Guest User

Untitled

a guest
May 21st, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. # Merb::Router is the request routing mapper for the merb framework.
  2. # See merb/specs/merb/router.rb for a fairly complete usage sample.
  3.  
  4. Merb.logger.info("Compiling routes...")
  5. Merb::Router.prepare do |r|
  6. r.match('/').defer_to do |request, params|
  7. if site = Site.find_by_domain(request.host)
  8. site.default_route
  9. else
  10. {:controller => 'exceptions', :action => 'not_found'}
  11. end
  12. end
  13.  
  14. r.match('/rsd.xml').to(:controller => 'rsd', :action => 'show')
  15.  
  16. r.match('/xmlrpc').defer_to do |request, params|
  17. function, args = XMLRPC::Marshal.load_call(request.raw_post)
  18. klass, method = function.split('.')
  19.  
  20. if(klass == 'wp')
  21. if(method == 'getPage')
  22. {:controller => 'wordpress', :action => 'get_page', :blog_id => args[0], :page_id => args[1], :username => args[2], :password => args[3]}
  23. elsif(method == 'newPage')
  24. {:controller => 'wordpress', :action => 'new_page', :blog_id => args[0], :username => args[1], :password => args[2], :struct => args[3], :publish => args[4] }
  25. end
  26. end
  27.  
  28. end
  29.  
  30. r.match('/xmlrpc').to(:controller => 'xmlrpc', :action => 'dispatch')
  31.  
  32. r.resources :posts
  33. r.resources :pages
  34. r.resources :categories
  35. r.resources :forms do |form|
  36. form.resources :form_entries
  37. end
  38.  
  39. r.namespace :admin do |admin|
  40. admin.resources :administrators
  41.  
  42. admin.resources :sites do |site|
  43. site.resources :writers
  44. site.resources :templates
  45. site.resources :pages
  46. site.resources :categories
  47. site.resources :forms do |form|
  48. form.resources :form_elements
  49. end
  50. end
  51. end
  52. r.match('/admin').to(:controller => 'admin/sites')
  53.  
  54.  
  55. # This is the default route for /:controller/:action/:id
  56. # This is fine for most cases. If you're heavily using resource-based
  57. # routes, you may want to comment/remove this line to prevent
  58. # clients from calling your create or destroy actions with a GET
  59. # r.default_routes
  60. end
Add Comment
Please, Sign In to add comment