Module: Cms::RouteExtensions
- Defined in:
- lib/cms/route_extensions.rb
Instance Method Summary collapse
-
#content_blocks(content_block_name, options = {}, &block) ⇒ Object
Adds all necessary routes to manage a new content type.
-
#mount_browsercms ⇒ Object
(also: #routes_for_browser_cms)
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 22 23 24 25 26 27 28 |
# File 'lib/cms/route_extensions.rb', line 8 def content_blocks(content_block_name, ={}, & block) content_name = content_block_name.to_s.classify begin content_block = "#{Cms::Module.current_namespace}::#{content_name}".constantize rescue NameError content_block = content_name.constantize end 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 |
#mount_browsercms ⇒ Object Also known as: routes_for_browser_cms
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''
mount_browsercms
end
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cms/route_extensions.rb', line 39 def mount_browsercms mount Cms::Engine => "/cms", :as => "cms" add_page_routes_defined_in_database # Handle 'stock' attachments match "/attachments/:id/:filename", :to=>"cms/attachments#download" match "/", :to=>"cms/content#show" match "*path", :to=>"cms/content#show" end |