terminal~/dev$ play new FlightClub
app → Application sources
└ assets → Compiled asset sources
└ stylesheets → Typically LESS CSS sources
└ javascripts → Typically CoffeeScript sources
└ controllers → Application controllers
└ models → Application business layer
└ views → Templates
build.sbt → Application build script
conf → Configurations files and other non-compiled resources
└ application.conf → Main configuration file
└ routes → Routes definition
public → Public assets
└ stylesheets → CSS files
└ javascripts → Javascript files
└ images → Image files
project → sbt configuration files
lib → Unmanaged libraries dependencies
logs → Standard logs folder
└ application.log → Default log file
# HTTP
# request URI Controller.method
# type
GET / controllers.Application.index()
GET /FlightSearch controllers.FlightsController.flightSearch()
POST /Login/ResetPassword controllers.SecurityManager.doReset()
DELETE /Cart/Remove controllers.Cart.remove(cartId: Long)
# Default Routes file: Default to Routes in the root package #application.router=my.application.Routes
# Database configuration # ~~~~~ # You can declare as many datasources as you want. # By convention, the default datasource is named "default" # Uncomment below or use the H2 in-memory database. db.default.driver=com.mysql.jdbc.Driver db.default.url="jdbc:mysql://localhost:3306/flights" db.default.user=... db.default.password=...
terminal~/dev/FlightClub$ play run
[info] Loading project definition from /Users/terminal/dev/FlightClub/project
--- (Running the application from SBT, auto-reloading is enabled) ---
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
(Server started, use Ctrl+D to stop and go back to the console...)
name := "FlightClub"
version := "1.0-SNAPSHOT"
libraryDependencies ++= Seq(
javaJdbc,
javaEbean,
cache,
"mysql" % "mysql-connector-java" % "5.1.18"
)
play.Project.playJavaSettings
--- (Running the application from SBT, auto-reloading is enabled) ---...
[info] Updating {file:/Users/terminal/dev/Flightclub/}flightclub...
[info] Resolving ...
[info] Done updating.
[info] Compiling 3 Scala sources and 2 Java sources to /Users/terminal/dev/Flightclub/target/scala-2.10/classes...
Form<User> userForm = form(User.class);
@Entity public class User { @Constraints.Required @Constraints.Email public String email; @Constraints.MinLength(6) public String password; public String validate() { if(authenticate(email,password) == null) { return "Invalid email or password"; } return null; } }
if(userForm.hasErrors()) {
return badRequest(form.render(userForm));
} else {
User user = userForm.get();
return ok("Got user " + user);
}
Variables are pretty easy
@black: #FFCC00
#header{
color: @black
}
Mixins are an easy way of including properties from one rule-set to another.
.bordered {
border-top: dotted 1px black;
border-bottom: solid 2px black;
}
#menu a {
color: #111;
.bordered;
}
Nesting Rules
#header {
color: black;
.navigation {
font-size: 12px;
}
.logo {
width: 300px;
}
}