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

170 lines
4.3 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. mount ActionCable.server, at: 'cable'
  6. authenticate :user, lambda { |u| u.admin? } do
  7. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  8. mount PgHero::Engine, at: 'pghero', as: :pghero
  9. end
  10. use_doorkeeper do
  11. controllers authorizations: 'oauth/authorizations'
  12. end
  13. get '.well-known/host-meta', to: 'xrd#host_meta', as: :host_meta
  14. get '.well-known/webfinger', to: 'xrd#webfinger', as: :webfinger
  15. devise_for :users, path: 'auth', controllers: {
  16. sessions: 'auth/sessions',
  17. registrations: 'auth/registrations',
  18. passwords: 'auth/passwords',
  19. confirmations: 'auth/confirmations',
  20. }
  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. member do
  30. get :followers
  31. get :following
  32. post :follow
  33. post :unfollow
  34. end
  35. end
  36. namespace :settings do
  37. resource :profile, only: [:show, :update]
  38. resource :preferences, only: [:show, :update]
  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 :accounts, only: [:index, :show, :update] do
  56. member do
  57. post :suspend
  58. end
  59. end
  60. end
  61. get '/admin', to: redirect('/admin/settings', status: 302)
  62. namespace :api do
  63. # PubSubHubbub outgoing subscriptions
  64. resources :subscriptions, only: [:show]
  65. post '/subscriptions/:id', to: 'subscriptions#update'
  66. # PubSubHubbub incoming subscriptions
  67. post '/push', to: 'push#update', as: :push
  68. # Salmon
  69. post '/salmon/:id', to: 'salmon#update', as: :salmon
  70. # OEmbed
  71. get '/oembed', to: 'oembed#show', as: :oembed
  72. # JSON / REST API
  73. namespace :v1 do
  74. resources :statuses, only: [:create, :show, :destroy] do
  75. member do
  76. get :context
  77. get :card
  78. get :reblogged_by
  79. get :favourited_by
  80. post :reblog
  81. post :unreblog
  82. post :favourite
  83. post :unfavourite
  84. end
  85. end
  86. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  87. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  88. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  89. resources :follows, only: [:create]
  90. resources :media, only: [:create]
  91. resources :apps, only: [:create]
  92. resources :blocks, only: [:index]
  93. resources :favourites, only: [:index]
  94. post '/devices/register', to: 'devices#register', as: :register_device
  95. post '/devices/unregister', to: 'devices#unregister', as: :unregister_device
  96. resources :follow_requests, only: [:index] do
  97. member do
  98. post :authorize
  99. post :reject
  100. end
  101. end
  102. resources :notifications, only: [:index, :show] do
  103. collection do
  104. post :clear
  105. end
  106. end
  107. resources :accounts, only: [:show] do
  108. collection do
  109. get :relationships
  110. get :verify_credentials
  111. get :search
  112. end
  113. member do
  114. get :statuses
  115. get :followers
  116. get :following
  117. post :follow
  118. post :unfollow
  119. post :block
  120. post :unblock
  121. end
  122. end
  123. end
  124. namespace :web do
  125. resource :settings, only: [:update]
  126. end
  127. end
  128. get '/web/(*any)', to: 'home#index', as: :web
  129. get '/about', to: 'about#index'
  130. get '/about/more', to: 'about#more'
  131. get '/terms', to: 'about#terms'
  132. root 'home#index'
  133. match '*unmatched_route', via: :all, to: 'application#raise_not_found'
  134. end