From 2d5f6671605d9a27c0f8947b908d14a619eedf47 Mon Sep 17 00:00:00 2001 From: riking Date: Fri, 20 Jun 2014 09:06:36 -0700 Subject: [PATCH] Make ?preview-style make sense New behavior: ?preview-style=(sha) -- see that stylesheet ?preview-style= -- see the currently selected stylesheet ?preview-style=default -- see the default stylesheet ("rescue mode") --- .../admin/templates/customize_css_html.js.handlebars | 6 ++++-- app/controllers/application_controller.rb | 8 +++++++- config/locales/client.en.yml | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/admin/templates/customize_css_html.js.handlebars b/app/assets/javascripts/admin/templates/customize_css_html.js.handlebars index 3323c13ba56..879ca8aaf87 100644 --- a/app/assets/javascripts/admin/templates/customize_css_html.js.handlebars +++ b/app/assets/javascripts/admin/templates/customize_css_html.js.handlebars @@ -51,9 +51,11 @@ {{i18n admin.customize.override_default}} {{view Ember.Checkbox checkedBinding="selectedItem.override_default_style"}} {{i18n admin.customize.enabled}} {{view Ember.Checkbox checkedBinding="selectedItem.enabled"}} {{#unless selectedItem.changed}} - {{i18n admin.customize.preview}} + {{i18n admin.customize.preview}} | - {{i18n admin.customize.undo_preview}}
+ {{i18n admin.customize.undo_preview}} + | + {{i18n admin.customize.rescue_preview}}
{{/unless}} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5a662c90e49..e73786f58ba 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -163,7 +163,13 @@ class ApplicationController < ActionController::Base def inject_preview_style style = request['preview-style'] - session[:preview_style] = style if style + if style.blank? + session[:preview_style] = nil + elsif style == "default" + session[:preview_style] = "" + else + session[:preview_style] = style + end end def disable_customization diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index a4abbb047db..22c5b5fad4c 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1505,7 +1505,11 @@ en: override_default: "Do not include standard style sheet" enabled: "Enabled?" preview: "preview" - undo_preview: "undo preview" + undo_preview: "remove preview" + rescue_preview: "default style" + explain_preview: "See the site with this custom stylesheet" + explain_undo_preview: "Go back to the currently enabled custom stylesheet" + explain_rescue_preview: "See the site with the default stylesheet" save: "Save" new: "New" new_style: "New Style"