liftweb-uirouter

angularjs ui-router module for scala liftweb framework

git clone https://9o.is/git/liftweb-uirouter.git

commit 188aeeefae3bbcee8c334dfee37e26c2fa29ef35
parent 374a15122248b13debdcce443cb82eafafb74766
Author: Jul <jul@9o.is>
Date:   Sat,  7 Jun 2014 07:05:40 -0400

moved code around

Diffstat:
Asrc/main/scala/net/liftmodules/uirouter/UiRouter.scala | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/main/scala/net/liftmodules/uirouter/package.scala | 56+-------------------------------------------------------
Msrc/main/scala/net/liftmodules/uirouter/snippet/UiJs.scala | 1+
3 files changed, 57 insertions(+), 55 deletions(-)

diff --git a/src/main/scala/net/liftmodules/uirouter/UiRouter.scala b/src/main/scala/net/liftmodules/uirouter/UiRouter.scala @@ -0,0 +1,54 @@ +package net.liftmodules.uirouter + +import net.liftweb._ +import http._ +import common._ +import sitemap._ + +object UiRouter extends Factory { + + import snippet._ + + /** + * Enables HTML5 Mode + */ + val html5mode = new FactoryMaker[Boolean](true) {} + + /** + * Ignores the UiRouter Loc Group. Adds entire sitemap. + */ + val ignoreUiRouterGroup = new FactoryMaker[Boolean](true) {} + + /** + * Default route when page lands on index. + */ + val defaultRoute = new FactoryMaker[Box[Menu]](Empty) {} + + /** + * The page title when page loads. + * example: pageTitle.set(setTitle(pageName => "Company Name - " + pageName)) + */ + val pageTitle = new FactoryMaker[String](setTitle()) {} + + /** + * List of all the UI-router states. + */ + lazy val routes = new FactoryMaker[Seq[Menu]](findRoutes) {} + + /* Finds menu items that are in UiRouterGroup group. */ + private def findRoutes = LiftRules.siteMap map { + siteMap => + if(ignoreUiRouterGroup.vend) + siteMap.menus + else + siteMap.menus.filter(_.loc.inGroup_?(loc.UiRouter.group.head)) + } openOr Nil + + def init: Unit = { + // don't include cometajax.js. served by ui-router module + LiftRules.autoIncludeComet = ((session: LiftSession) => false) + + // increase concurrent requests (since comet's aren't recycled -- need fix) + LiftRules.maxConcurrentRequests.default.set((request: Req) => 50) + } +} +\ No newline at end of file diff --git a/src/main/scala/net/liftmodules/uirouter/package.scala b/src/main/scala/net/liftmodules/uirouter/package.scala @@ -1,63 +1,9 @@ package net.liftmodules -import net.liftweb._ -import http._ -import common._ -import sitemap._ - -package object uirouter extends Factory { - import snippet._ - - /** - * Enables HTML5 Mode - */ - val html5mode = new FactoryMaker[Boolean](true) {} - - /** - * Ignores the UiRouter Loc Group. Adds entire sitemap. - */ - val ignoreUiRouterGroup = new FactoryMaker[Boolean](true) {} - - /** - * Default route when page lands on index. - */ - val defaultRoute = new FactoryMaker[Box[Menu]](Empty) {} - - /** - * The page title when page loads. - * example: pageTitle.set(setTitle(pageName => "Company Name - " + pageName)) - */ - val pageTitle = new FactoryMaker[String](setTitle()) {} - +package object uirouter { /** * Set document title on state change (provided the page name). */ def setTitle(edit: String => String = p => p): String = "document.title = "+edit(snippet.UiRouter.pageName)+";" - - /** - * List of all the UI-router states. - */ - lazy val routes = new FactoryMaker[Seq[Menu]](findRoutes) {} - - /* Finds menu items that are in UiRouterGroup group. */ - private def findRoutes = LiftRules.siteMap map { - siteMap => - if(ignoreUiRouterGroup.vend) - siteMap.menus - else - siteMap.menus.filter(_.loc.inGroup_?(loc.UiRouter.group.head)) - } openOr Nil - - - object UiRouter { - def init: Unit = { - // don't include cometajax.js. served by ui-router module - LiftRules.autoIncludeComet = ((session: LiftSession) => false) - - // increase concurrent requests (since comet's aren't recycled -- need fix) - LiftRules.maxConcurrentRequests.default.set((request: Req) => 50) - } - } - } \ No newline at end of file diff --git a/src/main/scala/net/liftmodules/uirouter/snippet/UiJs.scala b/src/main/scala/net/liftmodules/uirouter/snippet/UiJs.scala @@ -7,6 +7,7 @@ import js._ import common._ import util._ import Helpers._ +import net.liftmodules.uirouter.UiRouter._ /** * Just a bunch of javascript to append in html.