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.

194 lines
5.6 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. end
  52. resources :media, only: [:show]
  53. resources :tags, only: [:show]
  54. # Remote follow
  55. get :authorize_follow, to: 'authorize_follow#new'
  56. post :authorize_follow, to: 'authorize_follow#create'
  57. namespace :admin do
  58. resources :pubsubhubbub, only: [:index]
  59. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  60. resources :settings, only: [:index, :update]
  61. resources :instances, only: [:index]
  62. resources :reports, only: [:index, :show, :update] do
  63. resources :reported_statuses, only: :destroy
  64. end
  65. resources :accounts, only: [:index, :show] do
  66. resource :reset, only: [:create]
  67. resource :silence, only: [:create, :destroy]
  68. resource :suspension, only: [:create, :destroy]
  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. get '/search', to: 'search#index', as: :search
  100. resources :follows, only: [:create]
  101. resources :media, only: [:create]
  102. resources :apps, only: [:create]
  103. resources :blocks, only: [:index]
  104. resources :mutes, only: [:index]
  105. resources :favourites, only: [:index]
  106. resources :reports, only: [:index, :create]
  107. resource :instance, only: [:show]
  108. resources :follow_requests, only: [:index] do
  109. member do
  110. post :authorize
  111. post :reject
  112. end
  113. end
  114. resources :notifications, only: [:index, :show] do
  115. collection do
  116. post :clear
  117. post :dismiss
  118. end
  119. end
  120. resources :accounts, only: [:show] do
  121. collection do
  122. get :relationships
  123. get :verify_credentials
  124. patch :update_credentials
  125. get :search
  126. end
  127. member do
  128. get :statuses
  129. get :followers
  130. get :following
  131. post :follow
  132. post :unfollow
  133. post :block
  134. post :unblock
  135. post :mute
  136. post :unmute
  137. end
  138. end
  139. end
  140. namespace :web do
  141. resource :settings, only: [:update]
  142. end
  143. end
  144. get '/web/(*any)', to: 'home#index', as: :web
  145. get '/about', to: 'about#show'
  146. get '/about/more', to: 'about#more'
  147. get '/terms', to: 'about#terms'
  148. root 'home#index'
  149. match '*unmatched_route',
  150. via: :all,
  151. to: 'application#raise_not_found',
  152. format: false
  153. end