This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package code.snippet | |
import scala.xml._ | |
import net.liftweb.util.Helpers._ | |
import scala.xml.transform._ | |
import net.liftweb.common.Logger | |
object TBUtils extends Logger { | |
/* Transforms the XML produced by Menu.build such that any menus defined as: | |
Menu("Test") / "test" >> LocGroup("test") >> PlaceHolder submenus ( | |
Menu("Test 2") / "test2", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="topbar"> | |
<div class="fill"> | |
<div class="container"> | |
<a class="brand" href="/">My App</a> | |
<span class="lift:TBUtils.menuToTBNav?eager_eval=true"> | |
<span class="lift:Menu.builder? | |
top:class=nav;li_item:class=active;linkToSelf=true;expandAll=true"></span> | |
</span> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="topbar"> | |
<div class="fill"> | |
<div class="container"> | |
<a class="brand" href="/">My App</a> | |
<span class="lift:TBUtils.menuToTBNav?eager_eval=true"> | |
<span class="lift:Menu.builder? | |
top:class=nav;li_item:class=active;linkToSelf=true;expandAll=true"></span> | |
</span> | |
</div> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Menu("Home") / "index", | |
Menu("Page 1") / "page1", | |
Menu("Page 2") / "page2", | |
Menu("Page 3") / "page3" >> PlaceHolder >> submenus ( | |
Menu("Page 3a") / "page3a", | |
Menu("Page 3b") / "page3b" | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def userLinkText = User.currentUser.map(_.shortName).openOr("not logged in").toString | |
val entries = List(Menu("Home") / "index" >> LocGroup("main"), | |
Menu("Page 1") / "page1" >> LocGroup("main"), | |
Menu("Page 2") / "page2" >> LocGroup("main"), | |
Menu("Page 3") / "page3" >> LocGroup("main") >> PlaceHolder submenus ( | |
Menu("Page 3a") / "page3a" , | |
Menu("Page 3b") / "page3b" , | |
Menu("Page 3c") / "page3c") , | |
User.loginMenuLoc.open_!, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object User extends User with MetaMegaProtoUser[User] { | |
... | |
override def loginMenuLocParams = LocGroup("user") :: super.loginMenuLocParams | |
override def createUserMenuLocParams = LocGroup("user") :: super.createUserMenuLocParams | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="navbar"> | |
<div class="navbar-inner"> | |
<div class="container"> | |
<a class="brand" href="/">My App</a> | |
<!-- create the 'main' menu items --> | |
<span data-lift="lift:TBNav.menuToTBNav?eager_eval=true"> | |
<span data-lift="lift:Menu.builder?top:class=nav;li_item:class=active;linkToSelf=true;expandAll=true;group=main"></span> | |
</span> | |
<!-- create the 'user' (e.g. login/logout etc) menu items --> | |
<span data-lift="lift:TBNav.menuToTBNav?eager_eval=true"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def serve(reqdFile: String) : Box[LiftResponse] = { | |
debug("request headers: " + S.request.map( _.headers.map(h => h._1 + "\t\t" + h._2 + "\n").toString).openOr("")) | |
User.currentUser match { | |
case Full(user) => { | |
try { | |
// e.g. turn 1092345.mp4 into (1092345,mp4) | |
var (baseName, ext) = Media.splitExtension(reqdFile) | |
// should be only one in the database, check to make sure, don't want to | |
// show someone else's video by accident!! | |
val mediaList = Media.findAll(By(Media.baseNamePhysical,baseName),By(Media.fileExtension,ext)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def serve(reqdFile: String): Box[LiftResponse] = { | |
debug("request headers: " + S.request.map(_.headers.map(h => h._1 + "\t\t" + h._2 + "\n").toString).openOr("")) | |
User.currentUser match { | |
case Full(user) => { | |
try { | |
debug("starting in Media Server for logical file: " + reqdFile + ".....") | |
// e.g. turn 1092345.mp4 into (1092345,mp4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StatelessTestRV extends Logger { | |
object searchResults extends RequestVar[List[String]](Nil) | |
def doSearch(param: String) = { | |
// dummy results .... | |
"one" :: "two" :: "three" :: Nil | |
} | |
def processSubmit(param: String) = { |
OlderNewer