mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
move SiteText.{head,bottom} to SiteCustomization and remove redundant SiteText.top
This commit is contained in:
@@ -77,14 +77,11 @@ class SiteCustomization < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def self.custom_header(preview_style=nil, target=:desktop)
|
||||
preview_style ||= ENABLED_KEY
|
||||
lookup_field(preview_style, target, :header)
|
||||
end
|
||||
|
||||
def self.custom_footer(preview_style=nil, target=:dekstop)
|
||||
preview_style ||= ENABLED_KEY
|
||||
lookup_field(preview_style,target,:footer)
|
||||
%i{header footer head_tag body_tag}.each do |name|
|
||||
define_singleton_method("custom_#{name}") do |preview_style=nil, target=:desktop|
|
||||
preview_style ||= ENABLED_KEY
|
||||
lookup_field(preview_style, target, name)
|
||||
end
|
||||
end
|
||||
|
||||
def self.lookup_field(key, target, field)
|
||||
@@ -95,20 +92,18 @@ class SiteCustomization < ActiveRecord::Base
|
||||
lookup = @cache[cache_key]
|
||||
return lookup.html_safe if lookup
|
||||
|
||||
styles =
|
||||
if key == ENABLED_KEY
|
||||
order(:name).where(enabled:true).to_a
|
||||
else
|
||||
[find_by(key: key)].compact
|
||||
end
|
||||
styles = if key == ENABLED_KEY
|
||||
order(:name).where(enabled:true).to_a
|
||||
else
|
||||
[find_by(key: key)].compact
|
||||
end
|
||||
|
||||
val =
|
||||
if styles.present?
|
||||
styles.map do |style|
|
||||
lookup = target == :mobile ? "mobile_#{field}" : field
|
||||
style.send(lookup)
|
||||
end.compact.join("\n")
|
||||
end
|
||||
val = if styles.present?
|
||||
styles.map do |style|
|
||||
lookup = target == :mobile ? "mobile_#{field}" : field
|
||||
style.send(lookup)
|
||||
end.compact.join("\n")
|
||||
end
|
||||
|
||||
(@cache[cache_key] = val || "").html_safe
|
||||
end
|
||||
|
||||
@@ -25,9 +25,6 @@ class SiteText < ActiveRecord::Base
|
||||
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 :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
|
||||
@site_text_type ||= SiteText.find_text_type(text_type)
|
||||
|
||||
Reference in New Issue
Block a user