Last active
August 29, 2015 14:06
-
-
Save srph/ffa3561f2fe98b8eb99c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package controllers; | |
| import play.*; | |
| import play.mvc.*; | |
| import views.html.*; | |
| public class Application extends Controller { | |
| public static Result index() { | |
| return ok("READY"); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @main( "Publish new article" ) { | |
| <form> | |
| <div class="form-group"> | |
| <label> Title </label> | |
| <input type="text" name="title" class="form-group" value=""> | |
| </div> | |
| <div class="form-group"> | |
| <label> Content </label> | |
| <textarea rows="12" name="content" class="form-group" value=""></textarea> | |
| </div> | |
| <div class="form-group"> | |
| <button type="submit" class="btn btn-submit">Publish article</button> | |
| </div> | |
| </form> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @(article: models.News) | |
| @main( "Edit article" ) { | |
| <form> | |
| <div class="form-group"> | |
| <label> Title </label> | |
| <input type="text" name="title" class="form-group" value="@article.getTitle()"> | |
| </div> | |
| <div class="form-group"> | |
| <label> Content </label> | |
| <textarea rows="12" name="content" class="form-group" value="@article.getContent()"></textarea> | |
| </div> | |
| <div class="form-group"> | |
| <button type="submit" class="btn btn-submit">Publish changes</button> | |
| </div> | |
| </form> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @(news: List[models.News]) | |
| @main("Manage News") { | |
| <table class="table table-striped"> | |
| <thead> | |
| <th> | |
| <td> # </td> | |
| <td> Actions </td> | |
| <td> Title </td> | |
| </th> | |
| </thead> | |
| <tbody> | |
| @for(article <- news) { | |
| <tr> | |
| <td> @article.getId() </td> | |
| <td> @article.getTitle() </td> | |
| </tr> | |
| } | |
| </tbody> | |
| </table> | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @(title: String)(content: Html) | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>@title</title> | |
| <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")"> | |
| <link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")"> | |
| <script src="@routes.Assets.at("javascripts/hello.js")" type="text/javascript"></script> | |
| </head> | |
| <body> | |
| <div class="row"> | |
| <div class="col-md-4"> | |
| <div class="list-group"> | |
| <a href="#" class="list-group-item"> Manage News </a> | |
| <a href="#" class="list-group-item"> Create News </a> | |
| <a href="#" class="list-group-item"> Logout </a> | |
| </div> | |
| <div> | |
| <div class="col-md-8"> | |
| @if( session.get("success") ) { | |
| <div class="alert alert-success"> | |
| <p> @session.get("success") </p> | |
| </div> | |
| } | |
| @content | |
| </div> | |
| </div> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package models; | |
| import java.util.*; | |
| import javax.persistence.*; | |
| import play.db.ebean.*; | |
| import play.data.format.*; | |
| import play.data.validation.*; | |
| @Entity | |
| public class News extends Model { | |
| @Id | |
| @Constraints.Min(10) | |
| public Long id; | |
| @Constraints.Required | |
| public String title; | |
| @Constraints.Required | |
| public String content; | |
| @Formats.DateTime(pattern="dd/MM/yyyy") | |
| public Date created_at = new Date(); | |
| @Formats.DateTime(pattern="dd/MM/yyyy") | |
| public Date updated_at = new Date(); | |
| public static Finder<Long, News> find = new Finder<Long, News>( | |
| Long.class, News.class | |
| ); | |
| public Long getId() | |
| { | |
| return this.id; | |
| } | |
| public String getTitle() | |
| { | |
| return this.title; | |
| } | |
| public String getContent() | |
| { | |
| return this.content; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Routes | |
| # This file defines all application routes (Higher priority routes first) | |
| # ~~~~ | |
| # Home page | |
| GET / controllers.Application.index() | |
| # Map static resources from the /public folder to the /assets URL path | |
| GET /assets/*file controllers.Assets.at(path="/public", file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package models; | |
| import java.util.*; | |
| import javax.persistence.*; | |
| import play.db.ebean.*; | |
| import play.data.format.*; | |
| import play.data.validation.*; | |
| @Entity | |
| public class User extends Model { | |
| @Id | |
| @Constraints.Min(10) | |
| public Long id; | |
| @Constraints.Required | |
| public String username; | |
| @Constraints.Required | |
| public String password; | |
| @Formats.DateTime(pattern="dd/MM/yyyy") | |
| public Date created_at = new Date(); | |
| @Formats.DateTime(pattern="dd/MM/yyyy") | |
| public Date updated_at = new Date(); | |
| public static Finder<Long, User> find = new Finder<Long, User>( | |
| Long.class, User.class | |
| ); | |
| public Long getId() | |
| { | |
| return this.id; | |
| } | |
| public String getUsername() | |
| { | |
| return this.username; | |
| } | |
| public String getPassword() | |
| { | |
| return this.password; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment