The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

257 lines
7.7 KiB

  1. # frozen_string_literal: true
  2. require 'sidekiq/web'
  3. require 'sidekiq-scheduler/web'
  4. Sidekiq::Web.set :session_secret, Rails.application.secrets[:secret_key_base]
  5. Rails.application.routes.draw do
  6. mount LetterOpenerWeb::Engine, at: 'letter_opener' if Rails.env.development?
  7. authenticate :user, lambda { |u| u.admin? } do
  8. mount Sidekiq::Web, at: 'sidekiq', as: :sidekiq
  9. mount PgHero::Engine, at: 'pghero', as: :pghero
  10. end
  11. use_doorkeeper do
  12. controllers authorizations: 'oauth/authorizations', authorized_applications: 'oauth/authorized_applications'
  13. end
  14. get '.well-known/host-meta', to: 'well_known/host_meta#show', as: :host_meta, defaults: { format: 'xml' }
  15. get '.well-known/webfinger', to: 'well_known/webfinger#show', as: :webfinger
  16. get 'manifest', to: 'manifests#show', defaults: { format: 'json' }
  17. get 'intent', to: 'intents#show'
  18. devise_for :users, path: 'auth', controllers: {
  19. sessions: 'auth/sessions',
  20. registrations: 'auth/registrations',
  21. passwords: 'auth/passwords',
  22. confirmations: 'auth/confirmations',
  23. }
  24. get '/users/:username', to: redirect('/@%{username}'), constraints: lambda { |req| req.format.nil? || req.format.html? }
  25. resources :accounts, path: 'users', only: [:show], param: :username do
  26. resources :stream_entries, path: 'updates', only: [:show] do
  27. member do
  28. get :embed
  29. end
  30. end
  31. get :remote_follow, to: 'remote_follow#new'
  32. post :remote_follow, to: 'remote_follow#create'
  33. resources :statuses, only: [:show] do
  34. member do
  35. get :activity
  36. end
  37. end
  38. resources :followers, only: [:index], controller: :follower_accounts
  39. resources :following, only: [:index], controller: :following_accounts
  40. resource :follow, only: [:create], controller: :account_follow
  41. resource :unfollow, only: [:create], controller: :account_unfollow
  42. resource :outbox, only: [:show], module: :activitypub
  43. resource :inbox, only: [:create], module: :activitypub
  44. end
  45. get '/@:username', to: 'accounts#show', as: :short_account
  46. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  47. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  48. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  49. namespace :settings do
  50. resource :profile, only: [:show, :update]
  51. resource :preferences, only: [:show, :update]
  52. resource :import, only: [:show, :create]
  53. resource :export, only: [:show]
  54. namespace :exports, constraints: { format: :csv } do
  55. resources :follows, only: :index, controller: :following_accounts
  56. resources :blocks, only: :index, controller: :blocked_accounts
  57. resources :mutes, only: :index, controller: :muted_accounts
  58. end
  59. resource :two_factor_authentication, only: [:show, :create, :destroy]
  60. namespace :two_factor_authentication do
  61. resources :recovery_codes, only: [:create]
  62. resource :confirmation, only: [:new, :create]
  63. end
  64. resource :follower_domains, only: [:show, :update]
  65. resources :applications, except: [:edit] do
  66. member do
  67. post :regenerate
  68. end
  69. end
  70. resource :delete, only: [:show, :destroy]
  71. resources :sessions, only: [:destroy]
  72. end
  73. resources :media, only: [:show]
  74. resources :tags, only: [:show]
  75. # Remote follow
  76. resource :authorize_follow, only: [:show, :create]
  77. resource :share, only: [:show, :create]
  78. namespace :admin do
  79. resources :subscriptions, only: [:index]
  80. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  81. resource :settings, only: [:edit, :update]
  82. resources :instances, only: [:index] do
  83. collection do
  84. post :resubscribe
  85. end
  86. end
  87. resources :reports, only: [:index, :show, :update] do
  88. resources :reported_statuses, only: [:create, :update, :destroy]
  89. end
  90. resources :accounts, only: [:index, :show] do
  91. member do
  92. post :subscribe
  93. post :unsubscribe
  94. post :redownload
  95. end
  96. resource :reset, only: [:create]
  97. resource :silence, only: [:create, :destroy]
  98. resource :suspension, only: [:create, :destroy]
  99. resource :confirmation, only: [:create]
  100. resources :statuses, only: [:index, :create, :update, :destroy]
  101. end
  102. resources :users, only: [] do
  103. resource :two_factor_authentication, only: [:destroy]
  104. end
  105. end
  106. get '/admin', to: redirect('/admin/settings/edit', status: 302)
  107. namespace :api do
  108. # PubSubHubbub outgoing subscriptions
  109. resources :subscriptions, only: [:show]
  110. post '/subscriptions/:id', to: 'subscriptions#update'
  111. # PubSubHubbub incoming subscriptions
  112. post '/push', to: 'push#update', as: :push
  113. # Salmon
  114. post '/salmon/:id', to: 'salmon#update', as: :salmon
  115. # OEmbed
  116. get '/oembed', to: 'oembed#show', as: :oembed
  117. # JSON / REST API
  118. namespace :v1 do
  119. resources :statuses, only: [:create, :show, :destroy] do
  120. scope module: :statuses do
  121. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  122. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  123. resource :reblog, only: :create
  124. post :unreblog, to: 'reblogs#destroy'
  125. resource :favourite, only: :create
  126. post :unfavourite, to: 'favourites#destroy'
  127. resource :mute, only: :create
  128. post :unmute, to: 'mutes#destroy'
  129. resource :pin, only: :create
  130. post :unpin, to: 'pins#destroy'
  131. end
  132. member do
  133. get :context
  134. get :card
  135. end
  136. end
  137. namespace :timelines do
  138. resource :home, only: :show, controller: :home
  139. resource :public, only: :show, controller: :public
  140. resources :tag, only: :show
  141. end
  142. resources :streaming, only: [:index]
  143. get '/search', to: 'search#index', as: :search
  144. resources :follows, only: [:create]
  145. resources :media, only: [:create]
  146. resources :apps, only: [:create]
  147. resources :blocks, only: [:index]
  148. resources :mutes, only: [:index]
  149. resources :favourites, only: [:index]
  150. resources :reports, only: [:index, :create]
  151. resource :instance, only: [:show]
  152. resource :domain_blocks, only: [:show, :create, :destroy]
  153. resources :follow_requests, only: [:index] do
  154. member do
  155. post :authorize
  156. post :reject
  157. end
  158. end
  159. resources :notifications, only: [:index, :show] do
  160. collection do
  161. post :clear
  162. post :dismiss
  163. end
  164. end
  165. namespace :accounts do
  166. get :verify_credentials, to: 'credentials#show'
  167. patch :update_credentials, to: 'credentials#update'
  168. resource :search, only: :show, controller: :search
  169. resources :relationships, only: :index
  170. end
  171. resources :accounts, only: [:show] do
  172. resources :statuses, only: :index, controller: 'accounts/statuses'
  173. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  174. resources :following, only: :index, controller: 'accounts/following_accounts'
  175. member do
  176. post :follow
  177. post :unfollow
  178. post :block
  179. post :unblock
  180. post :mute
  181. post :unmute
  182. end
  183. end
  184. end
  185. namespace :web do
  186. resource :settings, only: [:update]
  187. resources :push_subscriptions, only: [:create] do
  188. member do
  189. put :update
  190. end
  191. end
  192. end
  193. end
  194. get '/web/(*any)', to: 'home#index', as: :web
  195. get '/about', to: 'about#show'
  196. get '/about/more', to: 'about#more'
  197. get '/terms', to: 'about#terms'
  198. root 'home#index'
  199. match '*unmatched_route',
  200. via: :all,
  201. to: 'application#raise_not_found',
  202. format: false
  203. end