Skip to content

Commit b4f41d5

Browse files
committed
Configure Play framework
1 parent 011c913 commit b4f41d5

14 files changed

+193
-3
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
logs
2+
project/project
3+
project/target
4+
target
5+
tmp
6+
.history
7+
dist
8+
/.idea
9+
/*.iml
10+
/out
11+
/.idea_modules
12+
/.classpath
13+
/.project
14+
/RUNNING_PID
15+
/.settings
16+
17+

app/controllers/Application.scala

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package controllers
2+
3+
import play.api._
4+
import play.api.mvc._
5+
6+
object Application extends Controller {
7+
8+
def index = Action {
9+
Ok(views.html.index("Your new application is ready."))
10+
}
11+
12+
}

app/views/index.scala.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@(message: String)
2+
3+
@main("Welcome to Play") {
4+
5+
@play20.welcome(message)
6+
7+
}

app/views/main.scala.html

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@(title: String)(content: Html)
2+
3+
<!DOCTYPE html>
4+
5+
<html>
6+
<head>
7+
<title>@title</title>
8+
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
9+
<link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
10+
<script src="@routes.Assets.at("javascripts/jquery-1.9.0.min.js")" type="text/javascript"></script>
11+
</head>
12+
<body>
13+
@content
14+
</body>
15+
</html>

build.sbt

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,12 @@ name := "htreader"
22

33
version := "1.0"
44

5+
lazy val `htreader` = (project in file(".")).enablePlugins(PlayScala)
6+
57
scalaVersion := "2.11.7"
6-
8+
9+
libraryDependencies ++= Seq( jdbc , cache , ws , specs2 % Test )
10+
11+
unmanagedResourceDirectories in Test <+= baseDirectory ( _ /"target/web/public/test" )
12+
13+
resolvers += "scalaz-bintray" at "https://dl.bintray.com/scalaz/releases"

conf/application.conf

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This is the main configuration file for the application.
2+
# ~~~~~
3+
4+
# Secret key
5+
# ~~~~~
6+
# The secret key is used to secure cryptographics functions.
7+
# If you deploy your application to several instances be sure to use the same key!
8+
application.secret="%APPLICATION_SECRET%"
9+
10+
# The application languages
11+
# ~~~~~
12+
application.langs="en"
13+
14+
# Global object class
15+
# ~~~~~
16+
# Define the Global object class for this application.
17+
# Default to Global in the root package.
18+
# application.global=Global
19+
20+
# Router
21+
# ~~~~~
22+
# Define the Router object to use for this application.
23+
# This router will be looked up first when the application is starting up,
24+
# so make sure this is the entry point.
25+
# Furthermore, it's assumed your route file is named properly.
26+
# So for an application router like `my.application.Router`,
27+
# you may need to define a router file `conf/my.application.routes`.
28+
# Default to Routes in the root package (and conf/routes)
29+
# application.router=my.application.Routes
30+
31+
# Database configuration
32+
# ~~~~~
33+
# You can declare as many datasources as you want.
34+
# By convention, the default datasource is named `default`
35+
#
36+
# db.default.driver=org.h2.Driver
37+
# db.default.url="jdbc:h2:mem:play"
38+
# db.default.user=sa
39+
# db.default.password=""
40+
41+
# Evolutions
42+
# ~~~~~
43+
# You can disable evolutions if needed
44+
# evolutionplugin=disabled
45+
46+
# Logger
47+
# ~~~~~
48+
# You can also configure logback (http://logback.qos.ch/),
49+
# by providing an application-logger.xml file in the conf directory.
50+
51+
# Root logger:
52+
logger.root=ERROR
53+
54+
# Logger used by the framework:
55+
logger.play=INFO
56+
57+
# Logger provided to your application:
58+
logger.application=DEBUG
59+

conf/routes

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Routes
2+
# This file defines all application routes (Higher priority routes first)
3+
# ~~~~
4+
5+
# Home page
6+
GET / controllers.Application.index
7+
8+
# Map static resources from the /public folder to the /assets URL path
9+
GET /assets/*file controllers.Assets.at(path="/public", file)
10+
11+

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 0.13.8
1+
sbt.version=0.13.5

project/plugins.sbt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
logLevel := Level.Warn
1+
logLevel := Level.Warn
2+
3+
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
4+
5+
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.6")

public/images/favicon.png

676 Bytes
Loading

public/javascripts/jquery-1.9.0.min.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/stylesheets/main.css

Whitespace-only changes.

test/ApplicationSpec.scala

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import org.specs2.mutable._
2+
import org.specs2.runner._
3+
import org.junit.runner._
4+
5+
import play.api.test._
6+
import play.api.test.Helpers._
7+
8+
/**
9+
* Add your spec here.
10+
* You can mock out a whole application including requests, plugins etc.
11+
* For more information, consult the wiki.
12+
*/
13+
@RunWith(classOf[JUnitRunner])
14+
class ApplicationSpec extends Specification {
15+
16+
"Application" should {
17+
18+
"send 404 on a bad request" in new WithApplication{
19+
route(FakeRequest(GET, "/boum")) must beNone
20+
}
21+
22+
"render the index page" in new WithApplication{
23+
val home = route(FakeRequest(GET, "/")).get
24+
25+
status(home) must equalTo(OK)
26+
contentType(home) must beSome.which(_ == "text/html")
27+
contentAsString(home) must contain ("Your new application is ready.")
28+
}
29+
}
30+
}

test/IntegrationSpec.scala

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import org.specs2.mutable._
2+
import org.specs2.runner._
3+
import org.junit.runner._
4+
5+
import play.api.test._
6+
import play.api.test.Helpers._
7+
8+
/**
9+
* add your integration spec here.
10+
* An integration test will fire up a whole play application in a real (or headless) browser
11+
*/
12+
@RunWith(classOf[JUnitRunner])
13+
class IntegrationSpec extends Specification {
14+
15+
"Application" should {
16+
17+
"work from within a browser" in new WithBrowser {
18+
19+
browser.goTo("http://localhost:" + port)
20+
21+
browser.pageSource must contain("Your new application is ready.")
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)