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.

188 lines
4.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'
  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 :export, only: [:show]
  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 :reports, only: [:index, :show] do
  56. member do
  57. post :resolve
  58. post :silence
  59. post :suspend
  60. post :remove
  61. end
  62. end
  63. resources :accounts, only: [:index, :show] do
  64. member do
  65. post :silence
  66. post :unsilence
  67. post :suspend
  68. post :unsuspend
  69. end
  70. end
  71. end
  72. get '/admin', to: redirect('/admin/settings', status: 302)
  73. namespace :api do
  74. # PubSubHubbub outgoing subscriptions
  75. resources :subscriptions, only: [:show]
  76. post '/subscriptions/:id', to: 'subscriptions#update'
  77. # PubSubHubbub incoming subscriptions
  78. post '/push', to: 'push#update', as: :push
  79. # Salmon
  80. post '/salmon/:id', to: 'salmon#update', as: :salmon
  81. # OEmbed
  82. get '/oembed', to: 'oembed#show', as: :oembed
  83. # JSON / REST API
  84. namespace :v1 do
  85. resources :statuses, only: [:create, :show, :destroy] do
  86. member do
  87. get :context
  88. get :card
  89. get :reblogged_by
  90. get :favourited_by
  91. post :reblog
  92. post :unreblog
  93. post :favourite
  94. post :unfavourite
  95. end
  96. end
  97. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  98. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  99. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  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. end
  118. end
  119. resources :accounts, only: [:show] do
  120. collection do
  121. get :relationships
  122. get :verify_credentials
  123. get :search
  124. end
  125. member do
  126. get :statuses
  127. get :followers
  128. get :following
  129. post :follow
  130. post :unfollow
  131. post :block
  132. post :unblock
  133. post :mute
  134. post :unmute
  135. end
  136. end
  137. end
  138. namespace :web do
  139. resource :settings, only: [:update]
  140. end
  141. end
  142. get '/web/(*any)', to: 'home#index', as: :web
  143. get '/about', to: 'about#index'
  144. get '/about/more', to: 'about#more'
  145. get '/terms', to: 'about#terms'
  146. root 'home#index'
  147. get '/:username', to: redirect('/users/%{username}')
  148. get '/:username/:id', to: redirect('/users/%{username}/updates/%{id}')
  149. match '*unmatched_route', via: :all, to: 'application#raise_not_found'
  150. end