Skip to content

Instantly share code, notes, and snippets.

@d6y
Created December 15, 2011 17:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d6y/1481964 to your computer and use it in GitHub Desktop.
Save d6y/1481964 to your computer and use it in GitHub Desktop.
Lift bookmarklet
// 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