Module Cms::Routes
In: lib/cms/routes.rb

Methods

Public Instance methods

[Source]

    # File lib/cms/routes.rb, line 3
 3:   def content_blocks(content_block_name, options={}, &block)
 4:     content_block = content_block_name.to_s.classify.constantize
 5:     resources(*[content_block_name, default_routes_for_content_block(content_block).deep_merge(options)], &block)
 6:     if content_block.versioned?
 7:       # I'm not sure why, but these named routes 
 8:       # don't end up getting nested in the CMS namepace.
 9:       # So for now I'm just hard-coding the stuff related to the CMS namespace
10:       send("version_cms_#{content_block_name}".to_sym, 
11:         "/cms/#{content_block_name}/:id/version/:version",
12:         :controller => "cms/#{content_block_name}",
13:         :action => "version",
14:         :conditions => {:method => :get})
15:       send("revert_to_cms_#{content_block_name}".to_sym, 
16:         "/cms/#{content_block_name}/:id/revert_to/:version",
17:         :controller => "cms/#{content_block_name}",
18:         :action => "revert_to",
19:         :conditions => {:method => :put})
20:     end
21:   end

[Source]

    # File lib/cms/routes.rb, line 23
23:   def default_routes_for_content_block(content_block)
24:     member_routes = {}
25:     member_routes[:publish] = :put if content_block.publishable?
26:     member_routes[:versions] = :get if content_block.versioned?
27:     member_routes[:usages] = :get if content_block.connectable?    
28:     {:member => member_routes}
29:   end

[Source]

     # File lib/cms/routes.rb, line 31
 31:   def routes_for_browser_cms
 32: 
 33:     namespace(:cms) do |cms|
 34:       
 35:       cms.home '/', :controller => 'home'
 36:       
 37:       cms.logout '/logout', :controller => 'sessions', :action => 'destroy'
 38:       cms.login '/login', :controller => 'sessions', :action => 'new', :conditions => { :method => :get }
 39:       cms.connect '/login', :controller => 'sessions', :action => 'create', :conditions => { :method => :post }      
 40:       cms.dashboard '/dashboard', :controller => 'dashboard'
 41:       cms.sitemap '/sitemap', :controller => 'section_nodes'
 42: 
 43:       cms.content_types '/content_types', :controller => 'content_types'
 44:       cms.resources :connectors, :member => {
 45:         :move_up => :put,
 46:         :move_down => :put,
 47:         :move_to_bottom => :put,
 48:         :move_to_top => :put
 49:       }
 50:       cms.resources :links
 51: 
 52:       cms.resources :pages, :member => {
 53:         :archive => :put,
 54:         :hide => :put,
 55:         :publish => :put,
 56:         :versions => :get
 57:       }, :collection => {
 58:         :publish => :put
 59:       }, :has_many => [:tasks]
 60:       version_cms_page '/cms/pages/:id/version/:version', :controller => 'cms/pages', :action => 'version', :conditions => {:method => :get}
 61:       revert_to_cms_page '/cms/pages/:id/revert_to/:version', :controller => 'cms/pages', :action => 'revert_to', :conditions => {:method => :put}
 62: 
 63:       cms.file_browser '/sections/file_browser.xml', :controller => 'sections', :action => 'file_browser', :format => "xml"
 64:       cms.resources :sections, :has_many => [:links, :pages]
 65: 
 66:       cms.resources :section_nodes, :member => {
 67:         :move_before => :put,
 68:         :move_after => :put,
 69:         :move_to_beginning => :put,
 70:         :move_to_end => :put,
 71:         :move_to_root => :put
 72:       }
 73:       cms.attachment '/attachments/:id', :controller => 'attachments', :action => 'show'
 74: 
 75:       cms.resources :tasks, :member => {:complete => :put}, :collection => {:complete => :put}
 76:       cms.toolbar '/toolbar', :controller => 'toolbar'
 77:       
 78:       # TODO: Make an actual content library controller 
 79:       # that redirects to the last content type you were working on
 80:       cms.content_library '/content_library', :controller => 'html_blocks' 
 81:       
 82:       cms.content_blocks :html_blocks
 83:       cms.content_blocks :portlets, :member => {:usages => :get}
 84:       cms.handler "/portlet/:id/:handler", 
 85:         :controller => "portlet", 
 86:         :action => "execute_handler", 
 87:         :conditions => {:method => :post}
 88:       
 89:       cms.content_blocks :file_blocks
 90:       cms.content_blocks :image_blocks
 91:       cms.content_blocks :category_types
 92:       cms.content_blocks :categories
 93:       cms.content_blocks :tags
 94:       
 95:       cms.administration '/administration', :controller => 'users'
 96:       
 97:       cms.with_options :controller => "cache" do |cache|
 98:           cache.cache "/cache", :action => "show", :conditions => {:method => :get}
 99:         cache.connect "/cache", :action => "destroy", :conditions => {:method => :delete}
100:       end
101:             
102:       cms.resources :email_messages
103:       cms.resources :groups
104:       cms.resources :redirects
105:       cms.resources :page_partials, :controller => 'dynamic_views'
106:       cms.resources :page_templates, :controller => 'dynamic_views'
107:       cms.resources :page_routes do |pr|
108:         pr.resources :conditions, :controller => "page_route_conditions"
109:         pr.resources :requirements, :controller => "page_route_requirements"
110:       end
111:       cms.routes "/routes", :controller => "routes"
112:       cms.resources :users, :member => {
113:         :change_password => :get, 
114:         :update_password => :put,
115:         :disable => :put, 
116:         :enable => :put
117:       }
118:       
119:     end
120: 
121:     if PageRoute.table_exists?
122:       PageRoute.all(:order => "page_routes.name").each do |r|
123:         send((r.route_name || 'connect').to_sym, r.pattern, r.options_map)
124:       end
125:     end
126: 
127:     connect '*path', :controller => 'cms/content', :action => 'show'    
128:   end

[Validate]