PageRenderTime 54ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/src/main/scala/com/mycotrack/lift/MycotrackUrlRewriter.scala

http://github.com/JanxSpirit/mycotrack_mongo
Scala | 49 lines | 39 code | 5 blank | 5 comment | 0 complexity | e2cae0ea1d37c7c3a06defed2c22864e MD5 | raw file
  1. package com.mycotrack.lift
  2. /*
  3. * User: gregg
  4. * Date: 4/9/11
  5. * Time: 11:35 PM
  6. */
  7. import _root_.net.liftweb.http._
  8. import net.liftweb.common.Full
  9. import com.mycotrack.model._
  10. import com.mycotrack.snippet._
  11. import com.mongodb._
  12. import com.mongodb.casbah.Imports._
  13. import com.mongodb.casbah.Implicits._
  14. trait MycotrackUrlRewriter {
  15. LiftRules.statelessRewrite.append {
  16. case RewriteRequest(
  17. ParsePath("projects" :: key :: Nil, "", true, false), _, _) => {
  18. val project = Project.find(MongoDBObject("key" -> key))
  19. SelectedProject(project)
  20. RewriteResponse("events" :: Nil)
  21. }
  22. }.append {
  23. case RewriteRequest(
  24. ParsePath("manageSpecies" :: Nil, "", true, false), _, _) => {
  25. val species = Species.createRecord
  26. theSpecies(Full(species))
  27. RewriteResponse(ParsePath("manageSpecies" :: Nil, "", true, false), Map.empty, true)
  28. }
  29. }.append {
  30. case RewriteRequest(
  31. ParsePath("speciesInfo" :: id :: Nil, "", true, false), _, _) => {
  32. val species = Species.find(id)
  33. theSpecies(species)
  34. RewriteResponse(ParsePath("speciesInfo" :: Nil, "", true, false), Map.empty, true)
  35. }
  36. }.append {
  37. case RewriteRequest(
  38. ParsePath("splitProject" :: id :: Nil, "", true, false), _, _) => {
  39. val project = Project.find(id)
  40. SelectedProject(project)
  41. RewriteResponse(ParsePath("splitProject" :: Nil, "", true, false), Map.empty, true)
  42. }
  43. }
  44. }