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

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