Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
124 additions
and
98 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,8 @@ | |
/project/project | ||
/project/target | ||
/target | ||
/tmp | ||
/out | ||
/*.iml | ||
/.idea | ||
/.idea_modules |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Deploy on Heroku | ||
---------------- | ||
|
||
1. [Install the Heroku Toolbelt](http://toolbelt.heroku.com) | ||
|
||
2. [Signup for a Heroku Account](http://heroku.com/signup) | ||
|
||
3. Login to Heroku: | ||
|
||
$ heroku login | ||
|
||
4. Create a new Heroku app: | ||
|
||
$ heroku create -s cedar | ||
|
||
5. Push the local repo to Heroku: | ||
|
||
$ git push heroku master | ||
|
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package controllers | ||
|
||
import play.api.data.Form | ||
import play.api.data.Forms.{single, nonEmptyText} | ||
import play.api.mvc.{Action, Controller} | ||
import anorm.NotAssigned | ||
import com.codahale.jerkson.Json | ||
|
||
import models.Bar | ||
|
||
|
||
object Application extends Controller { | ||
|
||
val barForm = Form( | ||
single("name" -> nonEmptyText) | ||
) | ||
|
||
def index = Action { | ||
Ok(views.html.index(barForm)) | ||
} | ||
|
||
def addBar() = Action { implicit request => | ||
barForm.bindFromRequest.value map { name => | ||
Bar.create(Bar(NotAssigned, name)) | ||
Redirect(routes.Application.index()) | ||
} getOrElse BadRequest | ||
} | ||
|
||
def listBars() = Action { | ||
val bars = Bar.findAll() | ||
val json = Json.generate(bars) | ||
Ok(json).as(JSON) | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package models | ||
|
||
import play.api.db._ | ||
import play.api.Play.current | ||
|
||
import anorm._ | ||
import anorm.SqlParser._ | ||
|
||
case class Bar(id: Pk[Long], name: String) | ||
|
||
object Bar { | ||
|
||
val simple = { | ||
get[Pk[Long]]("id") ~ | ||
get[String]("name") map { | ||
case id~name => Bar(id, name) | ||
} | ||
} | ||
|
||
def findAll(): Seq[Bar] = { | ||
DB.withConnection { implicit connection => | ||
SQL("select * from bar").as(Bar.simple *) | ||
} | ||
} | ||
|
||
def create(bar: Bar): Unit = { | ||
DB.withConnection { implicit connection => | ||
SQL("insert into bar(name) values ({name})").on( | ||
'name -> bar.name | ||
).executeUpdate() | ||
} | ||
} | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,47 @@ | ||
# Configuration | ||
|
||
application.name=PlayBars2a | ||
# 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="E27D^[_<Lpt0vjad]de;3/i;tx3gpRmG4Byof/3nahO/dIo9gbsMWut1w3xg[>9W" | ||
application.secret="ohoNuVPmVIxMd9jH]Y5nd;c^aiG7<DSRubl@S;LLLWyHEyrE2a4n`Ixe1=fv8]Yu" | ||
|
||
# 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.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="jdbc:h2:mem:play" | ||
# db.default.user=sa | ||
# db.default.password= | ||
|
||
# Ebean configuration | ||
# ~~~~~ | ||
# You can declare as many Ebean servers as you want. | ||
# By convention, the default server is named `default` | ||
ebean.default="models.*" | ||
|
||
# Assets configuration | ||
# Evolutions | ||
# ~~~~~ | ||
assets.cache./public/stylesheets/bootstrap.min.css="max-age=3600" | ||
# You can disable evolutions if needed | ||
# evolutionplugin=disabled | ||
|
||
# Logger | ||
# ~~~~~ | ||
# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory . | ||
|
||
# Root logger: | ||
logger=ERROR | ||
logger.root=ERROR | ||
|
||
# Logger used by the framework: | ||
logger.play=INFO | ||
|
||
# Logger provided to your application: | ||
logger.application=DEBUG | ||
|
||
|
||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,12 @@ | ||
# --- Created by Ebean DDL | ||
# To stop Ebean DDL generation, remove this comment and start using Evolutions | ||
# --- First database schema | ||
|
||
# --- !Ups | ||
|
||
create table bar ( | ||
id varchar(255) not null, | ||
name varchar(255), | ||
constraint pk_bar primary key (id)) | ||
; | ||
|
||
create sequence bar_seq; | ||
|
||
|
||
|
||
create table bar ( | ||
id SERIAL PRIMARY KEY, | ||
name varchar(255) not null | ||
); | ||
|
||
# --- !Downs | ||
|
||
SET REFERENTIAL_INTEGRITY FALSE; | ||
|
||
drop table if exists bar; | ||
|
||
SET REFERENTIAL_INTEGRITY TRUE; | ||
|
||
drop sequence if exists bar_seq; | ||
|
||
drop table if exists bar; |
This file contains 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
Empty file.