1
0

application.rb 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. require_relative 'boot'
  2. require 'rails'
  3. require 'active_record/railtie'
  4. #require 'active_storage/engine'
  5. require 'action_controller/railtie'
  6. require 'action_view/railtie'
  7. require 'action_mailer/railtie'
  8. require 'active_job/railtie'
  9. #require 'action_cable/engine'
  10. #require 'action_mailbox/engine'
  11. #require 'action_text/engine'
  12. #require 'rails/test_unit/railtie'
  13. require 'sprockets/railtie'
  14. # Used to be implicitly required in action_mailbox/engine
  15. require 'mail'
  16. # Require the gems listed in Gemfile, including any gems
  17. # you've limited to :test, :development, or :production.
  18. Bundler.require(*Rails.groups)
  19. require_relative '../lib/exceptions'
  20. require_relative '../lib/enumerable'
  21. require_relative '../lib/sanitize_ext/sanitize_config'
  22. require_relative '../lib/redis/namespace_extensions'
  23. require_relative '../lib/paperclip/url_generator_extensions'
  24. require_relative '../lib/paperclip/attachment_extensions'
  25. require_relative '../lib/paperclip/lazy_thumbnail'
  26. require_relative '../lib/paperclip/gif_transcoder'
  27. require_relative '../lib/paperclip/transcoder'
  28. require_relative '../lib/paperclip/type_corrector'
  29. require_relative '../lib/paperclip/response_with_limit_adapter'
  30. require_relative '../lib/terrapin/multi_pipe_extensions'
  31. require_relative '../lib/mastodon/snowflake'
  32. require_relative '../lib/mastodon/version'
  33. require_relative '../lib/mastodon/rack_middleware'
  34. require_relative '../lib/devise/two_factor_ldap_authenticatable'
  35. require_relative '../lib/devise/two_factor_pam_authenticatable'
  36. require_relative '../lib/chewy/strategy/mastodon'
  37. require_relative '../lib/webpacker/manifest_extensions'
  38. require_relative '../lib/webpacker/helper_extensions'
  39. require_relative '../lib/rails/engine_extensions'
  40. require_relative '../lib/active_record/database_tasks_extensions'
  41. require_relative '../lib/active_record/batches'
  42. Dotenv::Railtie.load
  43. Bundler.require(:pam_authentication) if ENV['PAM_ENABLED'] == 'true'
  44. require_relative '../lib/mastodon/redis_config'
  45. module Mastodon
  46. class Application < Rails::Application
  47. # Initialize configuration defaults for originally generated Rails version.
  48. config.load_defaults 6.1
  49. config.add_autoload_paths_to_load_path = false
  50. # Settings in config/environments/* take precedence over those specified here.
  51. # Application configuration should go into files in config/initializers
  52. # -- all .rb files in that directory are automatically loaded.
  53. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  54. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
  55. # config.time_zone = 'Central Time (US & Canada)'
  56. # All translations from config/locales/*.rb,yml are auto loaded.
  57. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
  58. config.i18n.available_locales = [
  59. :af,
  60. :ar,
  61. :ast,
  62. :bg,
  63. :bn,
  64. :br,
  65. :ca,
  66. :ckb,
  67. :co,
  68. :cs,
  69. :cy,
  70. :da,
  71. :de,
  72. :el,
  73. :en,
  74. :eo,
  75. :es,
  76. :'es-AR',
  77. :'es-MX',
  78. :et,
  79. :eu,
  80. :fa,
  81. :fi,
  82. :fr,
  83. :ga,
  84. :gd,
  85. :gl,
  86. :he,
  87. :hi,
  88. :hr,
  89. :hu,
  90. :hy,
  91. :id,
  92. :io,
  93. :is,
  94. :it,
  95. :ja,
  96. :ka,
  97. :kab,
  98. :kk,
  99. :kn,
  100. :ko,
  101. :ku,
  102. :lt,
  103. :lv,
  104. :mk,
  105. :ml,
  106. :mr,
  107. :ms,
  108. :nl,
  109. :nn,
  110. :no,
  111. :oc,
  112. :pl,
  113. :'pt-BR',
  114. :'pt-PT',
  115. :ro,
  116. :ru,
  117. :sa,
  118. :sc,
  119. :si,
  120. :sk,
  121. :sl,
  122. :sq,
  123. :sr,
  124. :'sr-Latn',
  125. :sv,
  126. :ta,
  127. :te,
  128. :th,
  129. :tr,
  130. :uk,
  131. :ur,
  132. :vi,
  133. :zgh,
  134. :'zh-CN',
  135. :'zh-HK',
  136. :'zh-TW',
  137. ]
  138. config.i18n.default_locale = begin
  139. custom_default_locale = ENV['DEFAULT_LOCALE']&.to_sym
  140. if config.i18n.available_locales.include?(custom_default_locale)
  141. custom_default_locale
  142. else
  143. :en
  144. end
  145. end
  146. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  147. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  148. config.active_job.queue_adapter = :sidekiq
  149. config.middleware.use Rack::Attack
  150. config.middleware.use Rack::Deflater
  151. config.middleware.use Mastodon::RackMiddleware
  152. config.to_prepare do
  153. Doorkeeper::AuthorizationsController.layout 'modal'
  154. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  155. Doorkeeper::Application.send :include, ApplicationExtension
  156. Doorkeeper::AccessToken.send :include, AccessTokenExtension
  157. Devise::FailureApp.send :include, AbstractController::Callbacks
  158. Devise::FailureApp.send :include, Localized
  159. end
  160. end
  161. end