The code powering m.abunchtell.com https://m.abunchtell.com
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

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