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.

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