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.

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