Module: Cms::Routes
- Defined in:
- lib/cms/routes.rb
Instance Method Summary collapse
-
#content_blocks(content_block_name, options = {}, &block) ⇒ Object
Adds all necessary routes to manage a new content type.
-
#routes_for_browser_cms ⇒ Object
Adds the routes required for BrowserCMS to function to a routes.rb file.
Instance Method Details
#content_blocks(content_block_name, options = {}, &block) ⇒ Object
Adds all necessary routes to manage a new content type. Works very similar to the Rails resources method, adding basic CRUD routes, as well as additional ones
for CMS specific routes (like versioning)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/cms/routes.rb', line 8 def content_blocks(content_block_name, ={}, & block) content_block = content_block_name.to_s.classify.constantize resources content_block_name do member do put :publish if content_block.publishable? get :versions if content_block.versioned? get :usages if content_block.connectable? end end if content_block.versioned? send("get", "/#{content_block_name}/:id/version/:version", :to=>"#{content_block_name}#version", :as=>"version_cms_#{content_block_name}".to_sym) send("put", "/#{content_block_name}/:id/revert_to/:version", :to=>"#{content_block_name}#revert_to", :as=>"revert_to_cms_#{content_block_name}".to_sym) end end |
#routes_for_browser_cms ⇒ Object
Adds the routes required for BrowserCMS to function to a routes.rb file. Should be the last route in the file, as all following routes will be ignored.
Usage:
YourAppName::Application.routes.draw do
match '/some/path/in/your/app' :to=>"controller#action''
routes_for_browser_cms
end
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/cms/routes.rb', line 32 def routes_for_browser_cms namespace :cms do match '/dashboard', :to=>"dashboard#index", :as=>'dashboard' match '/', :to => 'home#index', :as=>'home' match '/sitemap', :to=>"section_nodes#index", :as=>'sitemap' match '/content_library', :to=>"html_blocks#index", :as=>'content_library' match '/administration', :to=>"users#index", :as=>'administration' match '/logout', :to=>"sessions#destroy", :as=>'logout' get '/login', :to=>"sessions#new", :as=>'login' post '/login', :to=>"sessions#create" match '/toolbar', :to=>"toolbar#index", :as=>'toolbar' match '/content_types', :to=>"content_types#index", :as=>'content_types' resources :connectors do member do put :move_up put :move_down put :move_to_bottom put :move_to_top end end resources :links resources :pages do member do put :archive put :hide put :publish get :versions end collection do put :publish end resources :tasks end get '/pages/:id/version/:version', :to=>'pages#version', :as=>'version_cms_page' put '/pages/:id/revert_to/:version', :to=>'pages#revert_to', :as=>'revert_to_cms_page' resources :tasks do member do put :complete end collection do put :complete end end match '/sections/file_browser.xml', :to => 'sections#file_browser', :format => "xml", :as=>'file_browser' resources :sections do resources :links, :pages end resources :section_nodes do member do put :move_before put :move_after put :move_to_beginning put :move_to_end put :move_to_root end end match '/attachments/:id', :to => 'attachments#show', :as=>'attachment' match '/content_library', :to=>'html_blocks#index', :as=>'content_library' content_blocks :html_blocks content_blocks :portlets post '/portlet/:id/:handler', :to=>"portlet#execute_handler" content_blocks :file_blocks content_blocks :image_blocks content_blocks :category_types content_blocks :categories content_blocks :tags match '/administration', :to => 'users#index', :as=>'administration' resources :users do member do get :change_password put :update_password put :disable put :enable end end resources :email_messages resources :groups resources :redirects resources :page_partials, :controller => 'dynamic_views' resources :page_templates, :controller => 'dynamic_views' resources :page_routes do resources :conditions, :controller => "page_route_conditions" resources :requirements, :controller => "page_route_requirements" end get 'cache', :to=>'cache#show', :as=>'cache' delete 'cache', :to=>'cache#destroy' match "/routes", :to => "routes#index", :as=>'routes' end # Loads all Cms PageRoutes from the database # TODO: Needs a integration/functional level test to verify that a page route w/ constraints will be correctly mapped. if PageRoute.can_be_loaded? PageRoute.all(:order => "page_routes.name").each do |r| match r.pattern, :to=>r.to, :as=>r.route_name, :_page_route_id=>r.page_route_id, :via=>r.via, :constraints=>r.constraints end end match "/", :to=>"cms/content#show" match "*path", :to=>"cms/content#show" end |