add query parameter to temporarily disable customization
This commit is contained in:
		
							parent
							
								
									e25cf580d6
								
							
						
					
					
						commit
						e9f9d22482
					
				|  | @ -8,52 +8,56 @@ | ||||||
| **/ | **/ | ||||||
| Discourse.AdminCustomizeController = Ember.ArrayController.extend({ | Discourse.AdminCustomizeController = Ember.ArrayController.extend({ | ||||||
| 
 | 
 | ||||||
|   /** |   actions: { | ||||||
|     Create a new customization style |  | ||||||
| 
 | 
 | ||||||
|     @method newCustomization |     /** | ||||||
|   **/ |       Create a new customization style | ||||||
|   newCustomization: function() { |  | ||||||
|     var item = Discourse.SiteCustomization.create({name: I18n.t("admin.customize.new_style")}); |  | ||||||
|     this.pushObject(item); |  | ||||||
|     this.set('selectedItem', item); |  | ||||||
|   }, |  | ||||||
| 
 | 
 | ||||||
|   /** |       @method newCustomization | ||||||
|     Select a given style |     **/ | ||||||
|  |     newCustomization: function() { | ||||||
|  |       var item = Discourse.SiteCustomization.create({name: I18n.t("admin.customize.new_style")}); | ||||||
|  |       this.pushObject(item); | ||||||
|  |       this.set('selectedItem', item); | ||||||
|  |     }, | ||||||
| 
 | 
 | ||||||
|     @method selectStyle |     /** | ||||||
|     @param {Discourse.SiteCustomization} style The style we are selecting |       Select a given style | ||||||
|   **/ |  | ||||||
|   selectStyle: function(style) { |  | ||||||
|     this.set('selectedItem', style); |  | ||||||
|   }, |  | ||||||
| 
 | 
 | ||||||
|   /** |       @method selectStyle | ||||||
|     Save the current customization |       @param {Discourse.SiteCustomization} style The style we are selecting | ||||||
|  |     **/ | ||||||
|  |     selectStyle: function(style) { | ||||||
|  |       this.set('selectedItem', style); | ||||||
|  |     }, | ||||||
| 
 | 
 | ||||||
|     @method save |     /** | ||||||
|   **/ |       Save the current customization | ||||||
|   save: function() { |  | ||||||
|     this.get('selectedItem').save(); |  | ||||||
|   }, |  | ||||||
| 
 | 
 | ||||||
|   /** |       @method save | ||||||
|     Destroy the current customization |     **/ | ||||||
|  |     save: function() { | ||||||
|  |       this.get('selectedItem').save(); | ||||||
|  |     }, | ||||||
|  | 
 | ||||||
|  |     /** | ||||||
|  |       Destroy the current customization | ||||||
|  | 
 | ||||||
|  |       @method destroy | ||||||
|  |     **/ | ||||||
|  |     destroy: function() { | ||||||
|  |       var _this = this; | ||||||
|  |       return bootbox.confirm(I18n.t("admin.customize.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) { | ||||||
|  |         var selected; | ||||||
|  |         if (result) { | ||||||
|  |           selected = _this.get('selectedItem'); | ||||||
|  |           selected.destroy(); | ||||||
|  |           _this.set('selectedItem', null); | ||||||
|  |           return _this.removeObject(selected); | ||||||
|  |         } | ||||||
|  |       }); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     @method destroy |  | ||||||
|   **/ |  | ||||||
|   destroy: function() { |  | ||||||
|     var _this = this; |  | ||||||
|     return bootbox.confirm(I18n.t("admin.customize.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) { |  | ||||||
|       var selected; |  | ||||||
|       if (result) { |  | ||||||
|         selected = _this.get('selectedItem'); |  | ||||||
|         selected.destroy(); |  | ||||||
|         _this.set('selectedItem', null); |  | ||||||
|         return _this.removeObject(selected); |  | ||||||
|       } |  | ||||||
|     }); |  | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -1,5 +1,7 @@ | ||||||
| class Admin::SiteCustomizationsController < Admin::AdminController | class Admin::SiteCustomizationsController < Admin::AdminController | ||||||
| 
 | 
 | ||||||
|  |   before_filter :enable_customization | ||||||
|  | 
 | ||||||
|   def index |   def index | ||||||
|     @site_customizations = SiteCustomization.all |     @site_customizations = SiteCustomization.all | ||||||
| 
 | 
 | ||||||
|  | @ -56,4 +58,8 @@ class Admin::SiteCustomizationsController < Admin::AdminController | ||||||
|       StaffActionLogger.new(current_user).log_site_customization_change(old_record, new_params) |       StaffActionLogger.new(current_user).log_site_customization_change(old_record, new_params) | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|  |     def enable_customization | ||||||
|  |       session[:disable_customization] = false | ||||||
|  |     end | ||||||
|  | 
 | ||||||
| end | end | ||||||
|  |  | ||||||
|  | @ -27,6 +27,7 @@ class ApplicationController < ActionController::Base | ||||||
| 
 | 
 | ||||||
|   before_filter :set_mobile_view |   before_filter :set_mobile_view | ||||||
|   before_filter :inject_preview_style |   before_filter :inject_preview_style | ||||||
|  |   before_filter :disable_customization | ||||||
|   before_filter :block_if_maintenance_mode |   before_filter :block_if_maintenance_mode | ||||||
|   before_filter :authorize_mini_profiler |   before_filter :authorize_mini_profiler | ||||||
|   before_filter :store_incoming_links |   before_filter :store_incoming_links | ||||||
|  | @ -36,8 +37,10 @@ class ApplicationController < ActionController::Base | ||||||
|   before_filter :redirect_to_login_if_required |   before_filter :redirect_to_login_if_required | ||||||
| 
 | 
 | ||||||
|   rescue_from Exception do |exception| |   rescue_from Exception do |exception| | ||||||
|     unless [ ActiveRecord::RecordNotFound, ActionController::RoutingError, |     unless [ActiveRecord::RecordNotFound, | ||||||
|              ActionController::UnknownController, AbstractController::ActionNotFound].include? exception.class |             ActionController::RoutingError, | ||||||
|  |             ActionController::UnknownController, | ||||||
|  |             AbstractController::ActionNotFound].include? exception.class | ||||||
|       begin |       begin | ||||||
|         ErrorLog.report_async!(exception, self, request, current_user) |         ErrorLog.report_async!(exception, self, request, current_user) | ||||||
|       rescue |       rescue | ||||||
|  | @ -121,12 +124,15 @@ class ApplicationController < ActionController::Base | ||||||
|     session[:mobile_view] = params[:mobile_view] if params.has_key?(:mobile_view) |     session[:mobile_view] = params[:mobile_view] if params.has_key?(:mobile_view) | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|   def inject_preview_style |   def inject_preview_style | ||||||
|     style = request['preview-style'] |     style = request['preview-style'] | ||||||
|     session[:preview_style] = style if style |     session[:preview_style] = style if style | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  |   def disable_customization | ||||||
|  |     session[:disable_customization] = params[:customization] == "0" if params.has_key?(:customization) | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|   def guardian |   def guardian | ||||||
|     @guardian ||= Guardian.new(current_user) |     @guardian ||= Guardian.new(current_user) | ||||||
|   end |   end | ||||||
|  |  | ||||||
|  | @ -22,9 +22,8 @@ class SiteCustomization < ActiveRecord::Base | ||||||
|           error.gsub!("'", '\27 ') |           error.gsub!("'", '\27 ') | ||||||
| 
 | 
 | ||||||
|           self.send("#{stylesheet_attr}_baked=", |           self.send("#{stylesheet_attr}_baked=", | ||||||
|   "#main {display: none;} |   "footer { white-space: pre; } | ||||||
|   footer {white-space: pre; margin-left: 100px;} |   footer:after { content: '#{error}' }") | ||||||
|   footer:after{ content: '#{error}' }") |  | ||||||
|         end |         end | ||||||
|       end |       end | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  | @ -10,4 +10,6 @@ | ||||||
|   <%= stylesheet_link_tag "admin"%> |   <%= stylesheet_link_tag "admin"%> | ||||||
| <%-end%> | <%-end%> | ||||||
| 
 | 
 | ||||||
| <%= SiteCustomization.custom_stylesheet(session[:preview_style], mobile_view? ? :mobile : :desktop) %> | <%- unless session[:disable_customization] %> | ||||||
|  |   <%= SiteCustomization.custom_stylesheet(session[:preview_style], mobile_view? ? :mobile : :desktop) %> | ||||||
|  | <%- end %> | ||||||
|  |  | ||||||
|  | @ -31,7 +31,10 @@ | ||||||
|   <body> |   <body> | ||||||
|     <!--[if IE 9]><script type="text/javascript">ie = "new";</script><![endif]--> |     <!--[if IE 9]><script type="text/javascript">ie = "new";</script><![endif]--> | ||||||
| 
 | 
 | ||||||
|     <%= SiteCustomization.custom_header(session[:preview_style], mobile_view? ? :mobile : :desktop) %> |     <%- unless session[:disable_customization] %> | ||||||
|  |       <%= SiteCustomization.custom_header(session[:preview_style], mobile_view? ? :mobile : :desktop) %> | ||||||
|  |     <%- end %> | ||||||
|  | 
 | ||||||
|     <section id='main'> |     <section id='main'> | ||||||
|     </section> |     </section> | ||||||
| 
 | 
 | ||||||
|  | @ -57,6 +60,7 @@ | ||||||
|     <footer id='bottom'></footer> |     <footer id='bottom'></footer> | ||||||
| 
 | 
 | ||||||
|     <%= render :partial => "common/discourse_javascript" %> |     <%= render :partial => "common/discourse_javascript" %> | ||||||
|  | 
 | ||||||
|     <%= render_google_analytics_code %> |     <%= render_google_analytics_code %> | ||||||
| 
 | 
 | ||||||
|     <noscript data-path="<%= request.env['PATH_INFO'] %>"> |     <noscript data-path="<%= request.env['PATH_INFO'] %>"> | ||||||
|  |  | ||||||
|  | @ -7,33 +7,30 @@ | ||||||
|     <meta content="" name="description"> |     <meta content="" name="description"> | ||||||
|     <meta content="" name="author"> |     <meta content="" name="author"> | ||||||
|     <link rel="icon" type="image/png" href=<%=SiteSetting.favicon_url%>> |     <link rel="icon" type="image/png" href=<%=SiteSetting.favicon_url%>> | ||||||
| 
 |  | ||||||
|     <%= render :partial => "common/special_font_face" %> |     <%= render :partial => "common/special_font_face" %> | ||||||
|     <%= render :partial => "common/discourse_stylesheet" %> |     <%= render :partial => "common/discourse_stylesheet" %> | ||||||
| 
 |  | ||||||
|     <%= discourse_csrf_tags %> |     <%= discourse_csrf_tags %> | ||||||
|   </head> |   </head> | ||||||
| 
 |  | ||||||
|   <body> |   <body> | ||||||
| 
 |     <%- unless session[:disable_customization] %> | ||||||
|     <%=SiteCustomization.custom_header(session[:preview_style])%> |       <%= SiteCustomization.custom_header(session[:preview_style]) %> | ||||||
|  |     <%- end %> | ||||||
|     <section id='main'> |     <section id='main'> | ||||||
|     <header class="d-header"> |       <header class="d-header"> | ||||||
|       <div class="container"> |         <div class="container"> | ||||||
|         <div class="contents"> |           <div class="contents"> | ||||||
|           <div class="row"> |             <div class="row"> | ||||||
|             <div class="title span13"> |               <div class="title span13"> | ||||||
|               <a href="/"><img src="<%=SiteSetting.logo_url%>" alt="<%=SiteSetting.title%>" id="site-logo"></a> |                 <a href="/"><img src="<%=SiteSetting.logo_url%>" alt="<%=SiteSetting.title%>" id="site-logo"></a> | ||||||
|  |               </div> | ||||||
|             </div> |             </div> | ||||||
|           </div> |           </div> | ||||||
|         </div> |         </div> | ||||||
|  |       </header> | ||||||
|  |       <div id="main-outlet" class="container"> | ||||||
|  |         <%= yield %> | ||||||
|       </div> |       </div> | ||||||
|     </header> |  | ||||||
|     <div id="main-outlet" class="container"> |  | ||||||
|       <%= yield %> |  | ||||||
|     </div> |  | ||||||
|     </section> |     </section> | ||||||
| 
 |  | ||||||
|     <footer id='bottom'> |     <footer id='bottom'> | ||||||
|     </footer> |     </footer> | ||||||
|   </body> |   </body> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue