Folks, I'm made a ton of updates to sitemap.Loc. If you're using sitemap generically, these changes will not impact you. However, there are a bunch of new features:
- Loc is type-safe in terms of parameters... they're not just name-value pairs - Links and Text for a given Loc can be generated by passing in the appropriate type-safe parameters - Re-write rules can be part of Locs and can extract type-safe parameters which can be accessed and used in subsequent calls - Locs can have page-specific snippets that take as their parameter the parameter generated by the Loc during URL re-writing I'll illustrate with code for a page that does all the wiki stuff: /** * The WikiStuff object that provides menu, URL rewriting, * and snippet support for the page that displays wiki contents */ object WikiStuff extends Loc[WikiLoc] { object AllLoc extends WikiLoc("all", false) // the name of the page def name = "wiki" // the default parameters (used for generating the menu listing) def defaultParams = Full(WikiLoc("HomePage", false)) // no extra parameters def stuff = Nil // is the current page an "edit" or "view" def currentEdit = foundParam.is.map(_.edit) openOr false /** * Check for page-specific snippets and * do appropriate dispatching */ override val snippets: SnippetTest = { case ("wiki", Full(AllLoc)) => showAll _ case ("wiki", Full(wp @ WikiLoc(_ , true))) => editRecord(wp.record) _ case ("wiki", Full(wp @ WikiLoc(_ , false))) if !wp.record.saved_? => editRecord(wp.record) _ case ("wiki", Full(wp: WikiLoc)) => displayRecord(wp.record) _ } /** * Generate a link based on the current page */ val link = new Loc.Link[WikiLoc](List("wiki"), false) { override def createLink(in: WikiLoc) = { if (in.edit) Full(Text("/wiki/edit/"+urlEncode(in.page))) else Full(Text("/wiki/"+urlEncode(in.page))) } } /** * What's the text of the link? */ val text = new Loc.LinkText(calcLinkText _) def calcLinkText(in: WikiLoc): NodeSeq = if (in.edit) Text("Wiki edit "+in.page) else Text("Wiki "+in.page) /** * Rewrite the request and emit the type-safe parameter */ override val rewrite: LocRewrite = Full({ case RewriteRequest(ParsePath("wiki" :: "edit" :: page :: Nil, _, _,_), _, _) => (RewriteResponse("wiki" :: Nil), WikiLoc(page, true)) case RewriteRequest(ParsePath("wiki" :: page :: Nil, _, _,_), _, _) => (RewriteResponse("wiki" :: Nil), WikiLoc(page, false)) }) Questions? Thanks, David -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---