Skip to content

Commit

Permalink
Add Play template
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrorijo91 committed Nov 4, 2015
0 parents commit 4a1be1b
Show file tree
Hide file tree
Showing 17 changed files with 226 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
@@ -0,0 +1,8 @@
logs
target
/.idea
/.idea_modules
/.classpath
/.project
/.settings
/RUNNING_PID
8 changes: 8 additions & 0 deletions LICENSE
@@ -0,0 +1,8 @@
This software is licensed under the Apache 2 license, quoted below.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License.
4 changes: 4 additions & 0 deletions README
@@ -0,0 +1,4 @@
This is your new Play application
=================================

This file will be packaged with your application, when using `activator dist`.
12 changes: 12 additions & 0 deletions app/controllers/Application.scala
@@ -0,0 +1,12 @@
package controllers

import play.api._
import play.api.mvc._

class Application extends Controller {

def index = Action {
Ok(views.html.index("Your new application is ready."))
}

}
7 changes: 7 additions & 0 deletions app/views/index.scala.html
@@ -0,0 +1,7 @@
@(message: String)

@main("Welcome to Play") {

@play20.welcome(message)

}
15 changes: 15 additions & 0 deletions app/views/main.scala.html
@@ -0,0 +1,15 @@
@(title: String)(content: Html)

<!DOCTYPE html>

<html lang="en">
<head>
<title>@title</title>
<link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/main.css")">
<link rel="shortcut icon" type="image/png" href="@routes.Assets.versioned("images/favicon.png")">
<script src="@routes.Assets.versioned("javascripts/hello.js")" type="text/javascript"></script>
</head>
<body>
@content
</body>
</html>
20 changes: 20 additions & 0 deletions build.sbt
@@ -0,0 +1,20 @@
name := """slick3play"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.6"

libraryDependencies ++= Seq(
jdbc,
cache,
ws,
specs2 % Test
)

resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases"

// Play provides two styles of routers, one expects its actions to be injected, the
// other, legacy style, accesses its actions statically.
routesGenerator := InjectedRoutesGenerator
44 changes: 44 additions & 0 deletions conf/application.conf
@@ -0,0 +1,44 @@
# This is the main configuration file for the application.
# ~~~~~

# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
#
# This must be changed for production, but we recommend not changing it in this file.
#
# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
play.crypto.secret = "changeme"

# The application languages
# ~~~~~
play.i18n.langs = [ "en" ]

# Router
# ~~~~~
# Define the Router object to use for this application.
# This router will be looked up first when the application is starting up,
# so make sure this is the entry point.
# Furthermore, it's assumed your route file is named properly.
# So for an application router like `my.application.Router`,
# you may need to define a router file `conf/my.application.routes`.
# Default to Routes in the root package (and conf/routes)
# play.http.router = my.application.Routes

# 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.username=sa
# db.default.password=""

# Evolutions
# ~~~~~
# You can disable evolutions if needed
# play.evolutions.enabled=false

# You can disable evolutions for a specific datasource if necessary
# play.evolutions.db.default.enabled=false
22 changes: 22 additions & 0 deletions conf/logback.xml
@@ -0,0 +1,22 @@
<configuration>

<conversionRule conversionWord="coloredLevel" converterClass="play.api.Logger$ColoredLevel" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%coloredLevel - %logger - %message%n%xException</pattern>
</encoder>
</appender>

<!--
The logger name is typically the Java/Scala package name.
This configures the log level to log at for a package and its children packages.
-->
<logger name="play" level="INFO" />
<logger name="application" level="DEBUG" />

<root level="ERROR">
<appender-ref ref="STDOUT" />
</root>

</configuration>
9 changes: 9 additions & 0 deletions conf/routes
@@ -0,0 +1,9 @@
# Routes
# This file defines all application routes (Higher priority routes first)
# ~~~~

# Home page
GET / controllers.Application.index

# Map static resources from the /public folder to the /assets URL path
GET /assets/*file controllers.Assets.versioned(path="/public", file: Asset)
4 changes: 4 additions & 0 deletions project/build.properties
@@ -0,0 +1,4 @@
#Activator-generated Properties
#Wed Nov 04 23:11:57 WET 2015
template.uuid=fce2d244-c545-409f-806e-7a0c3681b306
sbt.version=0.13.8
16 changes: 16 additions & 0 deletions project/plugins.sbt
@@ -0,0 +1,16 @@
// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.4.3")

// web plugins

addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.0.6")

addSbtPlugin("com.typesafe.sbt" % "sbt-jshint" % "1.0.3")

addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")

addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-mocha" % "1.1.0")
Binary file added public/images/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/javascripts/hello.js
@@ -0,0 +1,3 @@
if (window.console) {
console.log("Welcome to your Play application's JavaScript!");
}
Empty file added public/stylesheets/main.css
Empty file.
30 changes: 30 additions & 0 deletions test/ApplicationSpec.scala
@@ -0,0 +1,30 @@
import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._

import play.api.test._
import play.api.test.Helpers._

/**
* Add your spec here.
* You can mock out a whole application including requests, plugins etc.
* For more information, consult the wiki.
*/
@RunWith(classOf[JUnitRunner])
class ApplicationSpec extends Specification {

"Application" should {

"send 404 on a bad request" in new WithApplication{
route(FakeRequest(GET, "/boum")) must beSome.which (status(_) == NOT_FOUND)
}

"render the index page" in new WithApplication{
val home = route(FakeRequest(GET, "/")).get

status(home) must equalTo(OK)
contentType(home) must beSome.which(_ == "text/html")
contentAsString(home) must contain ("Your new application is ready.")
}
}
}
24 changes: 24 additions & 0 deletions test/IntegrationSpec.scala
@@ -0,0 +1,24 @@
import org.specs2.mutable._
import org.specs2.runner._
import org.junit.runner._

import play.api.test._
import play.api.test.Helpers._

/**
* add your integration spec here.
* An integration test will fire up a whole play application in a real (or headless) browser
*/
@RunWith(classOf[JUnitRunner])
class IntegrationSpec extends Specification {

"Application" should {

"work from within a browser" in new WithBrowser {

browser.goTo("http://localhost:" + port)

browser.pageSource must contain("Your new application is ready.")
}
}
}

0 comments on commit 4a1be1b

Please sign in to comment.