application.rb 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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/media_type_spoof_detector_extensions'
  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/public_file_server_middleware'
  35. require_relative '../lib/devise/two_factor_ldap_authenticatable'
  36. require_relative '../lib/devise/two_factor_pam_authenticatable'
  37. require_relative '../lib/chewy/strategy/mastodon'
  38. require_relative '../lib/chewy/strategy/bypass_with_warning'
  39. require_relative '../lib/webpacker/manifest_extensions'
  40. require_relative '../lib/webpacker/helper_extensions'
  41. require_relative '../lib/rails/engine_extensions'
  42. require_relative '../lib/active_record/database_tasks_extensions'
  43. require_relative '../lib/active_record/batches'
  44. require_relative '../lib/simple_navigation/item_extensions'
  45. Dotenv::Railtie.load
  46. Bundler.require(:pam_authentication) if ENV['PAM_ENABLED'] == 'true'
  47. require_relative '../lib/mastodon/redis_config'
  48. module Mastodon
  49. class Application < Rails::Application
  50. # Initialize configuration defaults for originally generated Rails version.
  51. config.load_defaults 6.1
  52. config.add_autoload_paths_to_load_path = false
  53. # Settings in config/environments/* take precedence over those specified here.
  54. # Application configuration should go into files in config/initializers
  55. # -- all .rb files in that directory are automatically loaded.
  56. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  57. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
  58. # config.time_zone = 'Central Time (US & Canada)'
  59. # All translations from config/locales/*.rb,yml are auto loaded.
  60. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
  61. config.i18n.available_locales = [
  62. :af,
  63. :an,
  64. :ar,
  65. :ast,
  66. :be,
  67. :bg,
  68. :bn,
  69. :br,
  70. :bs,
  71. :ca,
  72. :ckb,
  73. :co,
  74. :cs,
  75. :cy,
  76. :da,
  77. :de,
  78. :el,
  79. :en,
  80. :'en-GB',
  81. :eo,
  82. :es,
  83. :'es-AR',
  84. :'es-MX',
  85. :et,
  86. :eu,
  87. :fa,
  88. :fi,
  89. :fo,
  90. :fr,
  91. :'fr-QC',
  92. :fy,
  93. :ga,
  94. :gd,
  95. :gl,
  96. :he,
  97. :hi,
  98. :hr,
  99. :hu,
  100. :hy,
  101. :id,
  102. :ig,
  103. :io,
  104. :is,
  105. :it,
  106. :ja,
  107. :ka,
  108. :kab,
  109. :kk,
  110. :kn,
  111. :ko,
  112. :ku,
  113. :kw,
  114. :la,
  115. :lt,
  116. :lv,
  117. :mk,
  118. :ml,
  119. :mr,
  120. :ms,
  121. :my,
  122. :nl,
  123. :nn,
  124. :no,
  125. :oc,
  126. :pa,
  127. :pl,
  128. :'pt-BR',
  129. :'pt-PT',
  130. :ro,
  131. :ru,
  132. :sa,
  133. :sc,
  134. :sco,
  135. :si,
  136. :sk,
  137. :sl,
  138. :sq,
  139. :sr,
  140. :'sr-Latn',
  141. :sv,
  142. :szl,
  143. :ta,
  144. :tai,
  145. :te,
  146. :th,
  147. :tr,
  148. :tt,
  149. :ug,
  150. :uk,
  151. :ur,
  152. :vi,
  153. :zgh,
  154. :'zh-CN',
  155. :'zh-HK',
  156. :'zh-TW',
  157. ]
  158. config.i18n.default_locale = begin
  159. custom_default_locale = ENV['DEFAULT_LOCALE']&.to_sym
  160. if config.i18n.available_locales.include?(custom_default_locale)
  161. custom_default_locale
  162. else
  163. :en
  164. end
  165. end
  166. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  167. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  168. config.active_job.queue_adapter = :sidekiq
  169. config.action_mailer.deliver_later_queue_name = 'mailers'
  170. # We use our own middleware for this
  171. config.public_file_server.enabled = false
  172. config.middleware.use PublicFileServerMiddleware if Rails.env.development? || ENV['RAILS_SERVE_STATIC_FILES'] == 'true'
  173. config.middleware.use Rack::Attack
  174. config.middleware.use Mastodon::RackMiddleware
  175. config.to_prepare do
  176. Doorkeeper::AuthorizationsController.layout 'modal'
  177. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  178. Doorkeeper::Application.send :include, ApplicationExtension
  179. Doorkeeper::AccessToken.send :include, AccessTokenExtension
  180. Devise::FailureApp.send :include, AbstractController::Callbacks
  181. Devise::FailureApp.send :include, Localized
  182. end
  183. end
  184. end