application.rb 2.5 KB

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