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

203 lines
5.9 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', authorized_applications: 'oauth/authorized_applications'
  11. end
  12. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  13. get '.well-known/webfinger', to: 'well_known/webfinger#show', 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. resources :followers, only: [:index], controller: :follower_accounts
  30. resources :following, only: [:index], controller: :following_accounts
  31. resource :follow, only: [:create], controller: :account_follow
  32. resource :unfollow, only: [:create], controller: :account_unfollow
  33. end
  34. get '/@:username', to: 'accounts#show', as: :short_account
  35. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  36. namespace :settings do
  37. resource :profile, only: [:show, :update]
  38. resource :preferences, only: [:show, :update]
  39. resource :import, only: [:show, :create]
  40. resource :export, only: [:show]
  41. namespace :exports, constraints: { format: :csv } do
  42. resources :follows, only: :index, controller: :following_accounts
  43. resources :blocks, only: :index, controller: :blocked_accounts
  44. resources :mutes, only: :index, controller: :muted_accounts
  45. end
  46. resource :two_factor_authentication, only: [:show, :create, :destroy]
  47. namespace :two_factor_authentication do
  48. resources :recovery_codes, only: [:create]
  49. resource :confirmation, only: [:new, :create]
  50. end
  51. resource :follower_domains, only: [:show, :update]
  52. end
  53. resources :media, only: [:show]
  54. resources :tags, only: [:show]
  55. # Remote follow
  56. resource :authorize_follow, only: [:show, :create]
  57. namespace :admin do
  58. resources :pubsubhubbub, only: [:index]
  59. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  60. resources :settings, only: [:index, :update]
  61. resources :instances, only: [:index]
  62. resources :reports, only: [:index, :show, :update] do
  63. resources :reported_statuses, only: :destroy
  64. end
  65. resources :accounts, only: [:index, :show] do
  66. resource :reset, only: [:create]
  67. resource :silence, only: [:create, :destroy]
  68. resource :suspension, only: [:create, :destroy]
  69. resource :confirmation, only: [:create]
  70. end
  71. end
  72. get '/admin', to: redirect('/admin/settings', status: 302)
  73. namespace :api do
  74. # PubSubHubbub outgoing subscriptions
  75. resources :subscriptions, only: [:show]
  76. post '/subscriptions/:id', to: 'subscriptions#update'
  77. # PubSubHubbub incoming subscriptions
  78. post '/push', to: 'push#update', as: :push
  79. # Salmon
  80. post '/salmon/:id', to: 'salmon#update', as: :salmon
  81. # OEmbed
  82. get '/oembed', to: 'oembed#show', as: :oembed
  83. # ActivityPub
  84. namespace :activitypub do
  85. get '/users/:id/outbox', to: 'outbox#show', as: :outbox
  86. get '/statuses/:id', to: 'activities#show_status', as: :status
  87. resources :notes, only: [:show]
  88. end
  89. # JSON / REST API
  90. namespace :v1 do
  91. resources :statuses, only: [:create, :show, :destroy] do
  92. member do
  93. get :context
  94. get :card
  95. get :reblogged_by
  96. get :favourited_by
  97. post :reblog
  98. post :unreblog
  99. post :favourite
  100. post :unfavourite
  101. end
  102. end
  103. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  104. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  105. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  106. get '/search', to: 'search#index', as: :search
  107. resources :follows, only: [:create]
  108. resources :media, only: [:create]
  109. resources :apps, only: [:create]
  110. resources :blocks, only: [:index]
  111. resources :mutes, only: [:index]
  112. resources :favourites, only: [:index]
  113. resources :reports, only: [:index, :create]
  114. resource :instance, only: [:show]
  115. resources :follow_requests, only: [:index] do
  116. member do
  117. post :authorize
  118. post :reject
  119. end
  120. end
  121. resources :notifications, only: [:index, :show] do
  122. collection do
  123. post :clear
  124. post :dismiss
  125. end
  126. end
  127. resources :accounts, only: [:show] do
  128. collection do
  129. get :relationships
  130. get :verify_credentials
  131. patch :update_credentials
  132. get :search
  133. end
  134. member do
  135. get :statuses
  136. get :followers
  137. get :following
  138. post :follow
  139. post :unfollow
  140. post :block
  141. post :unblock
  142. post :mute
  143. post :unmute
  144. end
  145. end
  146. end
  147. namespace :web do
  148. resource :settings, only: [:update]
  149. end
  150. end
  151. get '/web/(*any)', to: 'home#index', as: :web
  152. get '/about', to: 'about#show'
  153. get '/about/more', to: 'about#more'
  154. get '/terms', to: 'about#terms'
  155. root 'home#index'
  156. match '*unmatched_route',
  157. via: :all,
  158. to: 'application#raise_not_found',
  159. format: false
  160. end