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

194 lines
5.5 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_auth, only: [:show, :new, :create] do
  47. member do
  48. post :disable
  49. post :recovery_codes
  50. end
  51. end
  52. end
  53. resources :media, only: [:show]
  54. resources :tags, only: [:show]
  55. # Remote follow
  56. get :authorize_follow, to: 'authorize_follow#new'
  57. post :authorize_follow, to: 'authorize_follow#create'
  58. namespace :admin do
  59. resources :pubsubhubbub, only: [:index]
  60. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  61. resources :settings, only: [:index, :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. 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. # JSON / REST API
  84. namespace :v1 do
  85. resources :statuses, only: [:create, :show, :destroy] do
  86. member do
  87. get :context
  88. get :card
  89. get :reblogged_by
  90. get :favourited_by
  91. post :reblog
  92. post :unreblog
  93. post :favourite
  94. post :unfavourite
  95. end
  96. end
  97. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  98. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  99. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  100. get '/search', to: 'search#index', as: :search
  101. resources :follows, only: [:create]
  102. resources :media, only: [:create]
  103. resources :apps, only: [:create]
  104. resources :blocks, only: [:index]
  105. resources :mutes, only: [:index]
  106. resources :favourites, only: [:index]
  107. resources :reports, only: [:index, :create]
  108. resource :instance, only: [:show]
  109. resources :follow_requests, only: [:index] do
  110. member do
  111. post :authorize
  112. post :reject
  113. end
  114. end
  115. resources :notifications, only: [:index, :show] do
  116. collection do
  117. post :clear
  118. end
  119. end
  120. resources :accounts, only: [:show] do
  121. collection do
  122. get :relationships
  123. get :verify_credentials
  124. patch :update_credentials
  125. get :search
  126. end
  127. member do
  128. get :statuses
  129. get :followers
  130. get :following
  131. post :follow
  132. post :unfollow
  133. post :block
  134. post :unblock
  135. post :mute
  136. post :unmute
  137. end
  138. end
  139. end
  140. namespace :web do
  141. resource :settings, only: [:update]
  142. end
  143. end
  144. get '/web/(*any)', to: 'home#index', as: :web
  145. get '/about', to: 'about#show'
  146. get '/about/more', to: 'about#more'
  147. get '/terms', to: 'about#terms'
  148. root 'home#index'
  149. match '*unmatched_route',
  150. via: :all,
  151. to: 'application#raise_not_found',
  152. format: false
  153. end