I have created a very small lift project that I will use to show some lift trick and how-to. The master branch shows the simplest project possible. It includes a basic build.sbt file:
1: name := "shiny-lana" 2: 3: oranization := "shiny.lana" 4: 5: version := "0.0.1-SNAPSHOT" 6: 7: scalaVersion := "2.9.1" 8: 9: seq(webSettings :_*) 10: 11: libraryDependencies ++= { 12: val liftVersion = "2.4" 13: Seq( 14: "net.liftweb" %% "lift-webkit" % liftVersion % "compile", 15: "org.mortbay.jetty" % "jetty" % "6.1.26" % "container", 16: "org.scalatest" %% "scalatest" % "1.8" % "test" 17: ) 18: } 19: 20: unmanagedResourceDirectories in Test <+= (baseDirectory) { _ / "src/main/webapp" }
It is a typical sbt build file. In line 9 , we configure the web
plugin so we can use container:start
to start a server with the
running application. In line 20, we include the src/main/webapp
directory in the classpath for test so we can test the snippets. The
plugins.sbt is a single line to include the xsbt-web-plugin.
The Boot class include the most basic:
1: class Boot { 2: 3: def boot { 4: 5: LiftRules.addToPackages("shiny.lana") 6: LiftRules.early.append(_.setCharacterEncoding("UTF-8")) 7: LiftRules.htmlProperties.default.set((r: Req) => new Html5Properties(r.userAgent)) 8: 9: } 10: }
We still include a small test to check that we're getting the Hello World message:
1: class WorldSpec extends FlatSpec with ShouldMatchers { 2: 3: "The index" should "say Hello World !" in { 4: 5: val session = new LiftSession("/", "1", Empty) 6: S.initIfUninitted(session){ 7: new Boot().boot 8: val page = S.session.get.findAndProcessTemplate(List("index")).openTheBox 9: page.text should include("Hello World !") 10: } 11: } 12: }
The complete code is available on github https://github.com/arussel/shiny-lana