application.rb 3.7 KB

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