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

180 lines
4.4 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 :two_factor_auth, only: [:show] do
  39. member do
  40. post :enable
  41. post :disable
  42. end
  43. end
  44. end
  45. resources :media, only: [:show]
  46. resources :tags, only: [:show]
  47. # Remote follow
  48. get :authorize_follow, to: 'authorize_follow#new'
  49. post :authorize_follow, to: 'authorize_follow#create'
  50. namespace :admin do
  51. resources :pubsubhubbub, only: [:index]
  52. resources :domain_blocks, only: [:index, :create]
  53. resources :settings, only: [:index, :update]
  54. resources :reports, only: [:index, :show] do
  55. member do
  56. post :resolve
  57. post :silence
  58. post :suspend
  59. post :remove
  60. end
  61. end
  62. resources :accounts, only: [:index, :show] do
  63. member do
  64. post :silence
  65. post :unsilence
  66. post :suspend
  67. post :unsuspend
  68. end
  69. end
  70. end
  71. get '/admin', to: redirect('/admin/settings', status: 302)
  72. namespace :api do
  73. # PubSubHubbub outgoing subscriptions
  74. resources :subscriptions, only: [:show]
  75. post '/subscriptions/:id', to: 'subscriptions#update'
  76. # PubSubHubbub incoming subscriptions
  77. post '/push', to: 'push#update', as: :push
  78. # Salmon
  79. post '/salmon/:id', to: 'salmon#update', as: :salmon
  80. # OEmbed
  81. get '/oembed', to: 'oembed#show', as: :oembed
  82. # JSON / REST API
  83. namespace :v1 do
  84. resources :statuses, only: [:create, :show, :destroy] do
  85. member do
  86. get :context
  87. get :card
  88. get :reblogged_by
  89. get :favourited_by
  90. post :reblog
  91. post :unreblog
  92. post :favourite
  93. post :unfavourite
  94. end
  95. end
  96. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  97. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  98. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  99. resources :follows, only: [:create]
  100. resources :media, only: [:create]
  101. resources :apps, only: [:create]
  102. resources :blocks, only: [:index]
  103. resources :favourites, only: [:index]
  104. resources :reports, only: [:index, :create]
  105. resources :follow_requests, only: [:index] do
  106. member do
  107. post :authorize
  108. post :reject
  109. end
  110. end
  111. resources :notifications, only: [:index, :show] do
  112. collection do
  113. post :clear
  114. end
  115. end
  116. resources :accounts, only: [:show] do
  117. collection do
  118. get :relationships
  119. get :verify_credentials
  120. get :search
  121. end
  122. member do
  123. get :statuses
  124. get 'statuses/media', to: 'accounts#media_statuses', as: :media_statuses
  125. get :followers
  126. get :following
  127. post :follow
  128. post :unfollow
  129. post :block
  130. post :unblock
  131. end
  132. end
  133. end
  134. namespace :web do
  135. resource :settings, only: [:update]
  136. end
  137. end
  138. get '/web/(*any)', to: 'home#index', as: :web
  139. get '/about', to: 'about#index'
  140. get '/about/more', to: 'about#more'
  141. get '/terms', to: 'about#terms'
  142. root 'home#index'
  143. match '*unmatched_route', via: :all, to: 'application#raise_not_found'
  144. end