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.

112 lines
3.5 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
7 years ago
8 years ago
8 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/paperclip/audio_transcoder'
  11. require_relative '../lib/mastodon/snowflake'
  12. require_relative '../lib/mastodon/version'
  13. require_relative '../lib/devise/ldap_authenticatable'
  14. Dotenv::Railtie.load
  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. if config.i18n.available_locales.include?(config.i18n.default_locale)
  69. config.i18n.fallbacks = [:en]
  70. else
  71. config.i18n.default_locale = :en
  72. end
  73. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  74. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  75. config.active_job.queue_adapter = :sidekiq
  76. #config.middleware.insert_before 0, Rack::Cors, debug: true, logger: (-> { Rails.logger }) do
  77. config.middleware.insert_before 0, Rack::Cors do
  78. allow do
  79. origins '*'
  80. resource '/@:username', headers: :any, methods: [:get], credentials: false
  81. 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']
  82. resource '/oauth/token', headers: :any, methods: [:post], credentials: false
  83. resource '/assets/*', headers: :any, methods: [:get, :head, :options]
  84. resource '/stylesheets/*', headers: :any, methods: [:get, :head, :options]
  85. resource '/javascripts/*', headers: :any, methods: [:get, :head, :options]
  86. resource '/packs/*', headers: :any, methods: [:get, :head, :options]
  87. end
  88. end
  89. config.middleware.use Rack::Attack
  90. config.middleware.use Rack::Deflater
  91. config.to_prepare do
  92. Doorkeeper::AuthorizationsController.layout 'modal'
  93. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  94. Doorkeeper::Application.send :include, ApplicationExtension
  95. end
  96. end
  97. end