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

186 lines
4.6 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. resources :accounts, path: 'users', only: [:show], param: :username do
  21. resources :stream_entries, path: 'updates', only: [:show] do
  22. member do
  23. get :embed
  24. end
  25. end
  26. get :remote_follow, to: 'remote_follow#new'
  27. post :remote_follow, to: 'remote_follow#create'
  28. member do
  29. get :followers
  30. get :following
  31. post :follow
  32. post :unfollow
  33. end
  34. end
  35. namespace :settings do
  36. resource :profile, only: [:show, :update]
  37. resource :preferences, only: [:show, :update]
  38. resource :export, only: [:show]
  39. resource :two_factor_auth, only: [:show] do
  40. member do
  41. post :enable
  42. post :disable
  43. end
  44. end
  45. end
  46. resources :media, only: [:show]
  47. resources :tags, only: [:show]
  48. # Remote follow
  49. get :authorize_follow, to: 'authorize_follow#new'
  50. post :authorize_follow, to: 'authorize_follow#create'
  51. namespace :admin do
  52. resources :pubsubhubbub, only: [:index]
  53. resources :domain_blocks, only: [:index, :create]
  54. resources :settings, only: [:index, :update]
  55. resources :reports, only: [:index, :show] do
  56. member do
  57. post :resolve
  58. post :silence
  59. post :suspend
  60. post :remove
  61. end
  62. end
  63. resources :accounts, only: [:index, :show] do
  64. member do
  65. post :silence
  66. post :unsilence
  67. post :suspend
  68. post :unsuspend
  69. end
  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. resources :follows, only: [:create]
  101. resources :media, only: [:create]
  102. resources :apps, only: [:create]
  103. resources :blocks, only: [:index]
  104. resources :mutes, only: [:index]
  105. resources :favourites, only: [:index]
  106. resources :reports, only: [:index, :create]
  107. resources :follow_requests, only: [:index] do
  108. member do
  109. post :authorize
  110. post :reject
  111. end
  112. end
  113. resources :notifications, only: [:index, :show] do
  114. collection do
  115. post :clear
  116. end
  117. end
  118. resources :accounts, only: [:show] do
  119. collection do
  120. get :relationships
  121. get :verify_credentials
  122. get :search
  123. end
  124. member do
  125. get :statuses
  126. get :followers
  127. get :following
  128. post :follow
  129. post :unfollow
  130. post :block
  131. post :unblock
  132. post :mute
  133. post :unmute
  134. end
  135. end
  136. end
  137. namespace :web do
  138. resource :settings, only: [:update]
  139. end
  140. end
  141. get '/web/(*any)', to: 'home#index', as: :web
  142. get '/about', to: 'about#index'
  143. get '/about/more', to: 'about#more'
  144. get '/terms', to: 'about#terms'
  145. root 'home#index'
  146. get '/:username', to: redirect('/users/%{username}')
  147. get '/:username/:id', to: redirect('/users/%{username}/updates/%{id}')
  148. match '*unmatched_route', via: :all, to: 'application#raise_not_found'
  149. end