闭社主体 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.

207 lines
6.0 KiB

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