Permalink
Browse files

init

  • Loading branch information...
jamesward committed Nov 15, 2012
0 parents commit 69b84df521abcb7a02b96e69686462eac5ecb47a
@@ -0,0 +1,15 @@
+logs
+project/project
+project/target
+target
+tmp
+.history
+dist
+/.idea
+/*.iml
+/out
+/.idea_modules
+/.classpath
+/.project
+/RUNNING_PID
+/.settings
4 README
@@ -0,0 +1,4 @@
+This is your new Play 2.0 application
+=====================================
+
+This file will be packaged with your application, when using `play dist`.
@@ -0,0 +1,35 @@
+package controllers;
+
+import models.Bar;
+import play.*;
+import play.db.ebean.Model;
+import play.mvc.*;
+
+import views.html.*;
+
+import java.util.List;
+import java.util.UUID;
+
+public class Application extends Controller {
+
+ public static Result index() {
+ return redirect(routes.Application.getBars());
+ }
+
+ public static Result addBar() {
+ Bar bar = form(Bar.class).bindFromRequest().get();
+ bar.save();
+ return redirect(routes.Application.index());
+ }
+
+ public static Result getBars() {
+ List<Bar> bars = new Bar.Finder(String.class, Bar.class).all();
+ return ok(barList.render(bars));
+ }
+
+ public static Result getBar(UUID id) {
+ Bar bar = new Bar.Finder<String, Bar>(String.class, Bar.class).byId(id.toString());
+ return ok(barDetail.render(bar));
+ }
+
+}
@@ -0,0 +1,17 @@
+package models;
+
+import play.db.ebean.Model;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import java.util.UUID;
+
+@Entity
+public class Bar extends Model {
+
+ @Id
+ public UUID id;
+
+ public String name;
+
+}
@@ -0,0 +1,15 @@
+package utils
+
+import play.api.mvc.{PathBindable, QueryStringBindable}
+import java.util.UUID
+
+object Binders {
+ implicit def uuidPathBinder = new PathBindable[UUID] {
+ override def bind(key: String, value: String): Either[String, UUID] = {
+ Right(UUID.fromString(value))
+ }
+ override def unbind(key: String, id: UUID): String = {
+ id.toString
+ }
+ }
+}
@@ -0,0 +1,7 @@
+@(bar: Bar)
+
+@main("Welcome to Play 2.0") {
+
+ @bar.name
+
+}
@@ -0,0 +1,16 @@
+@(bars: List[Bar])
+
+@main("Welcome to Play 2.0") {
+
+ <ul>
+ @for(bar <- bars) {
+ <li><a href="@routes.Application.getBar(bar.id)">@bar.name</a></li>
+ }
+ </ul>
+
+ <form action="@routes.Application.addBar()" method="post">
+ <input type="text" name="name">
+ <input type="submit">
+ </form>
+
+}
@@ -0,0 +1,15 @@
+@(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/jquery-1.7.1.min.js")" type="text/javascript"></script>
+ </head>
+ <body>
+ @content
+ </body>
+</html>
@@ -0,0 +1,57 @@
+# This is the main configuration file for the application.
+# ~~~~~
+
+# Secret key
+# ~~~~~
+# The secret key is used to secure cryptographics functions.
+# If you deploy your application to several instances be sure to use the same key!
+application.secret="BBmA`MJWflLZVUmQJrHQ4agt[2OsIU@;:=wWVjsc<o2F4Vb9fIf4UvU9^<qSAm?6"
+
+# The application languages
+# ~~~~~
+application.langs="en"
+
+# Global object class
+# ~~~~~
+# Define the Global object class for this application.
+# Default to Global in the root package.
+# global=Global
+
+# Database configuration
+# ~~~~~
+# You can declare as many datasources as you want.
+# By convention, the default datasource is named `default`
+#
+db.default.driver=org.h2.Driver
+db.default.url="jdbc:h2:mem:play"
+# db.default.user=sa
+# db.default.password=
+#
+# You can expose this datasource via JNDI if needed (Useful for JPA)
+# db.default.jndiName=DefaultDS
+
+# Evolutions
+# ~~~~~
+# You can disable evolutions if needed
+# evolutionplugin=disabled
+
+# Ebean configuration
+# ~~~~~
+# You can declare as many Ebean servers as you want.
+# By convention, the default server is named `default`
+#
+ebean.default="models.*"
+
+# Logger
+# ~~~~~
+# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
+
+# Root logger:
+logger.root=ERROR
+
+# Logger used by the framework:
+logger.play=INFO
+
+# Logger provided to your application:
+logger.application=DEBUG
+
@@ -0,0 +1,22 @@
+# --- Created by Ebean DDL
+# To stop Ebean DDL generation, remove this comment and start using Evolutions
+
+# --- !Ups
+
+create table bar (
+ id varchar(40) not null,
+ name varchar(255),
+ constraint pk_bar primary key (id))
+;
+
+
+
+
+# --- !Downs
+
+SET REFERENTIAL_INTEGRITY FALSE;
+
+drop table if exists bar;
+
+SET REFERENTIAL_INTEGRITY TRUE;
+
@@ -0,0 +1,12 @@
+# Routes
+# This file defines all application routes (Higher priority routes first)
+# ~~~~
+
+# Home page
+GET / controllers.Application.index()
+POST /bar controllers.Application.addBar()
+GET /bar controllers.Application.getBars()
+GET /bar/:id controllers.Application.getBar(id: java.util.UUID)
+
+# Map static resources from the /public folder to the /assets URL path
+GET /assets/*file controllers.Assets.at(path="/public", file)
@@ -0,0 +1,18 @@
+import sbt._
+import Keys._
+import PlayProject._
+
+object ApplicationBuild extends Build {
+
+ val appName = "play2-ebean-uuid"
+ val appVersion = "1.0-SNAPSHOT"
+
+ val appDependencies = Seq(
+ // Add your project dependencies here,
+ )
+
+ val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
+ routesImport += "utils.Binders._"
+ )
+
+}
@@ -0,0 +1 @@
+sbt.version=0.11.3
@@ -0,0 +1,8 @@
+// Comment to get more information during initialization
+logLevel := Level.Warn
+
+// The Typesafe repository
+resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
+
+// Use the Play sbt plugin for Play projects
+addSbtPlugin("play" % "sbt-plugin" % "2.0.4")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Oops, something went wrong.
No changes.

0 comments on commit 69b84df

Please sign in to comment.