2013-02-06 03:16:51 +08:00
|
|
|
require 'sidekiq/web'
|
|
|
|
|
|
|
|
require_dependency 'admin_constraint'
|
2013-05-02 15:22:27 +08:00
|
|
|
require_dependency 'staff_constraint'
|
2013-03-28 21:01:13 +08:00
|
|
|
require_dependency 'homepage_constraint'
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
# This used to be User#username_format, but that causes a preload of the User object
|
2013-02-15 03:11:13 +08:00
|
|
|
# and makes Guard not work properly.
|
2013-03-26 09:08:23 +08:00
|
|
|
USERNAME_ROUTE_FORMAT = /[A-Za-z0-9\_]+/ unless defined? USERNAME_ROUTE_FORMAT
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
Discourse::Application.routes.draw do
|
|
|
|
|
2013-03-23 23:02:59 +08:00
|
|
|
match "/404", to: "exceptions#not_found"
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
mount Sidekiq::Web => '/sidekiq', constraints: AdminConstraint.new
|
|
|
|
|
2013-02-15 03:11:13 +08:00
|
|
|
resources :forums do
|
|
|
|
collection do
|
2013-02-06 03:16:51 +08:00
|
|
|
get 'request_access'
|
|
|
|
post 'request_access_submit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
get 'srv/status' => 'forums#status'
|
|
|
|
|
2013-05-02 15:22:27 +08:00
|
|
|
namespace :admin, constraints: StaffConstraint.new do
|
2013-02-06 03:16:51 +08:00
|
|
|
get '' => 'admin#index'
|
|
|
|
|
2013-05-02 13:15:17 +08:00
|
|
|
resources :site_settings, constraints: AdminConstraint.new
|
|
|
|
|
2013-02-28 11:39:42 +08:00
|
|
|
get 'reports/:type' => 'reports#show'
|
|
|
|
|
2013-05-08 13:20:38 +08:00
|
|
|
resources :groups, constraints: AdminConstraint.new do
|
|
|
|
collection do
|
|
|
|
post 'refresh_automatic_groups' => 'groups#refresh_automatic_groups'
|
|
|
|
end
|
|
|
|
get 'users'
|
|
|
|
end
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
resources :users, id: USERNAME_ROUTE_FORMAT do
|
|
|
|
collection do
|
|
|
|
get 'list/:query' => 'users#index'
|
|
|
|
put 'approve-bulk' => 'users#approve_bulk'
|
|
|
|
end
|
2013-02-24 22:01:58 +08:00
|
|
|
put 'ban'
|
|
|
|
put 'delete_all_posts'
|
|
|
|
put 'unban'
|
2013-05-02 13:15:17 +08:00
|
|
|
put 'revoke_admin', constraints: AdminConstraint.new
|
|
|
|
put 'grant_admin', constraints: AdminConstraint.new
|
|
|
|
put 'revoke_moderation', constraints: AdminConstraint.new
|
|
|
|
put 'grant_moderation', constraints: AdminConstraint.new
|
2013-02-24 22:01:58 +08:00
|
|
|
put 'approve'
|
2013-05-02 13:15:17 +08:00
|
|
|
post 'refresh_browsers', constraints: AdminConstraint.new
|
2013-05-08 09:58:34 +08:00
|
|
|
put 'activate'
|
|
|
|
put 'deactivate'
|
2013-05-31 23:41:40 +08:00
|
|
|
put 'block'
|
|
|
|
put 'unblock'
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
2013-05-02 13:15:17 +08:00
|
|
|
resources :impersonate, constraints: AdminConstraint.new
|
2013-06-04 04:12:24 +08:00
|
|
|
|
|
|
|
resources :email do
|
2013-02-06 03:16:51 +08:00
|
|
|
collection do
|
2013-02-24 22:01:58 +08:00
|
|
|
post 'test'
|
2013-06-04 04:12:24 +08:00
|
|
|
get 'logs'
|
|
|
|
get 'preview-digest' => 'email#preview_digest'
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
end
|
2013-06-04 04:12:24 +08:00
|
|
|
|
2013-05-02 13:15:17 +08:00
|
|
|
get 'customize' => 'site_customizations#index', constraints: AdminConstraint.new
|
2013-02-06 03:16:51 +08:00
|
|
|
get 'flags' => 'flags#index'
|
|
|
|
get 'flags/:filter' => 'flags#index'
|
|
|
|
post 'flags/clear/:id' => 'flags#clear'
|
2013-05-02 13:15:17 +08:00
|
|
|
resources :site_customizations, constraints: AdminConstraint.new
|
|
|
|
resources :site_contents, constraints: AdminConstraint.new
|
|
|
|
resources :site_content_types, constraints: AdminConstraint.new
|
|
|
|
resources :export, constraints: AdminConstraint.new
|
2013-02-06 03:16:51 +08:00
|
|
|
get 'version_check' => 'versions#show'
|
2013-03-30 03:48:26 +08:00
|
|
|
resources :dashboard, only: [:index] do
|
|
|
|
collection do
|
|
|
|
get 'problems'
|
|
|
|
end
|
|
|
|
end
|
2013-05-02 13:15:17 +08:00
|
|
|
resources :api, only: [:index], constraints: AdminConstraint.new do
|
2013-03-26 09:04:28 +08:00
|
|
|
collection do
|
|
|
|
post 'generate_key'
|
|
|
|
end
|
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
get 'email_preferences' => 'email#preferences_redirect'
|
|
|
|
get 'email/unsubscribe/:key' => 'email#unsubscribe', as: 'email_unsubscribe'
|
|
|
|
post 'email/resubscribe/:key' => 'email#resubscribe', as: 'email_resubscribe'
|
|
|
|
|
|
|
|
|
2013-03-23 23:02:59 +08:00
|
|
|
resources :session, id: USERNAME_ROUTE_FORMAT, only: [:create, :destroy] do
|
2013-02-15 03:11:13 +08:00
|
|
|
collection do
|
2013-02-06 03:16:51 +08:00
|
|
|
post 'forgot_password'
|
|
|
|
end
|
2013-02-15 03:11:13 +08:00
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2013-03-23 23:02:59 +08:00
|
|
|
resources :users, except: [:show, :update] do
|
2013-02-15 03:11:13 +08:00
|
|
|
collection do
|
2013-02-06 03:16:51 +08:00
|
|
|
get 'check_username'
|
|
|
|
get 'is_local_username'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
resources :static
|
2013-03-13 22:22:56 +08:00
|
|
|
post 'login' => 'static#enter'
|
2013-06-05 06:39:35 +08:00
|
|
|
get 'login' => 'static#show', id: 'login'
|
2013-02-15 03:11:13 +08:00
|
|
|
get 'faq' => 'static#show', id: 'faq'
|
2013-02-06 03:16:51 +08:00
|
|
|
get 'tos' => 'static#show', id: 'tos'
|
|
|
|
get 'privacy' => 'static#show', id: 'privacy'
|
2013-02-15 03:11:13 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
get 'users/search/users' => 'users#search_users'
|
|
|
|
get 'users/password-reset/:token' => 'users#password_reset'
|
|
|
|
put 'users/password-reset/:token' => 'users#password_reset'
|
|
|
|
get 'users/activate-account/:token' => 'users#activate_account'
|
|
|
|
get 'users/authorize-email/:token' => 'users#authorize_email'
|
2013-02-07 08:25:21 +08:00
|
|
|
get 'users/hp' => 'users#get_honeypot_value'
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
get 'user_preferences' => 'users#user_preferences_redirect'
|
2013-03-23 23:02:59 +08:00
|
|
|
get 'users/:username/private-messages' => 'user_actions#private_messages', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
get 'users/:username' => 'users#show', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
put 'users/:username' => 'users#update', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
get 'users/:username/preferences' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}, as: :email_preferences
|
|
|
|
get 'users/:username/preferences/email' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
put 'users/:username/preferences/email' => 'users#change_email', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
get 'users/:username/preferences/username' => 'users#preferences', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
put 'users/:username/preferences/username' => 'users#username', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
get 'users/:username/avatar(/:size)' => 'users#avatar', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
get 'users/:username/invited' => 'users#invited', constraints: {username: USERNAME_ROUTE_FORMAT}
|
|
|
|
get 'users/:username/send_activation_email' => 'users#send_activation_email', constraints: {username: USERNAME_ROUTE_FORMAT}
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
resources :uploads
|
|
|
|
|
|
|
|
|
|
|
|
get 'posts/by_number/:topic_id/:post_number' => 'posts#by_number'
|
|
|
|
resources :posts do
|
|
|
|
get 'versions'
|
|
|
|
put 'bookmark'
|
|
|
|
get 'replies'
|
2013-02-08 04:12:55 +08:00
|
|
|
put 'recover'
|
2013-02-06 03:16:51 +08:00
|
|
|
collection do
|
|
|
|
delete 'destroy_many'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-04-24 16:05:35 +08:00
|
|
|
get 'p/:post_id/:user_id' => 'posts#short_link'
|
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
resources :notifications
|
|
|
|
resources :categories
|
2013-02-12 14:51:44 +08:00
|
|
|
|
2013-02-12 21:47:22 +08:00
|
|
|
match "/auth/:provider/callback", to: "users/omniauth_callbacks#complete"
|
2013-02-15 03:11:13 +08:00
|
|
|
match "/auth/failure", to: "users/omniauth_callbacks#failure"
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
resources :clicks do
|
|
|
|
collection do
|
2013-02-24 22:01:58 +08:00
|
|
|
get 'track'
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
get 'excerpt' => 'excerpt#show'
|
|
|
|
|
|
|
|
resources :post_actions do
|
|
|
|
collection do
|
2013-02-24 22:01:58 +08:00
|
|
|
get 'users'
|
|
|
|
post 'clear_flags'
|
2013-02-06 03:16:51 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
resources :user_actions
|
2013-02-15 01:10:53 +08:00
|
|
|
resources :education
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2013-02-28 11:36:12 +08:00
|
|
|
get 'category/:category.rss' => 'list#category_feed', format: :rss, as: 'category_feed'
|
2013-02-06 03:16:51 +08:00
|
|
|
get 'category/:category' => 'list#category'
|
2013-02-28 11:36:12 +08:00
|
|
|
get 'category/:category' => 'list#category', as: 'category'
|
|
|
|
get 'category/:category/more' => 'list#category', as: 'category'
|
|
|
|
get 'categories' => 'categories#index'
|
2013-03-28 04:17:49 +08:00
|
|
|
|
|
|
|
# We've renamed popular to latest. If people access it we want a permanent redirect.
|
|
|
|
get 'popular' => 'list#popular_redirect'
|
|
|
|
get 'popular/more' => 'list#popular_redirect'
|
|
|
|
|
2013-03-28 21:01:13 +08:00
|
|
|
[:latest, :hot, :favorited, :read, :posted, :unread, :new].each do |filter|
|
|
|
|
get "#{filter}" => "list##{filter}"
|
|
|
|
get "#{filter}/more" => "list##{filter}"
|
|
|
|
end
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
get 'search' => 'search#query'
|
|
|
|
|
|
|
|
# Topics resource
|
2013-05-31 23:55:51 +08:00
|
|
|
get 't/:id' => 'topics#show'
|
2013-02-06 03:16:51 +08:00
|
|
|
delete 't/:id' => 'topics#destroy'
|
|
|
|
put 't/:id' => 'topics#update'
|
2013-02-15 03:11:13 +08:00
|
|
|
post 't' => 'topics#create'
|
2013-03-15 02:45:29 +08:00
|
|
|
post 'topics/timings'
|
|
|
|
get 'topics/similar_to'
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
# Legacy route for old avatars
|
2013-03-23 23:02:59 +08:00
|
|
|
get 'threads/:topic_id/:post_number/avatar' => 'topics#avatar', constraints: {topic_id: /\d+/, post_number: /\d+/}
|
2013-02-06 03:16:51 +08:00
|
|
|
|
2013-02-15 03:11:13 +08:00
|
|
|
# Topic routes
|
2013-03-23 23:02:59 +08:00
|
|
|
get 't/:slug/:topic_id/best_of' => 'topics#show', defaults: {best_of: true}, constraints: {topic_id: /\d+/, post_number: /\d+/}
|
|
|
|
get 't/:topic_id/best_of' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/}
|
|
|
|
put 't/:slug/:topic_id' => 'topics#update', constraints: {topic_id: /\d+/}
|
|
|
|
put 't/:slug/:topic_id/star' => 'topics#star', constraints: {topic_id: /\d+/}
|
|
|
|
put 't/:topic_id/star' => 'topics#star', constraints: {topic_id: /\d+/}
|
|
|
|
put 't/:slug/:topic_id/status' => 'topics#status', constraints: {topic_id: /\d+/}
|
|
|
|
put 't/:topic_id/status' => 'topics#status', constraints: {topic_id: /\d+/}
|
|
|
|
put 't/:topic_id/clear-pin' => 'topics#clear_pin', constraints: {topic_id: /\d+/}
|
|
|
|
put 't/:topic_id/mute' => 'topics#mute', constraints: {topic_id: /\d+/}
|
|
|
|
put 't/:topic_id/unmute' => 'topics#unmute', constraints: {topic_id: /\d+/}
|
2013-05-08 02:25:41 +08:00
|
|
|
put 't/:topic_id/autoclose' => 'topics#autoclose', constraints: {topic_id: /\d+/}
|
2013-03-23 23:02:59 +08:00
|
|
|
|
|
|
|
get 't/:topic_id/:post_number' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/}
|
|
|
|
get 't/:slug/:topic_id.rss' => 'topics#feed', format: :rss, constraints: {topic_id: /\d+/}
|
|
|
|
get 't/:slug/:topic_id' => 'topics#show', constraints: {topic_id: /\d+/}
|
|
|
|
get 't/:slug/:topic_id/:post_number' => 'topics#show', constraints: {topic_id: /\d+/, post_number: /\d+/}
|
|
|
|
post 't/:topic_id/timings' => 'topics#timings', constraints: {topic_id: /\d+/}
|
|
|
|
post 't/:topic_id/invite' => 'topics#invite', constraints: {topic_id: /\d+/}
|
|
|
|
post 't/:topic_id/move-posts' => 'topics#move_posts', constraints: {topic_id: /\d+/}
|
2013-05-17 03:55:14 +08:00
|
|
|
post 't/:topic_id/merge-topic' => 'topics#merge_topic', constraints: {topic_id: /\d+/}
|
2013-03-23 23:02:59 +08:00
|
|
|
delete 't/:topic_id/timings' => 'topics#destroy_timings', constraints: {topic_id: /\d+/}
|
|
|
|
|
|
|
|
post 't/:topic_id/notifications' => 'topics#set_notifications' , constraints: {topic_id: /\d+/}
|
2013-02-15 03:11:13 +08:00
|
|
|
|
2013-05-08 08:26:55 +08:00
|
|
|
get 'raw/:topic_id(/:post_number)' => 'posts#markdown'
|
2013-04-30 14:29:57 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
resources :invites
|
|
|
|
delete 'invites' => 'invites#destroy'
|
2013-02-15 03:11:13 +08:00
|
|
|
|
2013-02-06 03:16:51 +08:00
|
|
|
get 'request_access' => 'request_access#new'
|
|
|
|
post 'request_access' => 'request_access#create'
|
|
|
|
|
|
|
|
get 'onebox' => 'onebox#show'
|
|
|
|
|
|
|
|
get 'error' => 'forums#error'
|
|
|
|
|
|
|
|
get 'message-bus/poll' => 'message_bus#poll'
|
|
|
|
|
|
|
|
get 'draft' => 'draft#show'
|
|
|
|
post 'draft' => 'draft#update'
|
|
|
|
delete 'draft' => 'draft#destroy'
|
|
|
|
|
2013-02-11 08:02:57 +08:00
|
|
|
get 'robots.txt' => 'robots_txt#index'
|
|
|
|
|
2013-03-28 21:01:13 +08:00
|
|
|
[:latest, :hot, :unread, :new, :favorited, :read, :posted].each do |filter|
|
|
|
|
root to: "list##{filter}", constraints: HomePageConstraint.new("#{filter}")
|
|
|
|
end
|
|
|
|
# special case for categories
|
|
|
|
root to: "categories#index", constraints: HomePageConstraint.new("categories")
|
2013-02-06 03:16:51 +08:00
|
|
|
|
|
|
|
end
|