-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroutes.rb
134 lines (107 loc) · 3.24 KB
/
routes.rb
1
2
3
4
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
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
# frozen_string_literal: true
Rails.application.routes.draw do
Healthcheck.routes(self)
image_resources :images, path: "dynamic_images/:digest(/:size)"
# Attachment
resources :attachments, path: "attachments/:digest", only: %i[show] do
member do
get :download
end
end
# Pages
resources :pages, path: ":locale/pages" do
collection do
get "search"
post "search"
post "preview"
end
end
get "/:locale/pages/:id/:page" => "pages#show",
constraints: { page: /\d+/ }, as: :paginated_page
# Redirect hack for backwards compatibility
get "pages/:locale" => redirect("/%{locale}/pages"), locale: /\w\w\w/
get "pages/:locale/*glob" => redirect("/%{locale}/pages/%{glob}"),
locale: /\w\w\w/
# Sitemaps
get("sitemap" => "pages_core/sitemaps#index", as: :sitemap_index)
get("/sitemap-pages-:locale" => "pages_core/sitemaps#pages",
as: :pages_sitemap)
namespace :admin do
get "users/login" => redirect("/admin/login")
# Invites
resources :invites do
member do
post :accept
end
end
controller :invites do
get "/invites/:id/:token" => :show, as: :invite_with_token
end
# Password resets
resource :account_recovery
controller :account_recoveries do
get "/account_recovery/:token" => :show, as: :account_recovery_with_token
end
# Attachments
resources :attachments, only: %i[create update]
# Images
resources :images
# Users
resources :users do
collection do
get "deactivated"
end
member do
delete "delete_image"
end
end
# Authentication
resource :session, only: %i[create destroy] do
member { post :verify_otp }
end
resource :otp_secret, only: %i[new create destroy]
resource :recovery_codes, only: %i[new create]
get "login" => "sessions#new", as: "login"
# Pages
scope ":locale" do
resources :news,
only: %i[index],
path: "pages/news(/:year(/:month)(/page/:page))"
resource :calendar,
path: "pages/calendar(/:year(/:month)(/page/:page))"
resources :pages do
collection do
get "deleted"
get "search"
end
member do
put "move"
end
get "new/:parent", action: "new"
end
end
end
# Default admin route
get("/admin" => redirect do |_env, _req|
"/admin/#{I18n.default_locale}/pages/news"
end,
as: "admin_default")
# Errors
resources :errors
# Page path routing
get ":locale/*path/page/:page" => "pages#show",
constraints: PagesCore::PagePathConstraint.new
get ":locale/*path" => "pages#show",
constraints: PagesCore::PagePathConstraint.new
get "*path/page/:page" => "pages#show",
constraints: PagesCore::PagePathConstraint.new,
defaults: { locale: I18n.default_locale.to_s }
get "*path" => "pages#show",
constraints: PagesCore::PagePathConstraint.new,
defaults: { locale: I18n.default_locale.to_s }
get "/401", to: "errors#unauthorized"
get "/403", to: "errors#forbidden"
get "/404", to: "errors#not_found"
get "/422", to: "errors#unacceptable"
get "/500", to: "errors#internal_error"
end