Permalink
Browse files

updating source for play 2 rc1

  • Loading branch information...
1 parent 36d6fa0 commit 250a1a5b98819b3bc8ede72a1ef21ea07a5efcb1 @retroryan retroryan committed Jan 4, 2012
View
39 Playbars2a.iml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="FacetManager">
+ <facet type="scala" name="Scala">
+ <configuration>
+ <option name="compilerLibraryLevel" value="Global" />
+ <option name="compilerLibraryName" value="scala-compiler-2.9.1" />
+ </configuration>
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/app" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="file://$MODULE_DIR$/target/scala-2.9.1/classes" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library">
+ <library>
+ <CLASSES>
+ <root url="file://$MODULE_DIR$/target/scala-2.9.1/classes_managed" />
+ </CLASSES>
+ <JAVADOC />
+ <SOURCES />
+ </library>
+ </orderEntry>
+ <orderEntry type="library" name="Play 20 Source Build" level="application" />
+ </component>
+</module>
+
View
24 app/Global.java
@@ -1,13 +1,8 @@
-import com.avaje.ebean.Ebean;
-import models.Bar;
import play.Application;
import play.GlobalSettings;
import play.api.db.evolutions.OfflineEvolutions;
-import play.libs.Yaml;
import java.io.File;
-import java.util.List;
-import java.util.Map;
public class Global extends GlobalSettings {
@@ -18,26 +13,7 @@ public void beforeStart(Application app) {
}
public void onStart(Application app) {
- InitialData.insert(app);
}
- static class InitialData {
-
- public static void insert(Application app) {
-
- if (Ebean.find(Bar.class).findRowCount() == 0) {
-
- Map<String, List<Object>> all = (Map<String, List<Object>>) Yaml.load(
- app.resourceAsStream("conf/initial-data.yml"),
- app.classloader()
- );
-
- List<Object> bars = all.get("bars");
- Ebean.save(bars);
-
- }
- }
-
- }
}
View
11 app/controllers/Application.java
@@ -1,12 +1,14 @@
package controllers;
+
import models.Bar;
import play.data.Form;
+import play.mvc.Content;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.index;
-import static libs.Json.toJson;
+import static play.libs.Json.toJson;
public class Application extends Controller {
@@ -17,17 +19,18 @@ public static Result index() {
public static Result addBar() {
Form<Bar> form = form(Bar.class).bindFromRequest();
if (form.hasErrors()) {
- return badRequest(index.render("Error in Bar form. Enter new Bar",form(Bar.class)));
+ return badRequest(index.render("Error in Bar form. Enter new Bar", form(Bar.class)));
} else {
Bar bar = form.get();
bar.save();
return ok(
- index.render("The bar " + bar.name + " was saved. Enter a new Bar:", form(Bar.class))
+ index.render("The bar " + bar.name + " was saved. Enter a new Bar:", form(Bar.class))
);
}
}
public static Result listBars() {
- return ok(toJson(Bar.findAll()));
+ Content content = toJson(Bar.findAll());
+ return ok(content);
}
}
View
47 app/libs/Json.java
@@ -1,47 +0,0 @@
-package libs;
-
-
-import java.io.StringWriter;
-import org.codehaus.jackson.map.ObjectMapper;
-
-/**
- * provides helpers to deal with JSON
- */
-
-public class Json {
-
- /**
- * provides a simple way to serialize into JSON.
- *
- * usage (in a controller):
- * public static Result index() {
- *{{{
- *Map<String,String> d = new HashMap<String,String>();
- *d.put("peter","foo");
- *d.put("yay","value");
- * return ok(toJson(d));
- *}
- *}}}
- *
- * @param data to be serialized
- */
- public static play.api.mvc.Content toJson(final Object data) {
- return new play.api.mvc.Content() {
- public String body() {
- ObjectMapper mapper = new ObjectMapper();
- StringWriter w = new StringWriter();
- try {
- mapper.writeValue(w,data);
- } catch (java.io.IOException ex) {
- play.Logger.warn("could not seralize to JSON:"+data.toString());
- }
- return w.toString();
- }
-
- public String contentType() {
- return "application/json";
- }
- };
-
- }
-}
View
29 conf/application.conf
@@ -1,33 +1,39 @@
-# This is the main configuration file for the application.
-# ~~~~~
+# Configuration
+
+application.name=PlayBars2a
# 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=S_@xwrN5NtwvYyokBG[LxJ]ti7E8\bXOK^UV=>ejd39fgGGDhDA>Cl=0v\DU5mae
+application.secret="E27D^[_<Lpt0vjad]de;3/i;tx3gpRmG4Byof/3nahO/dIo9gbsMWut1w3xg[>9W"
# 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
-
-# The url needs to be modified with the actual url from the heroku environment variables. This needs to be changed to use environment variables
-db.default.url=jdbc:postgresql://ec2-107-21-110-190.compute-1.amazonaws.com/fjfancloqd?user=fjfancloqd&password=PZJcU_vQ-gatvF-a8zYb
db.default.driver=org.postgresql.Driver
+#eventually moving to heroku, we need to use an environment variable
+#for an in-memory database set this to --- jdbc:h2:mem:play
+#for postgresql database set this to --- jdbc:postgresql://localhost:5432/postgres?user=postgres&password=oracle
+
+db.default.url=${DATABASE_URL}
+
+
+
# Ebean configuration
# ~~~~~
# You can declare as many Ebean servers as you want.
# By convention, the default server is named `default`
-#
-ebean.default=models.*
+ebean.default="models.*"
+# Assets configuration
+# ~~~~~
+assets.cache./public/stylesheets/bootstrap.min.css="max-age=3600"
# Logger
# ~~~~~
@@ -42,3 +48,6 @@ logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG
+
+
+
View
6 db/evolutions/default/1.sql
@@ -12,9 +12,5 @@ create table bar (
# --- !Downs
-SET REFERENTIAL_INTEGRITY FALSE;
-
-drop table if exists bar;
-
-SET REFERENTIAL_INTEGRITY TRUE;
+drop table if exists bar cascade;
View
22 project/Build.scala
@@ -4,20 +4,18 @@ import PlayProject._
object ApplicationBuild extends Build {
- val appName = "playbars2"
- val appVersion = "1.0"
+ val appName = "PlayBars2a"
+ val appVersion = "1.0"
- val jacksonCoreAsl = "org.codehaus.jackson" % "jackson-core-asl" % "1.9.2"
- val jacksonMapperAsl = "org.codehaus.jackson" % "jackson-mapper-asl" % "1.9.2"
- val postgresql = "postgresql" % "postgresql" % "9.0-801.jdbc3"
+ val postgresql = "postgresql" % "postgresql" % "9.0-801.jdbc3"
- val appDependencies = Seq(
- // Add your project dependencies here,
- jacksonCoreAsl, jacksonMapperAsl, postgresql
- )
+ val appDependencies = Seq(
+ // Add your project dependencies here,
+ postgresql
+ )
- val main = PlayProject(appName, appVersion, appDependencies).settings(defaultJavaSettings: _*).settings(
- // Add your own project settings here
- )
+ val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
+ // Add your own project settings here
+ )
}
View
2 project/build.properties
@@ -1 +1 @@
-sbt.version=0.11.0
+sbt.version=0.11.2
View
5 project/plugins.sbt
@@ -1,9 +1,8 @@
resolvers ++= Seq(
DefaultMavenRepository,
- Resolver.url("Play", url("http://download.playframework.org/ivy-releases/"))(Resolver.ivyStylePatterns),
"Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
)
-libraryDependencies += "play" %% "play" % "2.0-beta"
+addSbtPlugin("play" % "sbt-plugin" % "2.0-RC1-SNAPSHOT")
-addSbtPlugin("com.typesafe.startscript" % "xsbt-start-script-plugin" % "0.5.0")
+addSbtPlugin("com.typesafe.startscript" % "xsbt-start-script-plugin" % "0.5.0")

0 comments on commit 250a1a5

Please sign in to comment.