Skip to content

Instantly share code, notes, and snippets.

@wfaler
wfaler / BowlerProject.scala
Created January 16, 2011 22:40
Bowler SBT Project File
import sbt._
class BowlerProject(info: ProjectInfo) extends DefaultWebProject(info){
val bowler = "org.bowlerframework" %% "core" % "0.5.1"
val slf4jVersion = "1.6.0"
val sfl4jnop = "org.slf4j" % "slf4j-nop" % slf4jVersion % "runtime"
// allows you to use an embedded/in-JVM jetty-server to run unit-tests.
@wfaler
wfaler / pom.xml
Created January 16, 2011 22:46
pom.xml
This goes into your <repositories>-section of your pom.xml:
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>https://oss.sonatype.org/content/repositories/releases</url>
</repository>
This goes into your <dependencies>-section:
<dependency>
<groupId>org.bowlerframework</groupId>
@wfaler
wfaler / WidgetController.scala
Created January 16, 2011 23:21
WidgetController
package org.bowlerframework.examples
import org.bowlerframework.model.Validations
import org.bowlerframework.view.{Renderable, ViewPath}
import org.bowlerframework.view.scalate.DefaultLayout
import org.bowlerframework._
import controller.{FunctionNameConventionRoutes, Controller, LayoutAware}
/**
* Our main application controller, showing a simple CRUD interface.
@wfaler
wfaler / web.xml
Created January 17, 2011 21:42
web.xml
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Bowler Sample</display-name>
<filter>
<filter-name>examples</filter-name>
<filter-class>org.bowlerframework.http.BowlerFilter</filter-class>
@wfaler
wfaler / Bootstrap.scala
Created January 17, 2011 21:45
Bootstrap.scala
package bowlerquickstart
import org.bowlerframework.view.scalate._
/**
* This class acts as the starting point and bootstrap point for our application
*/
class Bootstrap{
// parent layout
val parentLayout = DefaultLayout("default")
@wfaler
wfaler / MyController.scala
Created January 17, 2011 22:15
MyController.scala
class MyController extends Controller{
// responds to GET requests at /widgets/
get("/widgets/")((request, response) => {
..code goes here..
})
// responds to GET requests at /widgets/[someId], where
// ":id" will be mapped to a named request parameter "id"
get("/widgets/:id")((request, response) => {
@wfaler
wfaler / wildcard.scala
Created January 17, 2011 22:17
wildcard.scala
get("/say/*/to/*")((request, response) => {
..code goes here..
})
@wfaler
wfaler / regexroute.scala
Created January 17, 2011 22:20
regexroute.scala
get("""^\/f(.*)/b(.*)""".r)((request, response) => {
.. code here ..
})
@wfaler
wfaler / widgetcontroller.scala
Created January 17, 2011 22:54
widgetcontroller.scala
case class Widget(id: Long, name: String, priceInPence: Int)
class WidgetController extends Controller with Renderable with FunctionNameConventionRoutes{
def `GET /showAWidget` = {
val myWidget = Widget(1, "My Widget", 1000)
render(myWidget)
}
}
@wfaler
wfaler / widget.html
Created January 17, 2011 22:58
widget.html
{{#widget}}
<b>Id</b><br/>
{{id}}<br/>
<b>Name</b><br/>
{{name}}<br/>
<b>Price</b><br/>
{{priceInPence}}<br/>
{{/widget}}