Created
December 15, 2011 17:25
-
-
Save d6y/1481964 to your computer and use it in GitHub Desktop.
Lift bookmarklet
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
// In our case, we have /bookmarklet/{uuid}?title={page title}&url={page url} | |
// In Boot: | |
LiftRules.statelessDispatchTable.prepend(Bookmarklet.dispatch) | |
// The bookmarklet itself.... | |
object Bookmarklet extends Loggable { | |
def dispatch: LiftRules.DispatchPF = { | |
case req@Req("bookmarklet" :: uuid :: Nil, _, GetRequest) => () => add(uuid, req) | |
} | |
// We're just returning static Javascript to say "OK, we got the URL" | |
val confirmation: Box[LiftResponse] = for (js <- LiftRules.loadResourceAsString("/js/bookmarklet-confirmation.js")) | |
yield JavaScriptResponse(JE.JsRaw(js)) | |
// Had to butcher this example out from existing system... not tried to compile :-/ | |
private def add(uuid: String, req: Req): Box[LiftResponse] = for { | |
person <- Person.byToken(uuid) | |
url <- req.param("u") | |
title_text = <- req.param("t") | |
} yield { | |
// do work here | |
confirmation | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment