mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-14 00:08:46 +00:00
Change how theme style packs are loaded
Load the `common` style pack, and then charge the style pack for the current skin, independent from any selected JS pack.
This commit is contained in:
@@ -4,7 +4,7 @@ module ThemingConcern
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def use_pack(pack_name)
|
||||
@theme = resolve_pack_with_common(Themes.instance.flavour(current_flavour), pack_name, current_skin)
|
||||
@theme = resolve_pack(Themes.instance.flavour(current_flavour), pack_name)
|
||||
end
|
||||
|
||||
private
|
||||
@@ -18,29 +18,22 @@ module ThemingConcern
|
||||
[current_user&.setting_skin, Setting.skin, 'default'].find { |skin| skins.include?(skin) }
|
||||
end
|
||||
|
||||
def valid_pack_data?(data, pack_name)
|
||||
data['pack'].is_a?(Hash) && data['pack'][pack_name].present?
|
||||
def current_theme
|
||||
# NOTE: this is slightly different from upstream, as it's a derived value used
|
||||
# for the sole purpose of pointing to the appropriate stylesheet pack
|
||||
"skins/#{current_flavour}/#{current_skin}"
|
||||
end
|
||||
|
||||
def nil_pack(data)
|
||||
{
|
||||
def resolve_pack(data, pack_name)
|
||||
pack_data = {
|
||||
flavour: data['name'],
|
||||
pack: nil,
|
||||
preload: nil,
|
||||
skin: nil,
|
||||
supported_locales: data['locales'],
|
||||
}
|
||||
end
|
||||
|
||||
def pack(data, pack_name, skin)
|
||||
pack_data = {
|
||||
flavour: data['name'],
|
||||
pack: pack_name,
|
||||
preload: nil,
|
||||
skin: nil,
|
||||
supported_locales: data['locales'],
|
||||
}
|
||||
return pack_data unless data['pack'].is_a?(Hash) && data['pack'][pack_name].present?
|
||||
|
||||
pack_data[:pack] = pack_name
|
||||
return pack_data unless data['pack'][pack_name].is_a?(Hash)
|
||||
|
||||
pack_data[:pack] = nil unless data['pack'][pack_name]['filename']
|
||||
@@ -49,22 +42,6 @@ module ThemingConcern
|
||||
pack_data[:preload] = [preloads] if preloads.is_a?(String)
|
||||
pack_data[:preload] = preloads if preloads.is_a?(Array)
|
||||
|
||||
if skin != 'default' && data['skin'][skin]
|
||||
pack_data[:skin] = skin if data['skin'][skin].include?(pack_name)
|
||||
elsif data['pack'][pack_name]['stylesheet']
|
||||
pack_data[:skin] = 'default'
|
||||
end
|
||||
|
||||
pack_data
|
||||
end
|
||||
|
||||
def resolve_pack(data, pack_name, skin)
|
||||
pack(data, pack_name, skin) if valid_pack_data?(data, pack_name)
|
||||
end
|
||||
|
||||
def resolve_pack_with_common(data, pack_name, skin = 'default')
|
||||
result = resolve_pack(data, pack_name, skin) || nil_pack(data)
|
||||
result[:common] = resolve_pack(data, 'common', skin)
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user