├── project
├── build.properties
└── plugins.sbt
├── src
├── main
│ ├── resources
│ │ ├── views
│ │ │ └── GET
│ │ │ │ └── index.mustache
│ │ └── layouts
│ │ │ └── default.mustache
│ ├── scala
│ │ └── bowlerquickstart
│ │ │ ├── Bootstrap.scala
│ │ │ └── MyController.scala
│ └── webapp
│ │ └── WEB-INF
│ │ └── web.xml
└── test
│ └── scala
│ └── bowlerquickstart
│ └── SimpleRequestTest.scala
├── .gitignore
└── README.md
/project/build.properties:
--------------------------------------------------------------------------------
1 | sbt.version=0.11.2
2 |
--------------------------------------------------------------------------------
/src/main/resources/views/GET/index.mustache:
--------------------------------------------------------------------------------
1 | This is the index view!
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /project/project
2 | /project/target
3 | /target
4 | .history
--------------------------------------------------------------------------------
/src/main/resources/layouts/default.mustache:
--------------------------------------------------------------------------------
1 |
2 |
Bowler QuickStart App
3 |
4 | This is from the default.mustache layout
5 |
6 | {{&doLayout}}
7 |
8 |
9 |
--------------------------------------------------------------------------------
/project/plugins.sbt:
--------------------------------------------------------------------------------
1 | resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
2 |
3 | libraryDependencies <+= sbtVersion(v => v match {
4 | case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8"
5 | case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10"
6 | case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11"
7 | case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-0.2.11.1"
8 | case x if (x.startsWith("0.12")) => "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1"
9 | })
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Bowler SBT Quickstart
2 | The Bowler Quickstart is a Skeleton sbt project and Bowler app that gets you up and running with a minimal Bowler app that you can adapt in no time.
3 |
4 | ## Setup Instructions
5 | * Have [Simple Build Tool ("sbt")](http://code.google.com/p/simple-build-tool/) installed
6 | * Create the directory where you want to start your app and run "git init"
7 | * Do "git pull https://github.com/wfaler/bowler-quickstart.git"
8 | * Run sbt
9 | * To check that it is working, type "container:start" to start a Jetty servlet container on port 8080, and visit http://localhost:8080/
10 | * Done! Ready to start writing your Bowler app!
--------------------------------------------------------------------------------
/src/test/scala/bowlerquickstart/SimpleRequestTest.scala:
--------------------------------------------------------------------------------
1 | package bowlerquickstart
2 |
3 |
4 | import org.scalatra.test.scalatest.ScalatraFunSuite
5 | import org.bowlerframework.http.BowlerFilter
6 |
7 |
8 | class SimpleRequestTest extends ScalatraFunSuite{
9 | val holder = this.addFilter(classOf[BowlerFilter], "/*")
10 |
11 | test("Simple Controller Route"){
12 | // let's run the bootstrap of the app
13 | val bootstrap = new Bootstrap
14 | get("/"){
15 | println(body)
16 | // lets just check that the body of the response contains the text in the index.mustache view file.
17 | assert(body.contains("This is the index view!"))
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/src/main/scala/bowlerquickstart/Bootstrap.scala:
--------------------------------------------------------------------------------
1 | package bowlerquickstart
2 |
3 | import org.bowlerframework.view.scalate._
4 | import org.bowlerframework.Request
5 |
6 | /**
7 | * This class acts as the starting point and bootstrap point for our application
8 | */
9 | class Bootstrap{
10 | // parent layout
11 | val parentLayout = DefaultLayout("default", "doLayout", None, None)
12 |
13 | def resolver(request: Request): Option[DefaultLayout] = Option(parentLayout)
14 | TemplateRegistry.defaultLayout = resolver(_)
15 |
16 |
17 | // I think we're ready to start and instantiate our Controller.
18 | val controller = new MyController
19 |
20 |
21 | // allow template reload during development - remove these lines in production for better performance
22 | org.bowlerframework.view.scalate.RenderEngine.getEngine.allowCaching = false
23 | org.bowlerframework.view.scalate.RenderEngine.getEngine.allowReload = true
24 | }
--------------------------------------------------------------------------------
/src/main/scala/bowlerquickstart/MyController.scala:
--------------------------------------------------------------------------------
1 | package bowlerquickstart
2 |
3 | import org.bowlerframework.controller.{Controller,FunctionNameConventionRoutes}
4 | import org.bowlerframework.model.{ ParameterMapper, Validations}
5 | import org.bowlerframework.view.{Renderable}
6 |
7 | /**
8 | *
9 | * extends:
10 | * - Controller: used to construct routes and deal with them by providing functions that respond to routes.
11 | * - ParameterMapper: takes a request and maps any values into beans or other objects.
12 | * - Validations: validation enables the Controller
13 | * - Renderable: allows you to render View Model objects.
14 | */
15 |
16 | class MyController extends Controller with ParameterMapper with Validations with Renderable with FunctionNameConventionRoutes {
17 |
18 |
19 | // simple, no args render, just renders the root view of /views/GET/index (or http 204 for JSON)
20 | // views are resolved by view-root ("/view" on the classpath by default) + HTTP Method + path,
21 | // in this case /views/GET/index. The ending of the template file (mustache, ssp, jade or scaml) will be auto-resolved in the order mentioned here.
22 | // for named params, the ":" of the Scalatra route definition will be replaced by "_" when looking up on the classpath.
23 | def `GET /` = render
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
2 |
21 |
22 |
26 |
27 | Bowler Sample
28 |
29 |
30 | examples
31 | org.bowlerframework.http.BowlerFilter
32 |
33 | bootstrapClass
34 | bowlerquickstart.Bootstrap
35 |
36 |
37 |
38 |
39 | examples
40 | /*
41 |
42 |
43 |
--------------------------------------------------------------------------------