Class: Integral::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/integral/router.rb

Overview

Handles Integral routing

Class Method Summary collapse

Class Method Details

.draw_backendObject

Draws backend routes



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
# File 'lib/integral/router.rb', line 44

def self.draw_backend
  Integral::Engine.routes.draw do
    # Backend [User Only]
    scope Integral.backend_namespace do
      # User Authentication
      devise_for :users, class_name: 'Integral::User', module: :devise

      # WYSIWYG Editor
      mount Ckeditor::Engine => '/ckeditor'
    end

    namespace :backend, path: Integral.backend_namespace do
      get '/', to: 'static_pages#dashboard', as: 'dashboard'

      # User account Profile route
      get 'account', to: 'users#account'

      # User Management
      resources :users

      # Image Management
      resources :images, as: :img

      # Page Management
      resources :pages, except: [:show] do
        member do
          post 'duplicate'
          get 'activities', controller: 'pages'
          get 'activities/:activity_id', to: 'pages#activity', as: :activity
        end
      end

      # Activity Management
      resources :activities, only: %i[index show] do
        collection do
          post 'grid'
        end
      end

      # Post Management
      if Integral.blog_enabled?
        resources :posts, except: [:show] do
          member do
            post 'duplicate'
            get 'activities', controller: 'posts'
            get 'activities/:activity_id', to: 'posts#activity', as: :activity
          end
          # resources :comments, only: [:create, :destroy]
        end
      end

      # List Management
      resources :lists, except: [:show] do
        member do
          post 'duplicate'
        end
      end

      # Settings Management
      resources :settings, only: %i[index create]
    end
  end
end

.draw_frontendObject

Draws frontend routes including dynamic pages and blog routes



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/integral/router.rb', line 23

def self.draw_frontend
  Integral::Engine.routes.draw do
    # Dynamic pages (URLs are rewritten in Integral::Middleware::PageRouter)
    resources :pages, only: %i[show]

    # Visitor enquiries & newsletter signups
    post 'contact', to: 'contact#contact'
    post 'newsletter_signup', to: 'contact#newsletter_signup'

    # Frontend Blog routes
    if Integral.blog_enabled?
      scope Integral.blog_namespace do
        resources :tags, only: %i[index show]
      end
      # Post Routing must go after tags otherwise it will override
      resources Integral.blog_namespace, only: %i[show index], as: :posts, controller: 'posts'
    end
  end
end

.draw_rootObject

Draws root route



12
13
14
15
16
17
18
19
20
# File 'lib/integral/router.rb', line 12

def self.draw_root
  Integral::Engine.routes.draw do
    if Integral.dynamic_homepage_enabled?
      root 'pages#show'
    else
      root Integral.root_path
    end
  end
end

.loadObject

Loads Integral routes



5
6
7
8
9
# File 'lib/integral/router.rb', line 5

def self.load
  draw_root
  draw_frontend
  draw_backend
end