mirror of
https://github.com/discourse/discourse.git
synced 2025-06-16 13:25:02 +08:00
correct theme importer to support embedded.scss
This commit is contained in:
@ -44,7 +44,16 @@ class RemoteTheme < ActiveRecord::Base
|
|||||||
|
|
||||||
Theme.targets.keys.each do |target|
|
Theme.targets.keys.each do |target|
|
||||||
Theme::ALLOWED_FIELDS.each do |field|
|
Theme::ALLOWED_FIELDS.each do |field|
|
||||||
value = importer["#{target}/#{field=="scss"?"#{target}.scss":"#{field}.html"}"]
|
lookup =
|
||||||
|
if field == "scss"
|
||||||
|
"#{target}.scss"
|
||||||
|
elsif field == "embedded_scss" && target == :common
|
||||||
|
"embedded.scss"
|
||||||
|
else
|
||||||
|
"#{field}.html"
|
||||||
|
end
|
||||||
|
|
||||||
|
value = importer["#{target}/#{lookup}"]
|
||||||
theme.set_field(target.to_sym, field, value)
|
theme.set_field(target.to_sym, field, value)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,7 +4,7 @@ require_dependency 'stylesheet/manager'
|
|||||||
|
|
||||||
class Theme < ActiveRecord::Base
|
class Theme < ActiveRecord::Base
|
||||||
|
|
||||||
ALLOWED_FIELDS = %w{scss head_tag header after_header body_tag footer}
|
ALLOWED_FIELDS = %w{scss embedded_scss head_tag header after_header body_tag footer}
|
||||||
|
|
||||||
@cache = DistributedCache.new('theme')
|
@cache = DistributedCache.new('theme')
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ describe RemoteTheme do
|
|||||||
"desktop/desktop.scss" => "body {color: red;}",
|
"desktop/desktop.scss" => "body {color: red;}",
|
||||||
"common/header.html" => "I AM HEADER",
|
"common/header.html" => "I AM HEADER",
|
||||||
"common/random.html" => "I AM SILLY",
|
"common/random.html" => "I AM SILLY",
|
||||||
|
"common/embedded.scss" => "EMBED",
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -51,12 +52,13 @@ describe RemoteTheme do
|
|||||||
expect(remote.about_url).to eq("https://www.site.com/about")
|
expect(remote.about_url).to eq("https://www.site.com/about")
|
||||||
expect(remote.license_url).to eq("https://www.site.com/license")
|
expect(remote.license_url).to eq("https://www.site.com/license")
|
||||||
|
|
||||||
expect(@theme.theme_fields.length).to eq(2)
|
expect(@theme.theme_fields.length).to eq(3)
|
||||||
|
|
||||||
mapped = Hash[*@theme.theme_fields.map{|f| ["#{f.target}-#{f.name}", f.value]}.flatten]
|
mapped = Hash[*@theme.theme_fields.map{|f| ["#{f.target}-#{f.name}", f.value]}.flatten]
|
||||||
|
|
||||||
expect(mapped["0-header"]).to eq("I AM HEADER")
|
expect(mapped["0-header"]).to eq("I AM HEADER")
|
||||||
expect(mapped["1-scss"]).to eq("body {color: red;}")
|
expect(mapped["1-scss"]).to eq("body {color: red;}")
|
||||||
|
expect(mapped["0-embedded_scss"]).to eq("EMBED")
|
||||||
|
|
||||||
expect(remote.remote_updated_at).to eq(time)
|
expect(remote.remote_updated_at).to eq(time)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user