You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
3.0 KiB

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