Revert "move SiteText.{head,bottom} to SiteCustomization and remove redundant SiteText.top"
This reverts commit 6ee2849df6
.
This commit is contained in:
parent
962eb78104
commit
f3b72f5d96
|
@ -7,12 +7,7 @@
|
||||||
@module Discourse
|
@module Discourse
|
||||||
**/
|
**/
|
||||||
Discourse.SiteCustomization = Discourse.Model.extend({
|
Discourse.SiteCustomization = Discourse.Model.extend({
|
||||||
trackedProperties: [
|
trackedProperties: ['enabled', 'name', 'stylesheet', 'header', 'footer', 'mobile_stylesheet', 'mobile_header', 'mobile_footer'],
|
||||||
'enabled', 'name',
|
|
||||||
'stylesheet', 'header', 'footer',
|
|
||||||
'mobile_stylesheet', 'mobile_header', 'mobile_footer',
|
|
||||||
'head_tag', 'body_tag'
|
|
||||||
],
|
|
||||||
|
|
||||||
description: function() {
|
description: function() {
|
||||||
return "" + this.name + (this.enabled ? ' (*)' : '');
|
return "" + this.name + (this.enabled ? ' (*)' : '');
|
||||||
|
@ -30,10 +25,8 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||||
if (changed) { this.set('savingStatus', ''); }
|
if (changed) { this.set('savingStatus', ''); }
|
||||||
|
|
||||||
return changed;
|
return changed;
|
||||||
}.property('enabled', 'name', 'originals',
|
|
||||||
'stylesheet', 'header', 'footer',
|
}.property('enabled', 'name', 'stylesheet', 'header', 'footer', 'mobile_stylesheet', 'mobile_header', 'mobile_footer', 'originals'),
|
||||||
'mobile_stylesheet', 'mobile_header', 'mobile_footer',
|
|
||||||
'head_tag', 'body_tag'),
|
|
||||||
|
|
||||||
startTrackingChanges: function() {
|
startTrackingChanges: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
@ -50,7 +43,6 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||||
save: function() {
|
save: function() {
|
||||||
this.set('savingStatus', I18n.t('saving'));
|
this.set('savingStatus', I18n.t('saving'));
|
||||||
this.set('saving',true);
|
this.set('saving',true);
|
||||||
|
|
||||||
var data = {
|
var data = {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
enabled: this.enabled,
|
enabled: this.enabled,
|
||||||
|
@ -59,9 +51,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||||
footer: this.footer,
|
footer: this.footer,
|
||||||
mobile_stylesheet: this.mobile_stylesheet,
|
mobile_stylesheet: this.mobile_stylesheet,
|
||||||
mobile_header: this.mobile_header,
|
mobile_header: this.mobile_header,
|
||||||
mobile_footer: this.mobile_footer,
|
mobile_footer: this.mobile_footer
|
||||||
head_tag: this.head_tag,
|
|
||||||
body_tag: this.body_tag
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var siteCustomization = this;
|
var siteCustomization = this;
|
||||||
|
|
|
@ -20,8 +20,6 @@
|
||||||
<li><a {{bind-attr class="view.stylesheetActive:active"}} {{action "selectStylesheet" target="view"}}>{{i18n 'admin.customize.css'}}</a></li>
|
<li><a {{bind-attr class="view.stylesheetActive:active"}} {{action "selectStylesheet" target="view"}}>{{i18n 'admin.customize.css'}}</a></li>
|
||||||
<li><a {{bind-attr class="view.headerActive:active"}} {{action "selectHeader" target="view"}}>{{i18n 'admin.customize.header'}}</a></li>
|
<li><a {{bind-attr class="view.headerActive:active"}} {{action "selectHeader" target="view"}}>{{i18n 'admin.customize.header'}}</a></li>
|
||||||
<li><a {{bind-attr class="view.footerActive:active"}} {{action "selectFooter" target="view"}}>{{i18n 'admin.customize.footer'}}</a></li>
|
<li><a {{bind-attr class="view.footerActive:active"}} {{action "selectFooter" target="view"}}>{{i18n 'admin.customize.footer'}}</a></li>
|
||||||
<li><a {{bind-attr class="view.headTagActive:active"}} {{action "selectHeadTag" target="view"}} title="{{i18n 'admin.customize.head_tag.title'}}">{{fa-icon "file-text-o"}} {{i18n 'admin.customize.head_tag.text'}}</a></li>
|
|
||||||
<li><a {{bind-attr class="view.bodyTagActive:active"}} {{action "selectBodyTag" target="view"}} title="{{i18n 'admin.customize.body_tag.title'}}">{{fa-icon "file-text-o"}} {{i18n 'admin.customize.body_tag.text'}}</a></li>
|
|
||||||
<li><a {{bind-attr class="view.mobileStylesheetActive:active"}} {{action "selectMobileStylesheet" target="view"}}>{{fa-icon "mobile"}} {{i18n 'admin.customize.css'}}</a></li>
|
<li><a {{bind-attr class="view.mobileStylesheetActive:active"}} {{action "selectMobileStylesheet" target="view"}}>{{fa-icon "mobile"}} {{i18n 'admin.customize.css'}}</a></li>
|
||||||
<li><a {{bind-attr class="view.mobileHeaderActive:active"}} {{action "selectMobileHeader" target="view"}}>{{fa-icon "mobile"}} {{i18n 'admin.customize.header'}}</a></li>
|
<li><a {{bind-attr class="view.mobileHeaderActive:active"}} {{action "selectMobileHeader" target="view"}}>{{fa-icon "mobile"}} {{i18n 'admin.customize.header'}}</a></li>
|
||||||
<li><a {{bind-attr class="view.mobileFooterActive:active"}} {{action "selectMobileFooter" target="view"}}>{{fa-icon "mobile"}} {{i18n 'admin.customize.footer'}}</a></li>
|
<li><a {{bind-attr class="view.mobileFooterActive:active"}} {{action "selectMobileFooter" target="view"}}>{{fa-icon "mobile"}} {{i18n 'admin.customize.footer'}}</a></li>
|
||||||
|
@ -39,8 +37,6 @@
|
||||||
{{#if view.stylesheetActive}}{{aceEditor content=selectedItem.stylesheet mode="scss"}}{{/if}}
|
{{#if view.stylesheetActive}}{{aceEditor content=selectedItem.stylesheet mode="scss"}}{{/if}}
|
||||||
{{#if view.headerActive}}{{aceEditor content=selectedItem.header mode="html"}}{{/if}}
|
{{#if view.headerActive}}{{aceEditor content=selectedItem.header mode="html"}}{{/if}}
|
||||||
{{#if view.footerActive}}{{aceEditor content=selectedItem.footer mode="html"}}{{/if}}
|
{{#if view.footerActive}}{{aceEditor content=selectedItem.footer mode="html"}}{{/if}}
|
||||||
{{#if view.headTagActive}}{{aceEditor content=selectedItem.head_tag mode="html"}}{{/if}}
|
|
||||||
{{#if view.bodyTagActive}}{{aceEditor content=selectedItem.body_tag mode="html"}}{{/if}}
|
|
||||||
{{#if view.mobileStylesheetActive}}{{aceEditor content=selectedItem.mobile_stylesheet mode="scss"}}{{/if}}
|
{{#if view.mobileStylesheetActive}}{{aceEditor content=selectedItem.mobile_stylesheet mode="scss"}}{{/if}}
|
||||||
{{#if view.mobileHeaderActive}}{{aceEditor content=selectedItem.mobile_header mode="html"}}{{/if}}
|
{{#if view.mobileHeaderActive}}{{aceEditor content=selectedItem.mobile_header mode="html"}}{{/if}}
|
||||||
{{#if view.mobileFooterActive}}{{aceEditor content=selectedItem.mobile_footer mode="html"}}{{/if}}
|
{{#if view.mobileFooterActive}}{{aceEditor content=selectedItem.mobile_footer mode="html"}}{{/if}}
|
||||||
|
|
|
@ -15,8 +15,6 @@ Discourse.AdminCustomizeView = Discourse.View.extend({
|
||||||
|
|
||||||
headerActive: Em.computed.equal('selected', 'header'),
|
headerActive: Em.computed.equal('selected', 'header'),
|
||||||
footerActive: Em.computed.equal('selected', 'footer'),
|
footerActive: Em.computed.equal('selected', 'footer'),
|
||||||
headTagActive: Em.computed.equal('selected', 'head_tag'),
|
|
||||||
bodyTagActive: Em.computed.equal('selected', 'body_tag'),
|
|
||||||
stylesheetActive: Em.computed.equal('selected', 'stylesheet'),
|
stylesheetActive: Em.computed.equal('selected', 'stylesheet'),
|
||||||
mobileHeaderActive: Em.computed.equal('selected', 'mobileHeader'),
|
mobileHeaderActive: Em.computed.equal('selected', 'mobileHeader'),
|
||||||
mobileFooterActive: Em.computed.equal('selected', 'mobileFooter'),
|
mobileFooterActive: Em.computed.equal('selected', 'mobileFooter'),
|
||||||
|
@ -25,13 +23,10 @@ Discourse.AdminCustomizeView = Discourse.View.extend({
|
||||||
actions: {
|
actions: {
|
||||||
selectHeader: function() { this.set('selected', 'header'); },
|
selectHeader: function() { this.set('selected', 'header'); },
|
||||||
selectFooter: function() { this.set('selected', 'footer'); },
|
selectFooter: function() { this.set('selected', 'footer'); },
|
||||||
selectHeadTag: function() { this.set('selected', 'head_tag'); },
|
|
||||||
selectBodyTag: function() { this.set('selected', 'body_tag'); },
|
|
||||||
selectStylesheet: function() { this.set('selected', 'stylesheet'); },
|
selectStylesheet: function() { this.set('selected', 'stylesheet'); },
|
||||||
selectMobileHeader: function() { this.set('selected', 'mobileHeader'); },
|
selectMobileHeader: function() { this.set('selected', 'mobileHeader'); },
|
||||||
selectMobileFooter: function() { this.set('selected', 'mobileFooter'); },
|
selectMobileFooter: function() { this.set('selected', 'mobileFooter'); },
|
||||||
selectMobileStylesheet: function() { this.set('selected', 'mobileStylesheet'); },
|
selectMobileStylesheet: function() { this.set('selected', 'mobileStylesheet'); },
|
||||||
|
|
||||||
toggleMaximize: function() {
|
toggleMaximize: function() {
|
||||||
this.set("maximized", !this.get("maximized"));
|
this.set("maximized", !this.get("maximized"));
|
||||||
|
|
||||||
|
@ -44,16 +39,16 @@ Discourse.AdminCustomizeView = Discourse.View.extend({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
_init: function() {
|
didInsertElement: function() {
|
||||||
var controller = this.get('controller');
|
var controller = this.get('controller');
|
||||||
Mousetrap.bindGlobal('mod+s', function() {
|
Mousetrap.bindGlobal('mod+s', function() {
|
||||||
controller.send("save");
|
controller.send("save");
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}.on("didInsertElement"),
|
},
|
||||||
|
|
||||||
_cleanUp: function() {
|
willDestroyElement: function() {
|
||||||
Mousetrap.unbindGlobal('mod+s');
|
Mousetrap.unbindGlobal('mod+s');
|
||||||
}.on("willDestroyElement")
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<div class='container'>
|
<div class='container'>
|
||||||
|
{{custom-html "top"}}
|
||||||
{{global-notice}}
|
{{global-notice}}
|
||||||
{{discourse-banner user=currentUser banner=site.banner}}
|
{{discourse-banner user=currentUser banner=site.banner}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<div class='container'>
|
<div class='container'>
|
||||||
|
{{custom-html "top"}}
|
||||||
{{global-notice}}
|
{{global-notice}}
|
||||||
{{discourse-banner user=currentUser banner=site.banner overlay=view.hasScrolled hide=errorLoading}}
|
{{discourse-banner user=currentUser banner=site.banner overlay=view.hasScrolled hide=errorLoading}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<div class='container'>
|
<div class='container'>
|
||||||
|
{{custom-html "top"}}
|
||||||
{{global-notice}}
|
{{global-notice}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,6 @@ class Admin::SiteCustomizationsController < Admin::AdminController
|
||||||
params.require(:site_customization)
|
params.require(:site_customization)
|
||||||
.permit(:name, :stylesheet, :header, :footer,
|
.permit(:name, :stylesheet, :header, :footer,
|
||||||
:mobile_stylesheet, :mobile_header, :mobile_footer,
|
:mobile_stylesheet, :mobile_header, :mobile_footer,
|
||||||
:head_tag, :body_tag,
|
|
||||||
:position, :enabled, :key,
|
:position, :enabled, :key,
|
||||||
:stylesheet_baked)
|
:stylesheet_baked)
|
||||||
end
|
end
|
||||||
|
|
|
@ -274,7 +274,10 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def custom_html_json
|
def custom_html_json
|
||||||
data = { footer: SiteCustomization.custom_footer(session[:preview_style]) }
|
data = {
|
||||||
|
top: SiteText.text_for(:top),
|
||||||
|
footer: SiteCustomization.custom_footer(session[:preview_style])
|
||||||
|
}
|
||||||
|
|
||||||
if DiscoursePluginRegistry.custom_html
|
if DiscoursePluginRegistry.custom_html
|
||||||
data.merge! DiscoursePluginRegistry.custom_html
|
data.merge! DiscoursePluginRegistry.custom_html
|
||||||
|
|
|
@ -77,11 +77,14 @@ class SiteCustomization < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
%i{header footer head_tag body_tag}.each do |name|
|
def self.custom_header(preview_style=nil, target=:desktop)
|
||||||
define_singleton_method("custom_#{name}") do |preview_style=nil, target=:desktop|
|
preview_style ||= ENABLED_KEY
|
||||||
preview_style ||= ENABLED_KEY
|
lookup_field(preview_style, target, :header)
|
||||||
lookup_field(preview_style, target, name)
|
end
|
||||||
end
|
|
||||||
|
def self.custom_footer(preview_style=nil, target=:dekstop)
|
||||||
|
preview_style ||= ENABLED_KEY
|
||||||
|
lookup_field(preview_style,target,:footer)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.lookup_field(key, target, field)
|
def self.lookup_field(key, target, field)
|
||||||
|
@ -92,18 +95,20 @@ class SiteCustomization < ActiveRecord::Base
|
||||||
lookup = @cache[cache_key]
|
lookup = @cache[cache_key]
|
||||||
return lookup.html_safe if lookup
|
return lookup.html_safe if lookup
|
||||||
|
|
||||||
styles = if key == ENABLED_KEY
|
styles =
|
||||||
order(:name).where(enabled:true).to_a
|
if key == ENABLED_KEY
|
||||||
else
|
order(:name).where(enabled:true).to_a
|
||||||
[find_by(key: key)].compact
|
else
|
||||||
end
|
[find_by(key: key)].compact
|
||||||
|
end
|
||||||
|
|
||||||
val = if styles.present?
|
val =
|
||||||
styles.map do |style|
|
if styles.present?
|
||||||
lookup = target == :mobile ? "mobile_#{field}" : field
|
styles.map do |style|
|
||||||
style.send(lookup)
|
lookup = target == :mobile ? "mobile_#{field}" : field
|
||||||
end.compact.join("\n")
|
style.send(lookup)
|
||||||
end
|
end.compact.join("\n")
|
||||||
|
end
|
||||||
|
|
||||||
(@cache[cache_key] = val || "").html_safe
|
(@cache[cache_key] = val || "").html_safe
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,6 +25,9 @@ class SiteText < ActiveRecord::Base
|
||||||
add_text_type :education_new_topic, default_18n_key: 'education.new-topic'
|
add_text_type :education_new_topic, default_18n_key: 'education.new-topic'
|
||||||
add_text_type :education_new_reply, default_18n_key: 'education.new-reply'
|
add_text_type :education_new_reply, default_18n_key: 'education.new-reply'
|
||||||
add_text_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message'
|
add_text_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message'
|
||||||
|
add_text_type :top, allow_blank: true, format: :html
|
||||||
|
add_text_type :bottom, allow_blank: true, format: :html
|
||||||
|
add_text_type :head, allow_blank: true, format: :html
|
||||||
|
|
||||||
def site_text_type
|
def site_text_type
|
||||||
@site_text_type ||= SiteText.find_text_type(text_type)
|
@site_text_type ||= SiteText.find_text_type(text_type)
|
||||||
|
|
|
@ -22,9 +22,7 @@
|
||||||
<%= script "admin"%>
|
<%= script "admin"%>
|
||||||
<%- end %>
|
<%- end %>
|
||||||
|
|
||||||
<%- unless customization_disabled? %>
|
<%= raw SiteText.text_for(:head) %>
|
||||||
<%= raw SiteCustomization.custom_head_tag(session[:preview_style]) %>
|
|
||||||
<%- end %>
|
|
||||||
|
|
||||||
<%= render_google_universal_analytics_code %>
|
<%= render_google_universal_analytics_code %>
|
||||||
|
|
||||||
|
@ -89,8 +87,6 @@
|
||||||
|
|
||||||
<%= render_google_analytics_code %>
|
<%= render_google_analytics_code %>
|
||||||
|
|
||||||
<%- unless customization_disabled? %>
|
<%= raw SiteText.text_for(:bottom) %>
|
||||||
<%= raw SiteCustomization.custom_body_tag(session[:preview_style]) %>
|
|
||||||
<%- end %>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
<title><%= content_for?(:title) ? yield(:title) + ' - ' + SiteSetting.title : SiteSetting.title %></title>
|
<title><%= content_for?(:title) ? yield(:title) + ' - ' + SiteSetting.title : SiteSetting.title %></title>
|
||||||
<meta name="description" content="<%= @description_meta || SiteSetting.site_description %>">
|
<meta name="description" content="<%= @description_meta || SiteSetting.site_description %>">
|
||||||
<%= render partial: "layouts/head" %>
|
<%= render partial: "layouts/head" %>
|
||||||
<%- unless customization_disabled? %>
|
<%= raw SiteText.text_for(:head) %>
|
||||||
<%= raw SiteCustomization.custom_head_tag(session[:preview_style]) %>
|
|
||||||
<%- end %>
|
|
||||||
<%= yield :head %>
|
<%= yield :head %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
<title><%=SiteSetting.title%></title>
|
<title><%=SiteSetting.title%></title>
|
||||||
<meta name="description" content="">
|
<meta name="description" content="">
|
||||||
<%= render partial: "layouts/head" %>
|
<%= render partial: "layouts/head" %>
|
||||||
<%- unless customization_disabled? %>
|
<%= raw SiteText.text_for(:head) %>
|
||||||
<%= raw SiteCustomization.custom_head_tag(session[:preview_style]) %>
|
|
||||||
<%- end %>
|
|
||||||
<%= yield(:no_js_head) %>
|
<%= yield(:no_js_head) %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
@ -1716,12 +1716,6 @@ en:
|
||||||
css: "CSS"
|
css: "CSS"
|
||||||
header: "Header"
|
header: "Header"
|
||||||
footer: "Footer"
|
footer: "Footer"
|
||||||
head_tag:
|
|
||||||
text: "</head>"
|
|
||||||
title: "HTML that will be inserted before the </head> tag"
|
|
||||||
body_tag:
|
|
||||||
text: "</body>"
|
|
||||||
title: "HTML that will be inserted before the </body> tag"
|
|
||||||
override_default: "Do not include standard style sheet"
|
override_default: "Do not include standard style sheet"
|
||||||
enabled: "Enabled?"
|
enabled: "Enabled?"
|
||||||
preview: "preview"
|
preview: "preview"
|
||||||
|
|
Loading…
Reference in New Issue