闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

199 lines
5.0 KiB

8 years ago
7 years ago
8 years ago
8 years ago
  1. # frozen_string_literal: true
  2. require 'sidekiq/web'
  3. Rails.application.routes.draw do
  4. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  5. authenticate :user, lambda { |u| u.admin? } do
  6. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  7. mount PgHero::Engine, at: 'pghero', as: :pghero
  8. end
  9. use_doorkeeper do
  10. controllers authorizations: 'oauth/authorizations'
  11. end
  12. get '.well-known/host-meta', to: 'xrd#host_meta', as: :host_meta
  13. get '.well-known/webfinger', to: 'xrd#webfinger', as: :webfinger
  14. devise_for :users, path: 'auth', controllers: {
  15. sessions: 'auth/sessions',
  16. registrations: 'auth/registrations',
  17. passwords: 'auth/passwords',
  18. confirmations: 'auth/confirmations',
  19. }
  20. get '/users/:username', to: redirect('/@%{username}'), constraints: { format: :html }
  21. resources :accounts, path: 'users', only: [:show], param: :username do
  22. resources :stream_entries, path: 'updates', only: [:show] do
  23. member do
  24. get :embed
  25. end
  26. end
  27. get :remote_follow, to: 'remote_follow#new'
  28. post :remote_follow, to: 'remote_follow#create'
  29. member do
  30. get :followers
  31. get :following
  32. post :follow
  33. post :unfollow
  34. end
  35. end
  36. get '/@:username', to: 'accounts#show', as: :short_account
  37. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  38. namespace :settings do
  39. resource :profile, only: [:show, :update]
  40. resource :preferences, only: [:show, :update]
  41. resource :import, only: [:show, :create]
  42. resource :export, only: [:show] do
  43. collection do
  44. get :follows, to: 'exports#download_following_list'
  45. get :blocks, to: 'exports#download_blocking_list'
  46. end
  47. end
  48. resource :two_factor_auth, only: [:show] do
  49. member do
  50. post :enable
  51. post :disable
  52. end
  53. end
  54. end
  55. resources :media, only: [:show]
  56. resources :tags, only: [:show]
  57. # Remote follow
  58. get :authorize_follow, to: 'authorize_follow#new'
  59. post :authorize_follow, to: 'authorize_follow#create'
  60. namespace :admin do
  61. resources :pubsubhubbub, only: [:index]
  62. resources :domain_blocks, only: [:index, :new, :create]
  63. resources :settings, only: [:index, :update]
  64. resources :reports, only: [:index, :show] do
  65. member do
  66. post :resolve
  67. post :silence
  68. post :suspend
  69. post :remove
  70. end
  71. end
  72. resources :accounts, only: [:index, :show] do
  73. member do
  74. post :silence
  75. post :unsilence
  76. post :suspend
  77. post :unsuspend
  78. end
  79. end
  80. end
  81. get '/admin', to: redirect('/admin/settings', status: 302)
  82. namespace :api do
  83. # PubSubHubbub outgoing subscriptions
  84. resources :subscriptions, only: [:show]
  85. post '/subscriptions/:id', to: 'subscriptions#update'
  86. # PubSubHubbub incoming subscriptions
  87. post '/push', to: 'push#update', as: :push
  88. # Salmon
  89. post '/salmon/:id', to: 'salmon#update', as: :salmon
  90. # OEmbed
  91. get '/oembed', to: 'oembed#show', as: :oembed
  92. # JSON / REST API
  93. namespace :v1 do
  94. resources :statuses, only: [:create, :show, :destroy] do
  95. member do
  96. get :context
  97. get :card
  98. get :reblogged_by
  99. get :favourited_by
  100. post :reblog
  101. post :unreblog
  102. post :favourite
  103. post :unfavourite
  104. end
  105. end
  106. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  107. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  108. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  109. get '/search', to: 'search#index', as: :search
  110. resources :follows, only: [:create]
  111. resources :media, only: [:create]
  112. resources :apps, only: [:create]
  113. resources :blocks, only: [:index]
  114. resources :mutes, only: [:index]
  115. resources :favourites, only: [:index]
  116. resources :reports, only: [:index, :create]
  117. resource :instance, only: [:show]
  118. resources :follow_requests, only: [:index] do
  119. member do
  120. post :authorize
  121. post :reject
  122. end
  123. end
  124. resources :notifications, only: [:index, :show] do
  125. collection do
  126. post :clear
  127. end
  128. end
  129. resources :accounts, only: [:show] do
  130. collection do
  131. get :relationships
  132. get :verify_credentials
  133. get :search
  134. end
  135. member do
  136. get :statuses
  137. get :followers
  138. get :following
  139. post :follow
  140. post :unfollow
  141. post :block
  142. post :unblock
  143. post :mute
  144. post :unmute
  145. end
  146. end
  147. end
  148. namespace :web do
  149. resource :settings, only: [:update]
  150. end
  151. end
  152. get '/web/(*any)', to: 'home#index', as: :web
  153. get '/about', to: 'about#index'
  154. get '/about/more', to: 'about#more'
  155. get '/terms', to: 'about#terms'
  156. root 'home#index'
  157. match '*unmatched_route', via: :all, to: 'application#raise_not_found'
  158. end