application.rb 3.9 KB

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