forked from viktortnk/lift-quickstart
/
Boot.scala
48 lines (37 loc) · 1.16 KB
/
Boot.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package bootstrap.liftweb
import net.liftweb._
import util._
import Helpers._
import common._
import http._
import mapper._
import sitemap._
import Loc._
import code.model._
/**
* A class that's instantiated early and run. It allows the application
* to modify lift's environment
*/
class Boot
{
def boot
{
// where to search snippet
LiftRules.addToPackages("code")
BootMapper.boot
BootSitemap.boot
// Use jQuery 1.4
LiftRules.jsArtifacts = net.liftweb.http.js.jquery.JQuery14Artifacts
// Show/hide the spinny image for Ajax calls request cycle
LiftRules.ajaxStart = Full(() => LiftRules.jsArtifacts.show("ajax-loader").cmd)
LiftRules.ajaxEnd = Full(() => LiftRules.jsArtifacts.hide("ajax-loader").cmd)
// Force the request to be UTF-8
LiftRules.early.append(_.setCharacterEncoding("UTF-8"))
// What is the function to test if a user is logged in?
LiftRules.loggedInTest = Full(() => User.loggedIn_?)
// Use HTML5 for rendering
LiftRules.htmlProperties.default.set((r: Req) => new Html5Properties(r.userAgent))
// Make a transaction span the whole HTTP request
S.addAround(DB.buildLoanWrapper)
}
}