The code powering m.abunchtell.com https://m.abunchtell.com
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

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