DEV: Add simple digest for core stylesheets

And move fonts + category_backgrounds to color definitions stylesheet.
This will let us use the same core + plugin stylesheets in multisite.
This commit is contained in:
Penar Musaraj
2021-06-21 13:54:42 -04:00
committed by Alan Guo Xiang Tan
parent e123476329
commit d82c58e6cc
4 changed files with 39 additions and 30 deletions

View File

@ -29,9 +29,6 @@ module Stylesheet
file += File.read path
case asset.to_s
when "desktop", "mobile"
file += importer.category_backgrounds
file += importer.font
when "embed", "publish"
file += importer.font
when "wizard"
@ -39,6 +36,8 @@ module Stylesheet
when Stylesheet::Manager::COLOR_SCHEME_STYLESHEET
file += importer.import_color_definitions
file += importer.import_wcag_overrides
file += importer.category_backgrounds
file += importer.font
end
end

View File

@ -137,6 +137,10 @@ class Stylesheet::Manager::Builder
!!(@target.to_s =~ Stylesheet::Manager::THEME_REGEX)
end
def is_color_scheme?
!!(@target.to_s == Stylesheet::Manager::COLOR_SCHEME_STYLESHEET)
end
def scheme_slug
Slug.for(ActiveSupport::Inflector.transliterate(@color_scheme.name), 'scheme')
end
@ -146,8 +150,10 @@ class Stylesheet::Manager::Builder
@digest ||= begin
if is_theme?
theme_digest
else
elsif is_color_scheme?
color_scheme_digest
else
default_digest
end
end
end
@ -171,7 +177,7 @@ class Stylesheet::Manager::Builder
end
def theme_digest
Digest::SHA1.hexdigest(scss_digest.to_s + color_scheme_digest.to_s + settings_digest + plugins_digest + uploads_digest)
Digest::SHA1.hexdigest(scss_digest.to_s + color_scheme_digest.to_s + settings_digest + uploads_digest)
end
# this protects us from situations where new versions of a plugin removed a file
@ -218,6 +224,10 @@ class Stylesheet::Manager::Builder
Digest::SHA1.hexdigest(sha1s.sort!.join("\n"))
end
def default_digest
Digest::SHA1.hexdigest "default-#{Stylesheet::Manager.last_file_updated}-#{plugins_digest}"
end
def color_scheme_digest
cs = @color_scheme || theme&.color_scheme