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

166 lines
4.1 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 :accounts, only: [:index, :show, :update] do
  55. member do
  56. post :suspend
  57. end
  58. end
  59. end
  60. get '/admin', to: redirect('/admin/settings', status: 302)
  61. namespace :api do
  62. # PubSubHubbub outgoing subscriptions
  63. resources :subscriptions, only: [:show]
  64. post '/subscriptions/:id', to: 'subscriptions#update'
  65. # PubSubHubbub incoming subscriptions
  66. post '/push', to: 'push#update', as: :push
  67. # Salmon
  68. post '/salmon/:id', to: 'salmon#update', as: :salmon
  69. # OEmbed
  70. get '/oembed', to: 'oembed#show', as: :oembed
  71. # JSON / REST API
  72. namespace :v1 do
  73. resources :statuses, only: [:create, :show, :destroy] do
  74. member do
  75. get :context
  76. get :card
  77. get :reblogged_by
  78. get :favourited_by
  79. post :reblog
  80. post :unreblog
  81. post :favourite
  82. post :unfavourite
  83. end
  84. end
  85. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  86. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  87. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  88. resources :follows, only: [:create]
  89. resources :media, only: [:create]
  90. resources :apps, only: [:create]
  91. resources :blocks, only: [:index]
  92. resources :favourites, only: [:index]
  93. resources :follow_requests, only: [:index] do
  94. member do
  95. post :authorize
  96. post :reject
  97. end
  98. end
  99. resources :notifications, only: [:index, :show] do
  100. collection do
  101. post :clear
  102. end
  103. end
  104. resources :accounts, only: [:show] do
  105. collection do
  106. get :relationships
  107. get :verify_credentials
  108. get :search
  109. end
  110. member do
  111. get :statuses
  112. get :followers
  113. get :following
  114. post :follow
  115. post :unfollow
  116. post :block
  117. post :unblock
  118. end
  119. end
  120. end
  121. namespace :web do
  122. resource :settings, only: [:update]
  123. end
  124. end
  125. get '/web/(*any)', to: 'home#index', as: :web
  126. get '/about', to: 'about#index'
  127. get '/about/more', to: 'about#more'
  128. get '/terms', to: 'about#terms'
  129. root 'home#index'
  130. match '*unmatched_route', via: :all, to: 'application#raise_not_found'
  131. end