mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 03:53:43 +08:00
64a66cf82b
- `no_custom` -> `no_themes` (history: before themes existed, we had a similar tool called 'customizations') - `only_official` -> `no_unofficial_plugins` (matches format of `no_themes` and `no_plugins`, and makes it clear that this doesn't affect themes) - `?safe_mode=no_themes%2C%no_plugins` -> `?safe_mode=no_themes,no_plugins` (the query portion of a URL does not require commas to be encoded. This is much nicer to read) - If `no_plugins` is chosen from `/safe-mode` the URL generated will omit the superfluous `no_unofficial_plugins` flag - Some tweaks to copy on `/safe-mode`
44 lines
978 B
Ruby
44 lines
978 B
Ruby
# frozen_string_literal: true
|
|
|
|
class SafeModeController < ApplicationController
|
|
layout 'no_ember'
|
|
before_action :ensure_safe_mode_enabled
|
|
before_action :force_safe_mode_for_route
|
|
|
|
skip_before_action :preload_json, :check_xhr
|
|
|
|
def index
|
|
end
|
|
|
|
def enter
|
|
safe_mode = []
|
|
|
|
safe_mode << "no_themes" if params["no_themes"] == "true"
|
|
|
|
if params["no_plugins"] == "true"
|
|
safe_mode << "no_plugins"
|
|
elsif params["no_unofficial_plugins"] == "true"
|
|
safe_mode << "no_unofficial_plugins"
|
|
end
|
|
|
|
if safe_mode.length > 0
|
|
redirect_to path("/?safe_mode=#{safe_mode.join(",")}")
|
|
else
|
|
flash[:must_select] = true
|
|
redirect_to safe_mode_path
|
|
end
|
|
end
|
|
|
|
protected
|
|
|
|
def ensure_safe_mode_enabled
|
|
raise Discourse::NotFound unless guardian.can_enable_safe_mode?
|
|
end
|
|
|
|
def force_safe_mode_for_route
|
|
request.env[ApplicationController::NO_THEMES] = true
|
|
request.env[ApplicationController::NO_PLUGINS] = true
|
|
end
|
|
|
|
end
|