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
4.8 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] do
  39. collection do
  40. get :follows, to: 'exports#download_following_list'
  41. get :blocks, to: 'exports#download_blocking_list'
  42. end
  43. end
  44. resource :two_factor_auth, only: [:show] do
  45. member do
  46. post :enable
  47. post :disable
  48. end
  49. end
  50. end
  51. resources :media, only: [:show]
  52. resources :tags, only: [:show]
  53. # Remote follow
  54. get :authorize_follow, to: 'authorize_follow#new'
  55. post :authorize_follow, to: 'authorize_follow#create'
  56. namespace :admin do
  57. resources :pubsubhubbub, only: [:index]
  58. resources :domain_blocks, only: [:index, :create]
  59. resources :settings, only: [:index, :update]
  60. resources :reports, only: [:index, :show] do
  61. member do
  62. post :resolve
  63. post :silence
  64. post :suspend
  65. post :remove
  66. end
  67. end
  68. resources :accounts, only: [:index, :show] do
  69. member do
  70. post :silence
  71. post :unsilence
  72. post :suspend
  73. post :unsuspend
  74. end
  75. end
  76. end
  77. get '/admin', to: redirect('/admin/settings', status: 302)
  78. namespace :api do
  79. # PubSubHubbub outgoing subscriptions
  80. resources :subscriptions, only: [:show]
  81. post '/subscriptions/:id', to: 'subscriptions#update'
  82. # PubSubHubbub incoming subscriptions
  83. post '/push', to: 'push#update', as: :push
  84. # Salmon
  85. post '/salmon/:id', to: 'salmon#update', as: :salmon
  86. # OEmbed
  87. get '/oembed', to: 'oembed#show', as: :oembed
  88. # JSON / REST API
  89. namespace :v1 do
  90. resources :statuses, only: [:create, :show, :destroy] do
  91. member do
  92. get :context
  93. get :card
  94. get :reblogged_by
  95. get :favourited_by
  96. post :reblog
  97. post :unreblog
  98. post :favourite
  99. post :unfavourite
  100. end
  101. end
  102. get '/timelines/home', to: 'timelines#home', as: :home_timeline
  103. get '/timelines/public', to: 'timelines#public', as: :public_timeline
  104. get '/timelines/tag/:id', to: 'timelines#tag', as: :hashtag_timeline
  105. resources :follows, only: [:create]
  106. resources :media, only: [:create]
  107. resources :apps, only: [:create]
  108. resources :blocks, only: [:index]
  109. resources :mutes, only: [:index]
  110. resources :favourites, only: [:index]
  111. resources :reports, only: [:index, :create]
  112. resource :instance, only: [:show]
  113. resources :follow_requests, only: [:index] do
  114. member do
  115. post :authorize
  116. post :reject
  117. end
  118. end
  119. resources :notifications, only: [:index, :show] do
  120. collection do
  121. post :clear
  122. end
  123. end
  124. resources :accounts, only: [:show] do
  125. collection do
  126. get :relationships
  127. get :verify_credentials
  128. get :search
  129. end
  130. member do
  131. get :statuses
  132. get :followers
  133. get :following
  134. post :follow
  135. post :unfollow
  136. post :block
  137. post :unblock
  138. post :mute
  139. post :unmute
  140. end
  141. end
  142. end
  143. namespace :web do
  144. resource :settings, only: [:update]
  145. end
  146. end
  147. get '/web/(*any)', to: 'home#index', as: :web
  148. get '/about', to: 'about#index'
  149. get '/about/more', to: 'about#more'
  150. get '/terms', to: 'about#terms'
  151. root 'home#index'
  152. get '/:username', to: redirect('/users/%{username}')
  153. get '/:username/:id', to: redirect('/users/%{username}/updates/%{id}')
  154. match '*unmatched_route', via: :all, to: 'application#raise_not_found'
  155. end