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.
 
 
 
 

267 lines
8.1 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. get :embed
  37. end
  38. end
  39. resources :followers, only: [:index], controller: :follower_accounts
  40. resources :following, only: [:index], controller: :following_accounts
  41. resource :follow, only: [:create], controller: :account_follow
  42. resource :unfollow, only: [:create], controller: :account_unfollow
  43. resource :outbox, only: [:show], module: :activitypub
  44. resource :inbox, only: [:create], module: :activitypub
  45. end
  46. resource :inbox, only: [:create], module: :activitypub
  47. get '/@:username', to: 'accounts#show', as: :short_account
  48. get '/@:username/with_replies', to: 'accounts#show', as: :short_account_with_replies
  49. get '/@:username/media', to: 'accounts#show', as: :short_account_media
  50. get '/@:account_username/:id', to: 'statuses#show', as: :short_account_status
  51. get '/@:account_username/:id/embed', to: 'statuses#embed', as: :embed_short_account_status
  52. namespace :settings do
  53. resource :profile, only: [:show, :update]
  54. resource :preferences, only: [:show, :update]
  55. resource :import, only: [:show, :create]
  56. resource :export, only: [:show]
  57. namespace :exports, constraints: { format: :csv } do
  58. resources :follows, only: :index, controller: :following_accounts
  59. resources :blocks, only: :index, controller: :blocked_accounts
  60. resources :mutes, only: :index, controller: :muted_accounts
  61. end
  62. resource :two_factor_authentication, only: [:show, :create, :destroy]
  63. namespace :two_factor_authentication do
  64. resources :recovery_codes, only: [:create]
  65. resource :confirmation, only: [:new, :create]
  66. end
  67. resource :follower_domains, only: [:show, :update]
  68. resources :applications, except: [:edit] do
  69. member do
  70. post :regenerate
  71. end
  72. end
  73. resource :delete, only: [:show, :destroy]
  74. resources :sessions, only: [:destroy]
  75. end
  76. resources :media, only: [:show]
  77. resources :tags, only: [:show]
  78. get '/media_proxy/:id/(*any)', to: 'media_proxy#show', as: :media_proxy
  79. # Remote follow
  80. resource :authorize_follow, only: [:show, :create]
  81. resource :share, only: [:show, :create]
  82. namespace :admin do
  83. resources :subscriptions, only: [:index]
  84. resources :domain_blocks, only: [:index, :new, :create, :show, :destroy]
  85. resource :settings, only: [:edit, :update]
  86. resources :instances, only: [:index] do
  87. collection do
  88. post :resubscribe
  89. end
  90. end
  91. resources :reports, only: [:index, :show, :update] do
  92. resources :reported_statuses, only: [:create, :update, :destroy]
  93. end
  94. resources :accounts, only: [:index, :show] do
  95. member do
  96. post :subscribe
  97. post :unsubscribe
  98. post :redownload
  99. end
  100. resource :reset, only: [:create]
  101. resource :silence, only: [:create, :destroy]
  102. resource :suspension, only: [:create, :destroy]
  103. resource :confirmation, only: [:create]
  104. resources :statuses, only: [:index, :create, :update, :destroy]
  105. end
  106. resources :users, only: [] do
  107. resource :two_factor_authentication, only: [:destroy]
  108. end
  109. resources :custom_emojis, only: [:index, :new, :create, :destroy]
  110. end
  111. get '/admin', to: redirect('/admin/settings/edit', status: 302)
  112. namespace :api do
  113. # PubSubHubbub outgoing subscriptions
  114. resources :subscriptions, only: [:show]
  115. post '/subscriptions/:id', to: 'subscriptions#update'
  116. # PubSubHubbub incoming subscriptions
  117. post '/push', to: 'push#update', as: :push
  118. # Salmon
  119. post '/salmon/:id', to: 'salmon#update', as: :salmon
  120. # OEmbed
  121. get '/oembed', to: 'oembed#show', as: :oembed
  122. # JSON / REST API
  123. namespace :v1 do
  124. resources :statuses, only: [:create, :show, :destroy] do
  125. scope module: :statuses do
  126. resources :reblogged_by, controller: :reblogged_by_accounts, only: :index
  127. resources :favourited_by, controller: :favourited_by_accounts, only: :index
  128. resource :reblog, only: :create
  129. post :unreblog, to: 'reblogs#destroy'
  130. resource :favourite, only: :create
  131. post :unfavourite, to: 'favourites#destroy'
  132. resource :mute, only: :create
  133. post :unmute, to: 'mutes#destroy'
  134. resource :pin, only: :create
  135. post :unpin, to: 'pins#destroy'
  136. end
  137. member do
  138. get :context
  139. get :card
  140. end
  141. end
  142. namespace :timelines do
  143. resource :home, only: :show, controller: :home
  144. resource :public, only: :show, controller: :public
  145. resources :tag, only: :show
  146. end
  147. resources :streaming, only: [:index]
  148. resources :custom_emojis, only: [:index]
  149. get '/search', to: 'search#index', as: :search
  150. resources :follows, only: [:create]
  151. resources :media, only: [:create, :update]
  152. resources :apps, only: [:create]
  153. resources :blocks, only: [:index]
  154. resources :mutes, only: [:index]
  155. resources :favourites, only: [:index]
  156. resources :reports, only: [:index, :create]
  157. resource :instance, only: [:show]
  158. resource :domain_blocks, only: [:show, :create, :destroy]
  159. resources :follow_requests, only: [:index] do
  160. member do
  161. post :authorize
  162. post :reject
  163. end
  164. end
  165. resources :notifications, only: [:index, :show] do
  166. collection do
  167. post :clear
  168. post :dismiss
  169. end
  170. end
  171. namespace :accounts do
  172. get :verify_credentials, to: 'credentials#show'
  173. patch :update_credentials, to: 'credentials#update'
  174. resource :search, only: :show, controller: :search
  175. resources :relationships, only: :index
  176. end
  177. resources :accounts, only: [:show] do
  178. resources :statuses, only: :index, controller: 'accounts/statuses'
  179. resources :followers, only: :index, controller: 'accounts/follower_accounts'
  180. resources :following, only: :index, controller: 'accounts/following_accounts'
  181. member do
  182. post :follow
  183. post :unfollow
  184. post :block
  185. post :unblock
  186. post :mute
  187. post :unmute
  188. end
  189. end
  190. end
  191. namespace :web do
  192. resource :settings, only: [:update]
  193. resource :embed, only: [:create]
  194. resources :push_subscriptions, only: [:create] do
  195. member do
  196. put :update
  197. end
  198. end
  199. end
  200. end
  201. get '/web/(*any)', to: 'home#index', as: :web
  202. get '/about', to: 'about#show'
  203. get '/about/more', to: 'about#more'
  204. get '/terms', to: 'about#terms'
  205. root 'home#index'
  206. match '*unmatched_route',
  207. via: :all,
  208. to: 'application#raise_not_found',
  209. format: false
  210. end