Revert "move SiteText.{head,bottom} to SiteCustomization and remove redundant SiteText.top"

This reverts commit 6ee2849df64e048bce387a4a289d16c7276e770f.
This commit is contained in:
Robin Ward
2015-01-12 20:18:52 -05:00
parent 962eb78104
commit f3b72f5d96
14 changed files with 43 additions and 63 deletions

View File

@ -77,11 +77,14 @@ class SiteCustomization < ActiveRecord::Base
end
end
%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
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)
end
def self.lookup_field(key, target, field)
@ -92,18 +95,20 @@ 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