application.rb 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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/sanitize_ext/sanitize_config'
  21. require_relative '../lib/redis/namespace_extensions'
  22. require_relative '../lib/paperclip/url_generator_extensions'
  23. require_relative '../lib/paperclip/attachment_extensions'
  24. require_relative '../lib/paperclip/lazy_thumbnail'
  25. require_relative '../lib/paperclip/gif_transcoder'
  26. require_relative '../lib/paperclip/transcoder'
  27. require_relative '../lib/paperclip/type_corrector'
  28. require_relative '../lib/paperclip/response_with_limit_adapter'
  29. require_relative '../lib/terrapin/multi_pipe_extensions'
  30. require_relative '../lib/mastodon/snowflake'
  31. require_relative '../lib/mastodon/version'
  32. require_relative '../lib/mastodon/rack_middleware'
  33. require_relative '../lib/devise/two_factor_ldap_authenticatable'
  34. require_relative '../lib/devise/two_factor_pam_authenticatable'
  35. require_relative '../lib/chewy/strategy/mastodon'
  36. require_relative '../lib/webpacker/manifest_extensions'
  37. require_relative '../lib/webpacker/helper_extensions'
  38. require_relative '../lib/rails/engine_extensions'
  39. require_relative '../lib/active_record/database_tasks_extensions'
  40. require_relative '../lib/active_record/batches'
  41. require_relative '../lib/simple_navigation/item_extensions'
  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. :be,
  63. :bg,
  64. :bn,
  65. :br,
  66. :ca,
  67. :ckb,
  68. :co,
  69. :cs,
  70. :cy,
  71. :da,
  72. :de,
  73. :el,
  74. :en,
  75. :eo,
  76. :es,
  77. :'es-AR',
  78. :'es-MX',
  79. :et,
  80. :eu,
  81. :fa,
  82. :fi,
  83. :fr,
  84. :fy,
  85. :ga,
  86. :gd,
  87. :gl,
  88. :he,
  89. :hi,
  90. :hr,
  91. :hu,
  92. :hy,
  93. :id,
  94. :io,
  95. :is,
  96. :it,
  97. :ja,
  98. :ka,
  99. :kab,
  100. :kk,
  101. :kn,
  102. :ko,
  103. :ku,
  104. :lt,
  105. :lv,
  106. :mk,
  107. :ml,
  108. :mr,
  109. :ms,
  110. :nl,
  111. :nn,
  112. :no,
  113. :oc,
  114. :pl,
  115. :'pt-BR',
  116. :'pt-PT',
  117. :ro,
  118. :ru,
  119. :sa,
  120. :sc,
  121. :si,
  122. :sk,
  123. :sl,
  124. :sq,
  125. :sr,
  126. :'sr-Latn',
  127. :sv,
  128. :ta,
  129. :te,
  130. :th,
  131. :tr,
  132. :uk,
  133. :ur,
  134. :vi,
  135. :zgh,
  136. :'zh-CN',
  137. :'zh-HK',
  138. :'zh-TW',
  139. ]
  140. config.i18n.default_locale = begin
  141. custom_default_locale = ENV['DEFAULT_LOCALE']&.to_sym
  142. if config.i18n.available_locales.include?(custom_default_locale)
  143. custom_default_locale
  144. else
  145. :en
  146. end
  147. end
  148. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  149. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  150. config.active_job.queue_adapter = :sidekiq
  151. config.action_mailer.deliver_later_queue_name = 'mailers'
  152. config.middleware.use Rack::Attack
  153. config.middleware.use Mastodon::RackMiddleware
  154. config.to_prepare do
  155. Doorkeeper::AuthorizationsController.layout 'modal'
  156. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  157. Doorkeeper::Application.send :include, ApplicationExtension
  158. Doorkeeper::AccessToken.send :include, AccessTokenExtension
  159. Devise::FailureApp.send :include, AbstractController::Callbacks
  160. Devise::FailureApp.send :include, Localized
  161. end
  162. end
  163. end