|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +Discourse::Application.configure do |
| 4 | + # Settings specified here will take precedence over those in config/application.rb |
| 5 | + |
| 6 | + # In the development environment your application's code is reloaded on |
| 7 | + # every request. This slows down response time but is perfect for development |
| 8 | + # since you don't have to restart the web server when you make code changes. |
| 9 | + config.cache_classes = false |
| 10 | + config.file_watcher = ActiveSupport::EventedFileUpdateChecker |
| 11 | + |
| 12 | + config.eager_load = ENV["DISCOURSE_ZEITWERK_EAGER_LOAD"] == "1" |
| 13 | + |
| 14 | + # Use the schema_cache.yml file generated during db:migrate (via db:schema:cache:dump) |
| 15 | + config.active_record.use_schema_cache_dump = true |
| 16 | + |
| 17 | + # Show full error reports and disable caching |
| 18 | + config.consider_all_requests_local = true |
| 19 | + config.action_controller.perform_caching = false |
| 20 | + |
| 21 | + config.action_controller.asset_host = GlobalSetting.cdn_url |
| 22 | + |
| 23 | + # Print deprecation notices to the Rails logger |
| 24 | + config.active_support.deprecation = :log |
| 25 | + |
| 26 | + # Do not compress assets |
| 27 | + config.assets.compress = false |
| 28 | + |
| 29 | + # Don't Digest assets, makes debugging uglier |
| 30 | + config.assets.digest = false |
| 31 | + |
| 32 | + config.assets.debug = false |
| 33 | + |
| 34 | + config.public_file_server.headers = { "Access-Control-Allow-Origin" => "*" } |
| 35 | + |
| 36 | + # Raise an error on page load if there are pending migrations |
| 37 | + config.active_record.migration_error = :page_load |
| 38 | + config.watchable_dirs["lib"] = [:rb] |
| 39 | + |
| 40 | + # we recommend you use mailhog https://github.com/mailhog/MailHog |
| 41 | + config.action_mailer.smtp_settings = { address: "localhost", port: 1025 } |
| 42 | + |
| 43 | + config.action_mailer.raise_delivery_errors = true |
| 44 | + |
| 45 | + config.log_level = ENV["DISCOURSE_DEV_LOG_LEVEL"] if ENV["DISCOURSE_DEV_LOG_LEVEL"] |
| 46 | + |
| 47 | + config.active_record.logger = nil if ENV["RAILS_DISABLE_ACTIVERECORD_LOGS"] == "1" || |
| 48 | + ENV["ENABLE_LOGSTASH_LOGGER"] == "1" |
| 49 | + config.active_record.verbose_query_logs = true if ENV["RAILS_VERBOSE_QUERY_LOGS"] == "1" |
| 50 | + |
| 51 | + if defined?(BetterErrors) |
| 52 | + BetterErrors::Middleware.allow_ip! ENV["TRUSTED_IP"] if ENV["TRUSTED_IP"] |
| 53 | + |
| 54 | + if defined?(Unicorn) && ENV["UNICORN_WORKERS"].to_i != 1 |
| 55 | + # BetterErrors doesn't work with multiple unicorn workers. Disable it to avoid confusion |
| 56 | + Rails.configuration.middleware.delete BetterErrors::Middleware |
| 57 | + end |
| 58 | + end |
| 59 | + |
| 60 | + config.load_mini_profiler = true if !ENV["DISABLE_MINI_PROFILER"] |
| 61 | + |
| 62 | + if hosts = ENV["DISCOURSE_DEV_HOSTS"] |
| 63 | + Discourse.deprecate("DISCOURSE_DEV_HOSTS is deprecated. Use RAILS_DEVELOPMENT_HOSTS instead.") |
| 64 | + config.hosts.concat(hosts.split(",")) |
| 65 | + end |
| 66 | + |
| 67 | + require "middleware/turbo_dev" |
| 68 | + config.middleware.insert 0, Middleware::TurboDev |
| 69 | + require "middleware/missing_avatars" |
| 70 | + config.middleware.insert 1, Middleware::MissingAvatars |
| 71 | + |
| 72 | + config.enable_anon_caching = false |
| 73 | + require "rbtrace" if RUBY_ENGINE == "ruby" |
| 74 | + |
| 75 | + if emails = GlobalSetting.developer_emails |
| 76 | + config.developer_emails = emails.split(",").map(&:downcase).map(&:strip) |
| 77 | + end |
| 78 | + |
| 79 | + if ENV["DISCOURSE_SKIP_CSS_WATCHER"] != "1" && |
| 80 | + (defined?(Rails::Server) || defined?(Puma) || defined?(Unicorn)) |
| 81 | + require "stylesheet/watcher" |
| 82 | + STDERR.puts "Starting CSS change watcher" |
| 83 | + @watcher = Stylesheet::Watcher.watch |
| 84 | + end |
| 85 | + |
| 86 | + config.after_initialize do |
| 87 | + config.colorize_logging = true if ENV["RAILS_COLORIZE_LOGGING"] == "1" |
| 88 | + |
| 89 | + if ENV["RAILS_VERBOSE_QUERY_LOGS"] == "1" |
| 90 | + ActiveRecord::LogSubscriber.backtrace_cleaner.add_silencer do |line| |
| 91 | + line =~ %r{lib/freedom_patches} |
| 92 | + end |
| 93 | + end |
| 94 | + |
| 95 | + if ENV["BULLET"] |
| 96 | + Bullet.enable = true |
| 97 | + Bullet.rails_logger = true |
| 98 | + end |
| 99 | + end |
| 100 | + |
| 101 | + config.hosts << /\A(([a-z0-9-]+)\.)*localhost(\:\d+)?\Z/ |
| 102 | + |
| 103 | + config.generators.after_generate do |files| |
| 104 | + parsable_files = files.filter { |file| file.end_with?(".rb") } |
| 105 | + unless parsable_files.empty? |
| 106 | + system("bundle exec rubocop -A --fail-level=E #{parsable_files.shelljoin}", exception: true) |
| 107 | + end |
| 108 | + end |
| 109 | +end |
0 commit comments