Class: ActionDispatch::Routing::Mapper

Inherits:
Object
  • Object
show all
Defined in:
lib/comfortable_mexican_sofa/routes/cms_admin.rb,
lib/comfortable_mexican_sofa/routes/cms.rb,
lib/comfortable_mexican_sofa/routing.rb

Instance Method Summary collapse

Instance Method Details

#comfy_route(identifier, options = {}) ⇒ Object



8
9
10
# File 'lib/comfortable_mexican_sofa/routing.rb', line 8

def comfy_route(identifier, options = {})
  send("comfy_route_#{identifier}", options)
end

#comfy_route_cms(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/comfortable_mexican_sofa/routes/cms.rb', line 5

def comfy_route_cms(options = {})
  ComfortableMexicanSofa.configuration.public_cms_path = options[:path]

  scope module: :comfy, as: :comfy do
    namespace :cms, path: options[:path] do
      get "cms-css/:site_id/:identifier(/:cache_buster)" => "assets#render_css", as: "render_css"
      get "cms-js/:site_id/:identifier(/:cache_buster)"  => "assets#render_js",  as: "render_js"

      get "(*cms_path)" => "content#show", as: "render_page", action: "/:format"
    end
  end
end

#comfy_route_cms_admin(path: "admin") ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
# File 'lib/comfortable_mexican_sofa/routes/cms_admin.rb', line 5

def comfy_route_cms_admin(path: "admin")
  scope module: :comfy, as: :comfy do
    scope module: :admin do
      namespace :cms, as: :admin_cms, path: path, except: :show do
        get "/", to: "base#jump"

        concern :with_revisions do |options|
          resources :revisions, options.merge(only: %i[index show]) do
            patch :revert, on: :member
          end
        end

        concern :with_reorder do
          put :reorder, on: :collection
        end

        concern :with_form_fragments do
          get :form_fragments, on: :member
        end

        resources :sites do
          resources :pages do
            concerns :with_reorder
            concerns :with_form_fragments
            concerns :with_revisions, controller: "revisions/page"

            get :toggle_branch,  on: :member

            resources :translations, except: [:index] do
              concerns :with_form_fragments
              concerns :with_revisions, controller: "revisions/translation"
            end
          end

          resources :files, concerns: [:with_reorder]

          resources :layouts do
            concerns :with_reorder
            concerns :with_revisions, controller: "revisions/layout"
          end

          resources :snippets do
            concerns :with_reorder
            concerns :with_revisions, controller: "revisions/snippet"
          end

          resources :categories
        end
      end
    end
  end
end