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.

204 lines
5.9 KiB

8 years ago
7 years ago
7 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', authorized_applications: 'oauth/authorized_applications'
  11. end
  12. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  13. get '.well-known/webfinger', to: 'well_known/webfinger#show', 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. get '/users/:username', to: redirect('/@%{username}'), constraints: { format: :html }
  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. resources :followers, only: [:index], controller: :follower_accounts
  30. resources :following, only: [:index], controller: :following_accounts
  31. resource :follow, only: [:create], controller: :account_follow
  32. resource :unfollow, only: [:create], controller: :account_unfollow
  33. end
  34. get '/@:username', to: 'accounts#show', as: :short_account
  35. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  36. namespace :settings do
  37. resource :profile, only: [:show, :update]
  38. resource :preferences, only: [:show, :update]
  39. resource :import, only: [:show, :create]
  40. resource :export, only: [:show]
  41. namespace :exports, constraints: { format: :csv } do
  42. resources :follows, only: :index, controller: :following_accounts
  43. resources :blocks, only: :index, controller: :blocked_accounts
  44. resources :mutes, only: :index, controller: :muted_accounts
  45. end
  46. resource :two_factor_authentication, only: [:show, :create, :destroy]
  47. namespace :two_factor_authentication do
  48. resources :recovery_codes, only: [:create]
  49. resource :confirmation, only: [:new, :create]
  50. end
  51. resource :follower_domains, only: [:show, :update]
  52. end
  53. resources :media, only: [:show]
  54. resources :tags, only: [:show]
  55. # Remote follow
  56. get :authorize_follow, to: 'authorize_follow#new'
  57. post :authorize_follow, to: 'authorize_follow#create'
  58. namespace :admin do
  59. resources :pubsubhubbub, only: [:index]
  60. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  61. resources :settings, only: [:index, :update]
  62. resources :instances, only: [:index]
  63. resources :reports, only: [:index, :show, :update] do
  64. resources :reported_statuses, only: :destroy
  65. end
  66. resources :accounts, only: [:index, :show] do
  67. resource :reset, only: [:create]
  68. resource :silence, only: [:create, :destroy]
  69. resource :suspension, only: [:create, :destroy]
  70. resource :confirmation, only: [:create]
  71. end
  72. end
  73. get '/admin', to: redirect('/admin/settings', status: 302)
  74. namespace :api do
  75. # PubSubHubbub outgoing subscriptions
  76. resources :subscriptions, only: [:show]
  77. post '/subscriptions/:id', to: 'subscriptions#update'
  78. # PubSubHubbub incoming subscriptions
  79. post '/push', to: 'push#update', as: :push
  80. # Salmon
  81. post '/salmon/:id', to: 'salmon#update', as: :salmon
  82. # OEmbed
  83. get '/oembed', to: 'oembed#show', as: :oembed
  84. # ActivityPub
  85. namespace :activitypub do
  86. get '/users/:id/outbox', to: 'outbox#show', as: :outbox
  87. get '/statuses/:id', to: 'activities#show_status', as: :status
  88. resources :notes, only: [:show]
  89. end
  90. # JSON / REST API
  91. namespace :v1 do
  92. resources :statuses, only: [:create, :show, :destroy] do
  93. member do
  94. get :context
  95. get :card
  96. get :reblogged_by
  97. get :favourited_by
  98. post :reblog
  99. post :unreblog
  100. post :favourite
  101. post :unfavourite
  102. end
  103. end
  104. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  105. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  106. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  107. get '/search', to: 'search#index', as: :search
  108. resources :follows, only: [:create]
  109. resources :media, only: [:create]
  110. resources :apps, only: [:create]
  111. resources :blocks, only: [:index]
  112. resources :mutes, only: [:index]
  113. resources :favourites, only: [:index]
  114. resources :reports, only: [:index, :create]
  115. resource :instance, only: [:show]
  116. resources :follow_requests, only: [:index] do
  117. member do
  118. post :authorize
  119. post :reject
  120. end
  121. end
  122. resources :notifications, only: [:index, :show] do
  123. collection do
  124. post :clear
  125. post :dismiss
  126. end
  127. end
  128. resources :accounts, only: [:show] do
  129. collection do
  130. get :relationships
  131. get :verify_credentials
  132. patch :update_credentials
  133. get :search
  134. end
  135. member do
  136. get :statuses
  137. get :followers
  138. get :following
  139. post :follow
  140. post :unfollow
  141. post :block
  142. post :unblock
  143. post :mute
  144. post :unmute
  145. end
  146. end
  147. end
  148. namespace :web do
  149. resource :settings, only: [:update]
  150. end
  151. end
  152. get '/web/(*any)', to: 'home#index', as: :web
  153. get '/about', to: 'about#show'
  154. get '/about/more', to: 'about#more'
  155. get '/terms', to: 'about#terms'
  156. root 'home#index'
  157. match '*unmatched_route',
  158. via: :all,
  159. to: 'application#raise_not_found',
  160. format: false
  161. end