liftweb-uirouter
angularjs ui-router module for scala liftweb framework
git clone https://9o.is/git/liftweb-uirouter.git
UiRouter.scala
(1416B)
1 package net.liftmodules.uirouter
2
3 import net.liftweb._
4 import http._
5 import common._
6 import sitemap._
7
8 object UiRouter extends Factory {
9
10 import snippet._
11
12 /**
13 * Enables HTML5 Mode
14 */
15 val html5mode = new FactoryMaker[Boolean](true) {}
16
17 /**
18 * Ignores the UiRouter Loc Group. Adds entire sitemap.
19 */
20 val ignoreUiRouterGroup = new FactoryMaker[Boolean](true) {}
21
22 /**
23 * Default route when page lands on index.
24 */
25 val defaultRoute = new FactoryMaker[Box[Menu]](Empty) {}
26
27 /**
28 * The page title when page loads.
29 * example: pageTitle.set(setTitle(pageName => "Company Name - " + pageName))
30 */
31 val pageTitle = new FactoryMaker[String](setTitle()) {}
32
33 /**
34 * List of all the UI-router states.
35 */
36 lazy val routes = new FactoryMaker[Seq[Menu]](findRoutes) {}
37
38 /* Finds menu items that are in UiRouterGroup group. */
39 private def findRoutes = LiftRules.siteMap map {
40 siteMap =>
41 if(ignoreUiRouterGroup.vend)
42 siteMap.menus
43 else
44 siteMap.menus.filter(_.loc.inGroup_?(loc.UiRouter.group.head))
45 } openOr Nil
46
47 def init: Unit = {
48 // don't include cometajax.js. served by ui-router module
49 LiftRules.autoIncludeComet = ((session: LiftSession) => false)
50
51 // increase concurrent requests (since comet's aren't recycled -- need fix)
52 LiftRules.maxConcurrentRequests.default.set((request: Req) => 50)
53 }
54 }