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.

94 lines
3.0 KiB

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