闭社主体 forked from https://github.com/tootsuite/mastodon
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.

90 lines
2.6 KiB

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