闭社主体 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.

92 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/snowflake'
  10. require_relative '../lib/mastodon/version'
  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. :gl,
  35. :he,
  36. :hr,
  37. :hu,
  38. :id,
  39. :io,
  40. :it,
  41. :ja,
  42. :ko,
  43. :nl,
  44. :no,
  45. :oc,
  46. :pl,
  47. :pt,
  48. :'pt-BR',
  49. :ru,
  50. :sv,
  51. :th,
  52. :tr,
  53. :uk,
  54. :'zh-CN',
  55. :'zh-HK',
  56. :'zh-TW',
  57. ]
  58. config.i18n.default_locale = :en
  59. # config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  60. # config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  61. config.active_job.queue_adapter = :sidekiq
  62. config.middleware.insert_before 0, Rack::Cors do
  63. allow do
  64. origins '*'
  65. resource '/@:username', headers: :any, methods: [:get], credentials: false
  66. 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']
  67. resource '/oauth/token', headers: :any, methods: [:post], credentials: false
  68. end
  69. end
  70. config.middleware.use Rack::Attack
  71. config.middleware.use Rack::Deflater
  72. config.to_prepare do
  73. Doorkeeper::AuthorizationsController.layout 'modal'
  74. Doorkeeper::AuthorizedApplicationsController.layout 'admin'
  75. Doorkeeper::Application.send :include, ApplicationExtension
  76. end
  77. end
  78. end