2014-12-12 18:35:14 +01:00
|
|
|
require 'sidekiq/web'
|
2014-08-01 11:23:47 +02:00
|
|
|
Rails.application.routes.draw do
|
2017-03-31 22:38:23 +02:00
|
|
|
start = Time.now
|
2014-12-05 07:02:23 +01:00
|
|
|
|
2014-12-26 13:46:47 +01:00
|
|
|
# Sidekiq
|
2014-12-12 18:35:14 +01:00
|
|
|
constraints ->(req) { req.env["warden"].authenticate?(scope: :user) &&
|
2020-04-19 22:35:58 +02:00
|
|
|
req.env["warden"].user.has_role?(:administrator) } do
|
|
|
|
# Admin panel
|
|
|
|
mount RailsAdmin::Engine => "/justask_admin", as: "rails_admin"
|
|
|
|
|
2014-12-12 18:35:14 +01:00
|
|
|
mount Sidekiq::Web, at: "/sidekiq"
|
2020-04-19 22:35:58 +02:00
|
|
|
mount PgHero::Engine, at: "/pghero", as: "pghero"
|
2020-04-19 23:58:47 +02:00
|
|
|
|
|
|
|
match "/admin/announcements", to: "announcement#index", via: :get, as: :announcement_index
|
|
|
|
match "/admin/announcements", to: "announcement#create", via: :post, as: :announcement_create
|
|
|
|
match "/admin/announcements/new", to: "announcement#new", via: :get, as: :announcement_new
|
|
|
|
match "/admin/announcements/:id/edit", to: "announcement#edit", via: :get, as: :announcement_edit
|
|
|
|
match "/admin/announcements/:id", to: "announcement#update", via: :patch, as: :announcement_update
|
|
|
|
match "/admin/announcements/:id", to: "announcement#destroy", via: :delete, as: :announcement_destroy
|
2014-12-12 18:35:14 +01:00
|
|
|
end
|
|
|
|
|
2014-12-26 13:46:47 +01:00
|
|
|
# Moderation panel
|
2020-04-19 22:35:58 +02:00
|
|
|
constraints ->(req) { req.env["warden"].authenticate?(scope: :user) &&
|
|
|
|
req.env["warden"].user.mod? } do
|
2015-07-23 19:38:42 +02:00
|
|
|
match '/moderation/priority(/:user_id)', to: 'moderation#priority', via: :get, as: :moderation_priority
|
|
|
|
match '/moderation/ip/:user_id', to: 'moderation#ip', via: :get, as: :moderation_ip
|
2014-12-29 01:25:48 +01:00
|
|
|
match '/moderation(/:type)', to: 'moderation#index', via: :get, as: :moderation, defaults: {type: 'all'}
|
2014-12-28 23:26:16 +01:00
|
|
|
namespace :ajax do
|
2014-12-29 00:21:06 +01:00
|
|
|
match '/mod/destroy_report', to: 'moderation#destroy_report', via: :post, as: :mod_destroy_report
|
2014-12-29 00:50:14 +01:00
|
|
|
match '/mod/create_comment', to: 'moderation#create_comment', via: :post, as: :mod_create_comment
|
|
|
|
match '/mod/destroy_comment', to: 'moderation#destroy_comment', via: :post, as: :mod_destroy_comment
|
|
|
|
match '/mod/create_vote', to: 'moderation#vote', via: :post, as: :mod_create_vote
|
2014-12-28 23:26:16 +01:00
|
|
|
match '/mod/destroy_vote', to: 'moderation#destroy_vote', via: :post, as: :mod_destroy_vote
|
2015-02-03 17:48:30 +01:00
|
|
|
match '/mod/privilege', to: 'moderation#privilege', via: :post, as: :mod_privilege
|
2015-04-23 02:56:29 +02:00
|
|
|
match '/mod/ban', to: 'moderation#ban', via: :post, as: :mod_ban
|
2014-12-28 23:26:16 +01:00
|
|
|
end
|
2014-12-26 13:46:47 +01:00
|
|
|
end
|
|
|
|
|
2014-08-01 11:47:25 +02:00
|
|
|
root 'static#index'
|
2014-08-01 11:23:47 +02:00
|
|
|
|
2014-08-01 11:47:25 +02:00
|
|
|
match '/about', to: 'static#about', via: 'get'
|
2015-01-07 21:30:52 +01:00
|
|
|
match '/help/faq', to: 'static#faq', via: 'get', as: :help_faq
|
2015-01-16 22:36:39 +01:00
|
|
|
match '/privacy', to: 'static#privacy_policy', via: 'get', as: :privacy_policy
|
2015-01-16 23:16:28 +01:00
|
|
|
match '/terms', to: 'static#terms', via: 'get', as: :terms
|
2014-11-02 17:58:27 +01:00
|
|
|
|
|
|
|
# Devise routes
|
|
|
|
devise_for :users, path: 'user', skip: [:sessions, :registrations]
|
|
|
|
as :user do
|
|
|
|
# :sessions
|
|
|
|
get 'sign_in' => 'devise/sessions#new', as: :new_user_session
|
2020-10-18 10:39:46 +02:00
|
|
|
post 'sign_in' => 'user/sessions#create', as: :user_session
|
|
|
|
get 'otp_auth' => 'user/sessions#two_factor_entry', as: :user_two_factor_entry
|
2014-11-02 17:58:27 +01:00
|
|
|
delete 'sign_out' => 'devise/sessions#destroy', as: :destroy_user_session
|
|
|
|
# :registrations
|
|
|
|
get 'settings/delete_account' => 'devise/registrations#cancel', as: :cancel_user_registration
|
2020-05-22 22:29:22 +02:00
|
|
|
post '/user/create' => 'user/registrations#create', as: :user_registration
|
2014-11-02 17:58:27 +01:00
|
|
|
get '/sign_up' => 'devise/registrations#new', as: :new_user_registration
|
|
|
|
get '/settings/account' => 'devise/registrations#edit', as: :edit_user_registration
|
2014-11-03 13:21:41 +01:00
|
|
|
patch '/settings/account' => 'devise/registrations#update', as: :update_user_registration
|
2014-11-02 17:58:27 +01:00
|
|
|
put '/settings/account' => 'devise/registrations#update'
|
2015-07-15 01:44:35 +02:00
|
|
|
delete '/settings/account' => 'user/registrations#destroy'
|
2014-11-02 17:58:27 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
match '/settings/profile', to: 'user#edit', via: 'get', as: :edit_user_profile
|
2014-11-03 13:21:41 +01:00
|
|
|
match '/settings/profile', to: 'user#update', via: 'patch', as: :update_user_profile
|
2014-12-09 23:21:41 +01:00
|
|
|
|
2015-08-25 10:26:36 +02:00
|
|
|
match '/settings/theme', to: 'user#edit_theme', via: 'get', as: :edit_user_theme
|
|
|
|
match '/settings/theme', to: 'user#update_theme', via: 'patch', as: :update_user_theme
|
2015-08-27 01:56:07 +02:00
|
|
|
match '/settings/theme/delete', to: 'user#delete_theme', via: 'delete', as: :delete_user_theme
|
2015-08-25 10:26:36 +02:00
|
|
|
|
2020-10-18 10:39:46 +02:00
|
|
|
match '/settings/security', to: 'user#edit_security', via: :get, as: :edit_user_security
|
|
|
|
match '/settings/security/2fa', to: 'user#update_2fa', via: :patch, as: :update_user_2fa
|
|
|
|
match '/settings/security/2fa', to: 'user#destroy_2fa', via: :delete, as: :destroy_user_2fa
|
|
|
|
|
2014-12-12 21:43:09 +01:00
|
|
|
# resources :services, only: [:index, :destroy]
|
|
|
|
match '/settings/services', to: 'services#index', via: 'get', as: :services
|
|
|
|
match '/settings/services/:id', to: 'services#destroy', via: 'delete', as: :service
|
|
|
|
controller :services do
|
|
|
|
scope "/auth", as: "auth" do
|
|
|
|
get ':provider/callback' => :create
|
|
|
|
get :failure
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-01-03 21:58:56 +01:00
|
|
|
match '/settings/privacy', to: 'user#edit_privacy', via: :get, as: :edit_user_privacy
|
|
|
|
match '/settings/privacy', to: 'user#update_privacy', via: :patch, as: :update_user_privacy
|
2015-01-02 21:34:56 +01:00
|
|
|
|
2015-06-20 20:38:07 +02:00
|
|
|
match '/settings/data', to: 'user#data', via: :get, as: :user_data
|
2016-01-05 20:54:38 +01:00
|
|
|
match '/settings/export', to: 'user#export', via: :get, as: :user_export
|
|
|
|
match '/settings/export', to: 'user#begin_export', via: :post, as: :begin_user_export
|
2015-06-20 20:38:07 +02:00
|
|
|
|
2014-11-10 13:04:10 +01:00
|
|
|
namespace :ajax do
|
2014-11-10 21:56:30 +01:00
|
|
|
match '/ask', to: 'question#create', via: :post, as: :ask
|
2015-04-26 03:36:25 +02:00
|
|
|
match '/destroy_question', to: 'question#destroy', via: :post, as: :destroy_question
|
2014-12-09 23:21:41 +01:00
|
|
|
match '/generate_question', to: 'inbox#create', via: :post, as: :generate_question
|
2014-11-30 18:05:51 +01:00
|
|
|
match '/delete_inbox', to: 'inbox#remove', via: :post, as: :delete_inbox
|
2014-12-21 13:41:57 +01:00
|
|
|
match '/delete_all_inbox', to: 'inbox#remove_all', via: :post, as: :delete_all_inbox
|
2015-07-17 20:29:19 +02:00
|
|
|
match '/delete_all_inbox/:author', to: 'inbox#remove_all_author', via: :post, as: :delete_all_author
|
2015-01-03 18:40:39 +01:00
|
|
|
match '/answer', to: 'answer#create', via: :post, as: :answer
|
2014-11-26 17:05:46 +01:00
|
|
|
match '/destroy_answer', to: 'answer#destroy', via: :post, as: :destroy_answer
|
2014-11-30 14:45:32 +01:00
|
|
|
match '/create_friend', to: 'friend#create', via: :post, as: :create_friend
|
|
|
|
match '/destroy_friend', to: 'friend#destroy', via: :post, as: :destroy_friend
|
2014-11-30 20:31:22 +01:00
|
|
|
match '/create_smile', to: 'smile#create', via: :post, as: :create_smile
|
|
|
|
match '/destroy_smile', to: 'smile#destroy', via: :post, as: :destroy_smile
|
2015-05-04 03:39:41 +02:00
|
|
|
match '/create_comment_smile', to: 'smile#create_comment', via: :post, as: :create_comment_smile
|
|
|
|
match '/destroy_comment_smile', to: 'smile#destroy_comment', via: :post, as: :destroy_comment_smile
|
2014-12-07 14:29:35 +01:00
|
|
|
match '/create_comment', to: 'comment#create', via: :post, as: :create_comment
|
2014-12-28 21:14:01 +01:00
|
|
|
match '/destroy_comment', to: 'comment#destroy', via: :post, as: :destroy_comment
|
2014-12-28 19:55:50 +01:00
|
|
|
match '/report', to: 'report#create', via: :post, as: :report
|
2020-05-25 18:04:54 +02:00
|
|
|
match '/create_list', to: 'list#create', via: :post, as: :create_list
|
|
|
|
match '/destroy_list', to: 'list#destroy', via: :post, as: :destroy_list
|
|
|
|
match '/list_membership', to: 'list#membership', via: :post, as: :list_membership
|
2015-04-21 03:12:11 +02:00
|
|
|
match '/subscribe', to: 'subscription#subscribe', via: :post, as: :subscribe_answer
|
|
|
|
match '/unsubscribe', to: 'subscription#unsubscribe', via: :post, as: :unsubscribe_answer
|
2014-11-10 13:04:10 +01:00
|
|
|
end
|
2014-11-03 13:21:41 +01:00
|
|
|
|
2020-04-19 13:55:13 +02:00
|
|
|
match '/discover', to: 'discover#index', via: :get, as: :discover
|
2017-03-31 22:21:19 +02:00
|
|
|
match '/public', to: 'public#index', via: :get, as: :public_timeline if APP_CONFIG.dig(:features, :public, :enabled)
|
2020-05-25 18:04:54 +02:00
|
|
|
match '/list/:list_name', to: 'list#index', via: :get, as: :list_timeline
|
2014-12-11 06:39:35 +01:00
|
|
|
|
2015-09-16 22:18:40 +02:00
|
|
|
match '/notifications(/:type)', to: 'notifications#index', via: :get, as: :notifications, defaults: {type: 'new'}
|
2014-12-14 15:17:52 +01:00
|
|
|
|
2014-11-11 07:10:41 +01:00
|
|
|
match '/inbox', to: 'inbox#show', via: 'get'
|
2015-07-17 21:02:53 +02:00
|
|
|
match '/inbox/:author', to: 'inbox#show', via: 'get'
|
2015-04-19 00:17:13 +02:00
|
|
|
|
2014-11-12 20:40:24 +01:00
|
|
|
match '/user/:username(/p/:page)', to: 'user#show', via: 'get', defaults: {page: 1}
|
2015-01-17 16:29:11 +01:00
|
|
|
match '/@:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile_alt, defaults: {page: 1}
|
|
|
|
match '/@:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer_alt
|
|
|
|
match '/@:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question_alt
|
|
|
|
match '/@:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers_alt, defaults: {page: 1}
|
|
|
|
match '/@:username/friends(/p/:page)', to: 'user#friends', via: 'get', as: :show_user_friends_alt, defaults: {page: 1}
|
|
|
|
match '/:username(/p/:page)', to: 'user#show', via: 'get', as: :show_user_profile, defaults: {page: 1}
|
|
|
|
match '/:username/a/:id', to: 'answer#show', via: 'get', as: :show_user_answer
|
|
|
|
match '/:username/q/:id', to: 'question#show', via: 'get', as: :show_user_question
|
|
|
|
match '/:username/followers(/p/:page)', to: 'user#followers', via: 'get', as: :show_user_followers, defaults: {page: 1}
|
|
|
|
match '/:username/friends(/p/:page)', to: 'user#friends', via: 'get', as: :show_user_friends, defaults: {page: 1}
|
2020-05-25 18:04:54 +02:00
|
|
|
match '/:username/lists(/p/:page)', to: 'user#lists', via: 'get', as: :show_user_lists, defaults: {page: 1}
|
2014-12-19 22:34:24 +01:00
|
|
|
match '/:username/questions(/p/:page)', to: 'user#questions', via: 'get', as: :show_user_questions, defaults: {page: 1}
|
2017-03-31 22:38:23 +02:00
|
|
|
|
|
|
|
puts 'processing time of routes.rb: ' + "#{(Time.now - start).round(3).to_s.ljust(5, '0')}s".light_green
|
2014-08-01 11:23:47 +02:00
|
|
|
end
|