application.rb 2.8 KB

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