From 9468ebeb2e0a72771e0d05845dbd4e9a10cc19a1 Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 17 Jul 2014 08:34:30 +1000 Subject: [PATCH] CHANGE: Mini Profiler only enabled for developers in prd --- app/controllers/application_controller.rb | 2 +- config/cloud/cloud66/files/production.rb | 4 ++-- config/discourse_defaults.conf | 4 ++-- config/discourse_quickstart.conf | 4 ++-- config/environments/development.rb | 2 +- config/environments/production.rb | 4 ++-- config/environments/profile.rb | 2 +- config/initializers/06-mini_profiler.rb | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 156bde81420..1babd3edb66 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -305,7 +305,7 @@ class ApplicationController < ActionController::Base end def mini_profiler_enabled? - defined?(Rack::MiniProfiler) && current_user.try(:admin?) + defined?(Rack::MiniProfiler) && guardian.is_developer? end def authorize_mini_profiler diff --git a/config/cloud/cloud66/files/production.rb b/config/cloud/cloud66/files/production.rb index de0db349bb8..b7f03a09774 100644 --- a/config/cloud/cloud66/files/production.rb +++ b/config/cloud/cloud66/files/production.rb @@ -52,8 +52,8 @@ Discourse::Application.configure do # this setting enables rack_cache so it caches various requests in redis config.enable_rack_cache = true - # allows admins to use mini profiler - config.enable_mini_profiler = true + # allows developers to use mini profiler + config.load_mini_profiler = true # allows Cross-origin resource sharing (CORS) for API access in JavaScript (default to false for security). # See the initializer and https://github.com/cyu/rack-cors for configuration documentation. diff --git a/config/discourse_defaults.conf b/config/discourse_defaults.conf index 577ac428d0a..3678c838f39 100644 --- a/config/discourse_defaults.conf +++ b/config/discourse_defaults.conf @@ -67,8 +67,8 @@ smtp_enable_start_tls = true # to disable, set to 'none' smtp_openssl_verify_mode = -# enable MiniProfiler for administrators -enable_mini_profiler = true +# load MiniProfiler in production, to be used by developers +load_mini_profiler = true # recommended, cdn used to access assets cdn_url = diff --git a/config/discourse_quickstart.conf b/config/discourse_quickstart.conf index 00db18e7f33..f60e8232cfb 100644 --- a/config/discourse_quickstart.conf +++ b/config/discourse_quickstart.conf @@ -28,8 +28,8 @@ smtp_password = # enable TLS encryption for smtp connections smtp_enable_start_tls = true -# enable MiniProfiler for administrators, by default this is true. This shows response times in the top left for admin users only. Uncomment this line to turn this off. -# enable_mini_profiler = false +# enable MiniProfiler for developers, by default this is true. This shows response times in the top left for admin users only. Uncomment this line to turn this off. +# load_mini_profiler = false # recommended, cdn used to access assets. This can be left empty at first. cdn_url = diff --git a/config/environments/development.rb b/config/environments/development.rb index 1c33aa290d5..143e5992ebd 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -36,7 +36,7 @@ Discourse::Application.configure do BetterErrors::Middleware.allow_ip! ENV['TRUSTED_IP'] if ENV['TRUSTED_IP'] - config.enable_mini_profiler = true + config.load_mini_profiler = true require 'middleware/turbo_dev' require 'middleware/missing_avatars' diff --git a/config/environments/production.rb b/config/environments/production.rb index 5ce1abeace1..9734f9e6da7 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -50,8 +50,8 @@ Discourse::Application.configure do # this will cause all handlebars templates to be pre-compiles, making your page faster config.handlebars.precompile = true - # allows admins to use mini profiler - config.enable_mini_profiler = GlobalSetting.enable_mini_profiler + # allows developers to use mini profiler + config.load_mini_profiler = GlobalSetting.load_mini_profiler # Discourse strongly recommend you use a CDN. # For origin pull cdns all you need to do is register an account and configure diff --git a/config/environments/profile.rb b/config/environments/profile.rb index a498bcb8a71..9cc7d7e7e21 100644 --- a/config/environments/profile.rb +++ b/config/environments/profile.rb @@ -41,7 +41,7 @@ Discourse::Application.configure do config.handlebars.precompile = true # allows users to use mini profiler - config.enable_mini_profiler = false + config.load_mini_profiler = false # for profiling with perftools # config.middleware.use ::Rack::PerftoolsProfiler, default_printer: 'gif' diff --git a/config/initializers/06-mini_profiler.rb b/config/initializers/06-mini_profiler.rb index 5d486229c6b..11dc894fbf0 100644 --- a/config/initializers/06-mini_profiler.rb +++ b/config/initializers/06-mini_profiler.rb @@ -1,5 +1,5 @@ # If Mini Profiler is included via gem -if Rails.configuration.respond_to?(:enable_mini_profiler) && Rails.configuration.enable_mini_profiler +if Rails.configuration.respond_to?(:load_mini_profiler) && Rails.configuration.load_mini_profiler require 'rack-mini-profiler' require 'flamegraph' require 'memory_profiler' if RUBY_VERSION >= "2.1.0"