1
0

application.rb 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/paperclip/lazy_thumbnail'
  8. require_relative '../lib/paperclip/gif_transcoder'
  9. require_relative '../lib/paperclip/video_transcoder'
  10. require_relative '../lib/mastodon/snowflake'
  11. require_relative '../lib/mastodon/version'
  12. require_relative '../lib/devise/ldap_authenticatable'
  13. Dotenv::Railtie.load
  14. Bundler.require(:pam_authentication) if ENV['PAM_ENABLED'] == 'true'
  15. require_relative '../lib/mastodon/redis_config'
  16. module Mastodon
  17. class Application < Rails::Application
  18. # Initialize configuration defaults for originally generated Rails version.
  19. config.load_defaults 5.1
  20. # Settings in config/environments/* take precedence over those specified here.
  21. # Application configuration should go into files in config/initializers
  22. # -- all .rb files in that directory are automatically loaded.
  23. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
  24. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
  25. # config.time_zone = 'Central Time (US & Canada)'
  26. # All translations from config/locales/*.rb,yml are auto loaded.
  27. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
  28. config.i18n.available_locales = [
  29. :en,
  30. :ar,
  31. :bg,
  32. :ca,
  33. :de,
  34. :eo,
  35. :es,
  36. :fa,
  37. :fi,
  38. :fr,
  39. :gl,
  40. :he,
  41. :hr,
  42. :hu,
  43. :hy,
  44. :id,
  45. :io,
  46. :it,
  47. :ja,
  48. :ko,
  49. :nl,
  50. :no,
  51. :oc,
  52. :pl,
  53. :pt,
  54. :'pt-BR',
  55. :ru,
  56. :sk,
  57. :sr,
  58. :'sr-Latn',
  59. :sv,
  60. :th,
  61. :tr,
  62. :uk,
  63. :'zh-CN',
  64. :'zh-HK',
  65. :'zh-TW',
  66. ]
  67. config.i18n.default_locale = ENV['DEFAULT_LOCALE']&.to_sym
  68. unless config.i18n.available_locales.include?(config.i18n.default_locale)
  69. config.i18n.default_locale = :en
  70. end
  71. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  72. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  73. config.active_job.queue_adapter = :sidekiq
  74. config.middleware.insert_before 0, Rack::Cors do
  75. allow do
  76. origins '*'
  77. resource '/@:username', headers: :any, methods: [:get], credentials: false
  78. resource '/api/*', headers: :any, methods: [:post, :put, :delete, :get, :patch, :options], credentials: false, expose: ['Link', 'X-RateLimit-Reset', 'X-RateLimit-Limit', 'X-RateLimit-Remaining', 'X-Request-Id']
  79. resource '/oauth/token', headers: :any, methods: [:post], credentials: false
  80. end
  81. end
  82. config.middleware.use Rack::Attack
  83. config.middleware.use Rack::Deflater
  84. config.to_prepare do
  85. Doorkeeper::AuthorizationsController.layout 'modal'
  86. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  87. Doorkeeper::Application.send :include, ApplicationExtension
  88. end
  89. end
  90. end