forked from forem/forem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroutes.rb
451 lines (398 loc) · 20.7 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# rubocop:disable Metrics/BlockLength
Rails.application.routes.draw do
use_doorkeeper do
controllers tokens: "oauth/tokens"
end
# Devise does not support scoping omniauth callbacks under a dynamic segment
# so this lives outside our i18n scope.
devise_for :users, controllers: {
omniauth_callbacks: "omniauth_callbacks",
registrations: "registrations",
invitations: "invitations",
passwords: "passwords",
confirmations: "confirmations"
}
devise_scope :user do
get "/enter", to: "registrations#new", as: :sign_up
get "/confirm-email", to: "confirmations#new"
delete "/sign_out", to: "devise/sessions#destroy"
end
get "/r/mobile", to: "deep_links#mobile"
get "/.well-known/apple-app-site-association", to: "deep_links#aasa"
# [@forem/delightful] - all routes are nested under this optional scope to
# begin supporting i18n.
scope "(/locale/:locale)", defaults: { locale: nil } do
get "/locale/:locale", to: "stories#index"
require "sidekiq/web"
require "sidekiq_unique_jobs/web"
require "sidekiq/cron/web"
authenticated :user, ->(user) { user.tech_admin? } do
Sidekiq::Web.class_eval do
use Rack::Protection, permitted_origins: [URL.url] # resolve Rack Protection HttpOrigin
end
mount Sidekiq::Web => "/sidekiq"
mount FieldTest::Engine, at: "abtests"
end
draw :admin
namespace :stories, defaults: { format: "json" } do
resource :feed, only: [:show] do
resource :pinned_article, only: %w[show update destroy]
get ":timeframe", to: "feeds#show", as: :timeframe
end
end
namespace :api, defaults: { format: "json" } do
scope module: :v0,
constraints: ApiConstraints.new(version: 0, default: true) do
resources :articles, only: %i[index show create update] do
collection do
get "me(/:status)", to: "articles#me", as: :me, constraints: { status: /published|unpublished|all/ }
get "/:username/:slug", to: "articles#show_by_slug", as: :slug
get "/latest", to: "articles#index", defaults: { sort: "desc" }
end
end
resources :comments, only: %i[index show]
resources :videos, only: [:index]
resources :podcast_episodes, only: [:index]
resources :users, only: %i[show] do
collection do
get :me
end
end
resources :tags, only: [:index]
resources :follows, only: [:create] do
collection do
get :tags
end
end
namespace :followers do
get :users
get :organizations
end
resources :readinglist, only: [:index]
resources :webhooks, only: %i[index create show destroy]
resources :listings, only: %i[index show create update]
get "/listings/category/:category", to: "listings#index", as: :listings_category
get "/analytics/totals", to: "analytics#totals"
get "/analytics/historical", to: "analytics#historical"
get "/analytics/past_day", to: "analytics#past_day"
get "/analytics/referrers", to: "analytics#referrers"
resources :health_checks, only: [] do
collection do
get :app
get :database
get :cache
end
end
resources :profile_images, only: %i[show], param: :username
resources :organizations, only: [:show], param: :username do
resources :users, only: [:index], to: "organizations#users"
resources :listings, only: [:index], to: "organizations#listings"
resources :articles, only: [:index], to: "organizations#articles"
end
resource :instance, only: %i[show]
end
end
namespace :notifications do
resources :counts, only: [:index]
resources :reads, only: [:create]
end
namespace :incoming_webhooks do
get "/mailchimp/:secret/unsubscribe", to: "mailchimp_unsubscribes#index", as: :mailchimp_unsubscribe_check
post "/mailchimp/:secret/unsubscribe", to: "mailchimp_unsubscribes#create", as: :mailchimp_unsubscribe
end
resources :messages, only: [:create]
resources :chat_channels, only: %i[index show create update]
resources :chat_channel_memberships, only: %i[index create edit update destroy]
resources :articles, only: %i[update create destroy] do
patch "/admin_unpublish", to: "articles#admin_unpublish"
end
resources :article_mutes, only: %i[update]
resources :comments, only: %i[create update destroy] do
patch "/hide", to: "comments#hide"
patch "/unhide", to: "comments#unhide"
patch "/admin_delete", to: "comments#admin_delete"
collection do
post "/moderator_create", to: "comments#moderator_create"
end
end
resources :comment_mutes, only: %i[update]
resources :users, only: %i[index], defaults: { format: :json } do # internal API
collection do
resources :devices, only: %i[create destroy]
end
end
namespace :users do
resource :settings, only: %i[update]
resource :notification_settings, only: %i[update]
end
resources :users, only: %i[update]
resources :reactions, only: %i[index create]
resources :response_templates, only: %i[index create edit update destroy]
resources :feedback_messages, only: %i[index create]
resources :organizations, only: %i[update create destroy]
resources :followed_articles, only: [:index]
resources :follows, only: %i[show create] do
collection do
get "/bulk_show", to: "follows#bulk_show"
patch "/bulk_update", to: "follows#bulk_update"
end
end
resources :image_uploads, only: [:create]
resources :notifications, only: [:index]
resources :tags, only: [:index] do
collection do
get "/onboarding", to: "tags#onboarding"
end
end
resources :stripe_active_cards, only: %i[create update destroy]
resources :github_repos, only: %i[index] do
collection do
post "/update_or_create", to: "github_repos#update_or_create"
end
end
resources :events, only: %i[index show]
resources :videos, only: %i[index create new]
resources :video_states, only: [:create]
resources :twilio_tokens, only: [:show]
resources :html_variant_trials, only: [:create]
resources :html_variant_successes, only: [:create]
resources :tag_adjustments, only: %i[create destroy]
resources :rating_votes, only: [:create]
resources :page_views, only: %i[create update]
resources :listings, only: %i[index new create edit update destroy dashboard]
resources :credits, only: %i[index new create] do
get "purchase", on: :collection, to: "credits#new"
end
resources :reading_list_items, only: [:update]
resources :poll_votes, only: %i[show create]
resources :poll_skips, only: [:create]
resources :profile_pins, only: %i[create update]
resources :display_ad_events, only: [:create]
resources :badges, only: [:index]
resources :user_blocks, param: :blocked_id, only: %i[show create destroy]
resources :podcasts, only: %i[new create]
resources :article_approvals, only: %i[create]
resources :video_chats, only: %i[show]
resources :sidebars, only: %i[show]
resources :profile_preview_cards, only: %i[show]
resources :user_subscriptions, only: %i[create] do
collection do
get "/subscribed", action: "subscribed"
end
end
namespace :followings, defaults: { format: :json } do
get :users
get :tags
get :organizations
get :podcasts
end
resource :onboarding, only: :show
resources :profiles, only: %i[update]
resources :profile_field_groups, only: %i[index], defaults: { format: :json }
resources :liquid_tags, only: %i[index], defaults: { format: :json }
resources :discussion_locks, only: %i[create destroy]
get "/verify_email_ownership", to: "email_authorizations#verify", as: :verify_email_authorizations
get "/search/tags", to: "search#tags"
get "/search/chat_channels", to: "search#chat_channels"
get "/search/listings", to: "search#listings"
get "/search/usernames", to: "search#usernames"
get "/search/feed_content", to: "search#feed_content"
get "/search/reactions", to: "search#reactions"
get "/chat_channel_memberships/find_by_chat_channel_id", to: "chat_channel_memberships#find_by_chat_channel_id"
get "/listings/dashboard", to: "listings#dashboard"
get "/listings/:category", to: "listings#index", as: :listing_category
get "/listings/:category/:slug", to: "listings#index", as: :listing_slug
get "/listings/:category/:slug/:view", to: "listings#index",
constraints: { view: /moderate/ }
get "/listings/:category/:slug/delete_confirm", to: "listings#delete_confirm"
delete "/listings/:category/:slug", to: "listings#destroy"
get "/notifications/:filter", to: "notifications#index"
get "/notifications/:filter/:org_id", to: "notifications#index"
get "/notification_subscriptions/:notifiable_type/:notifiable_id", to: "notification_subscriptions#show"
post "/notification_subscriptions/:notifiable_type/:notifiable_id", to: "notification_subscriptions#upsert"
patch "/onboarding_update", to: "users#onboarding_update"
patch "/onboarding_checkbox_update", to: "users#onboarding_checkbox_update"
patch "/onboarding_notifications_checkbox_update",
to: "users/notification_settings#onboarding_notifications_checkbox_update"
get "email_subscriptions/unsubscribe"
post "/chat_channels/:id/moderate", to: "chat_channels#moderate"
post "/chat_channels/:id/open", to: "chat_channels#open"
get "/connect", to: "chat_channels#index"
get "/connect/:slug", to: "chat_channels#index"
get "/chat_channels/:id/channel_info", to: "chat_channels#channel_info", as: :chat_channel_info
post "/chat_channels/create_chat", to: "chat_channels#create_chat"
post "/chat_channels/block_chat", to: "chat_channels#block_chat"
post "/chat_channel_memberships/remove_membership", to: "chat_channel_memberships#remove_membership"
post "/chat_channel_memberships/add_membership", to: "chat_channel_memberships#add_membership"
post "/join_chat_channel", to: "chat_channel_memberships#join_channel"
delete "/messages/:id", to: "messages#destroy"
patch "/messages/:id", to: "messages#update"
get "/internal", to: redirect("/admin")
get "/internal/:path", to: redirect("/admin/%{path}")
post "/pusher/auth", to: "pusher#auth"
# Chat channel
patch "/chat_channels/update_channel/:id", to: "chat_channels#update_channel"
post "/create_channel", to: "chat_channels#create_channel"
# Chat Channel Membership json response
get "/chat_channel_memberships/chat_channel_info/:id", to: "chat_channel_memberships#chat_channel_info"
post "/chat_channel_memberships/create_membership_request", to: "chat_channel_memberships#create_membership_request"
patch "/chat_channel_memberships/leave_membership/:id", to: "chat_channel_memberships#leave_membership"
patch "/chat_channel_memberships/update_membership/:id", to: "chat_channel_memberships#update_membership"
get "/channel_request_info/", to: "chat_channel_memberships#request_details"
patch "/chat_channel_memberships/update_membership_role/:id", to: "chat_channel_memberships#update_membership_role"
get "/join_channel_invitation/:channel_slug", to: "chat_channel_memberships#join_channel_invitation"
post "/joining_invitation_response", to: "chat_channel_memberships#joining_invitation_response"
get "/social_previews/article/:id", to: "social_previews#article", as: :article_social_preview
get "/social_previews/user/:id", to: "social_previews#user", as: :user_social_preview
get "/social_previews/organization/:id", to: "social_previews#organization", as: :organization_social_preview
get "/social_previews/tag/:id", to: "social_previews#tag", as: :tag_social_preview
get "/social_previews/listing/:id", to: "social_previews#listing", as: :listing_social_preview
get "/social_previews/comment/:id", to: "social_previews#comment", as: :comment_social_preview
get "/async_info/base_data", controller: "async_info#base_data", defaults: { format: :json }
get "/async_info/shell_version", controller: "async_info#shell_version", defaults: { format: :json }
# Settings
post "users/join_org", to: "users#join_org"
post "users/leave_org/:organization_id", to: "users#leave_org", as: :users_leave_org
post "users/add_org_admin", to: "users#add_org_admin"
post "users/remove_org_admin", to: "users#remove_org_admin"
post "users/remove_from_org", to: "users#remove_from_org"
delete "users/remove_identity", to: "users#remove_identity"
post "users/request_destroy", to: "users#request_destroy", as: :user_request_destroy
get "users/confirm_destroy/:token", to: "users#confirm_destroy", as: :user_confirm_destroy
delete "users/full_delete", to: "users#full_delete", as: :user_full_delete
post "organizations/generate_new_secret", to: "organizations#generate_new_secret"
post "users/api_secrets", to: "api_secrets#create", as: :users_api_secrets
delete "users/api_secrets/:id", to: "api_secrets#destroy", as: :users_api_secret
post "users/update_password", to: "users#update_password", as: :user_update_password
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root
get "/robots.:format", to: "pages#robots"
get "/api", to: redirect("https://docs.forem.com/api")
get "/privacy", to: "pages#privacy"
get "/terms", to: "pages#terms"
get "/contact", to: "pages#contact"
get "/code-of-conduct", to: "pages#code_of_conduct"
get "/report-abuse", to: "pages#report_abuse"
get "/welcome", to: "pages#welcome"
get "/challenge", to: "pages#challenge"
get "/checkin", to: "pages#checkin"
get "/badge", to: "pages#badge", as: :pages_badge
get "/💸", to: redirect("t/hiring")
get "/survey", to: redirect("https://dev.to/ben/final-thoughts-on-the-state-of-the-web-survey-44nn")
get "/events", to: "events#index"
get "/workshops", to: redirect("events")
get "/sponsors", to: "pages#sponsors"
get "/search", to: "stories/articles_search#index"
post "articles/preview", to: "articles#preview"
post "comments/preview", to: "comments#preview"
# These routes are required by links in the sites and will most likely to be replaced by a db page
get "/about", to: "pages#about"
get "/about-listings", to: "pages#about_listings"
get "/security", to: "pages#bounty"
get "/community-moderation", to: "pages#community_moderation"
get "/faq", to: "pages#faq"
get "/page/post-a-job", to: "pages#post_a_job"
get "/tag-moderation", to: "pages#tag_moderation"
get "/mod", to: "moderations#index", as: :mod
get "/mod/:tag", to: "moderations#index"
post "/fallback_activity_recorder", to: "ga_events#create"
get "/page/:slug", to: "pages#show"
scope "p" do
pages_actions = %w[welcome editor_guide publishing_from_rss_guide markdown_basics].freeze
pages_actions.each do |action|
get action, action: action, controller: "pages"
end
end
# Redirect previous settings changed after https://github.com/forem/forem/pull/11347
get "/settings/integrations", to: redirect("/settings/extensions")
get "/settings/misc", to: redirect("/settings")
get "/settings/publishing-from-rss", to: redirect("/settings/extensions")
get "/settings/ux", to: redirect("/settings/customization")
get "/settings/(:tab)", to: "users#edit", as: :user_settings
get "/settings/:tab/:org_id", to: "users#edit", constraints: { tab: /organization/ }
get "/settings/:tab/:id", to: "users#edit", constraints: { tab: /response-templates/ }
get "/signout_confirm", to: "users#signout_confirm"
get "/dashboard", to: "dashboards#show"
get "/dashboard/analytics", to: "dashboards#analytics"
get "dashboard/analytics/org/:org_id", to: "dashboards#analytics", as: :dashboard_analytics_org
get "dashboard/following", to: "dashboards#following_tags"
get "dashboard/following_tags", to: "dashboards#following_tags"
get "dashboard/following_users", to: "dashboards#following_users"
get "dashboard/following_organizations", to: "dashboards#following_organizations"
get "dashboard/following_podcasts", to: "dashboards#following_podcasts"
get "/dashboard/subscriptions", to: "dashboards#subscriptions"
get "/dashboard/:which", to: "dashboards#followers", constraints: { which: /user_followers/ }
get "/dashboard/:which/:org_id", to: "dashboards#show",
constraints: {
which: /organization/
}
get "/dashboard/:username", to: "dashboards#show"
# for testing rails mailers
unless Rails.env.production?
get "/rails/mailers", to: "rails/mailers#index"
get "/rails/mailers/*path", to: "rails/mailers#preview"
end
get "/embed/:embeddable", to: "liquid_embeds#show", as: "liquid_embed"
# serviceworkers
get "/serviceworker", to: "service_worker#index"
get "/manifest", to: "service_worker#manifest"
# open search
get "/open-search", to: "open_search#show",
constraints: { format: /xml/ }
get "/new", to: "articles#new"
get "/new/:template", to: "articles#new"
get "/pod", to: "podcast_episodes#index"
get "/podcasts", to: redirect("pod")
get "/readinglist", to: "reading_list_items#index"
get "/readinglist/:view", to: "reading_list_items#index", constraints: { view: /archive/ }
get "/feed", to: "articles#feed", as: "feed", defaults: { format: "rss" }
get "/feed/tag/:tag", to: "articles#feed", as: "tag_feed", defaults: { format: "rss" }
get "/feed/latest", to: "articles#feed", as: "latest_feed", defaults: { format: "rss" }
get "/feed/:username", to: "articles#feed", as: "user_feed", defaults: { format: "rss" }
get "/rss", to: "articles#feed", defaults: { format: "rss" }
get "/tag/:tag", to: "stories/tagged_articles#index"
get "/t/:tag", to: "stories/tagged_articles#index", as: :tag
get "/t/:tag/top/:timeframe", to: "stories/tagged_articles#index"
get "/t/:tag/page/:page", to: "stories/tagged_articles#index"
get "/t/:tag/:timeframe", to: "stories/tagged_articles#index",
constraints: { timeframe: /latest/ }
get "/t/:tag/edit", to: "tags#edit", as: :edit_tag
get "/t/:tag/admin", to: "tags#admin"
patch "/tag/:id", to: "tags#update"
get "/badge/:slug", to: "badges#show", as: :badge
get "/top/:timeframe", to: "stories#index"
get "/:timeframe", to: "stories#index", constraints: { timeframe: /latest/ }
get "/:username/series", to: "collections#index", as: "user_series"
get "/:username/series/:id", to: "collections#show"
# Legacy comment format (might still be floating around app, and external links)
get "/:username/:slug/comments", to: "comments#index"
get "/:username/:slug/comments/:id_code", to: "comments#index"
get "/:username/:slug/comments/:id_code/edit", to: "comments#edit"
get "/:username/:slug/comments/:id_code/delete_confirm", to: "comments#delete_confirm"
# Proper link format
get "/:username/comment/:id_code", to: "comments#index"
get "/:username/comment/:id_code/edit", to: "comments#edit"
get "/:username/comment/:id_code/delete_confirm", to: "comments#delete_confirm"
get "/:username/comment/:id_code/mod", to: "moderations#comment"
get "/:username/comment/:id_code/settings", to: "comments#settings"
get "/:username/:slug/:view", to: "stories#show",
constraints: { view: /moderate/ }
get "/:username/:slug/mod", to: "moderations#article"
get "/:username/:slug/actions_panel", to: "moderations#actions_panel"
get "/:username/:slug/manage", to: "articles#manage", as: :article_manage
get "/:username/:slug/edit", to: "articles#edit"
get "/:username/:slug/delete_confirm", to: "articles#delete_confirm"
get "/:username/:slug/discussion_lock_confirm", to: "articles#discussion_lock_confirm"
get "/:username/:slug/discussion_unlock_confirm", to: "articles#discussion_unlock_confirm"
get "/:username/:slug/stats", to: "articles#stats"
get "/:username/:view", to: "stories#index",
constraints: { view: /comments|moderate|admin/ }
get "/:username/:slug", to: "stories#show"
get "/:sitemap", to: "sitemaps#show",
constraints: { format: /xml/, sitemap: /sitemap-.+/ }
get "/:username", to: "stories#index", as: "user_profile"
root "stories#index"
end
end
# rubocop:enable Metrics/BlockLength