Merge pull request #229 from glitch-soc/glitch-theme
Advanced Next-Level Flavours And Skins For Mastodon™
This commit is contained in:
@ -7,22 +7,59 @@ class Themes
|
||||
include Singleton
|
||||
|
||||
def initialize
|
||||
|
||||
core = YAML.load_file(Rails.root.join('app', 'javascript', 'core', 'theme.yml'))
|
||||
core['pack'] = Hash.new unless core['pack']
|
||||
|
||||
result = Hash.new
|
||||
Dir.glob(Rails.root.join('app', 'javascript', 'themes', '*', 'theme.yml')) do |path|
|
||||
Dir.glob(Rails.root.join('app', 'javascript', 'flavours', '*', 'theme.yml')) do |path|
|
||||
data = YAML.load_file(path)
|
||||
name = File.basename(File.dirname(path))
|
||||
if data['pack']
|
||||
data['name'] = name
|
||||
data['skin'] = { 'default' => [] }
|
||||
result[name] = data
|
||||
end
|
||||
end
|
||||
|
||||
Dir.glob(Rails.root.join('app', 'javascript', 'skins', '*', '*')) do |path|
|
||||
ext = File.extname(path)
|
||||
skin = File.basename(path)
|
||||
name = File.basename(File.dirname(path))
|
||||
if result[name]
|
||||
if File.directory?(path)
|
||||
pack = []
|
||||
Dir.glob(File.join(path, '*.{css,scss}')) do |sheet|
|
||||
pack.push(File.basename(sheet, File.extname(sheet)))
|
||||
end
|
||||
elsif ext.match(/^\.s?css$/i)
|
||||
skin = File.basename(path, ext)
|
||||
pack = ['common']
|
||||
end
|
||||
if skin != 'default'
|
||||
result[name]['skin'][skin] = pack
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@core = core
|
||||
@conf = result
|
||||
|
||||
end
|
||||
|
||||
def get(name)
|
||||
def core
|
||||
@core
|
||||
end
|
||||
|
||||
def flavour(name)
|
||||
@conf[name]
|
||||
end
|
||||
|
||||
def names
|
||||
def flavours
|
||||
@conf.keys
|
||||
end
|
||||
|
||||
def skins_for(name)
|
||||
@conf[name]['skin'].keys
|
||||
end
|
||||
end
|
||||
|
@ -26,7 +26,8 @@ class UserSettingsDecorator
|
||||
user.settings['reduce_motion'] = reduce_motion_preference if change?('setting_reduce_motion')
|
||||
user.settings['system_font_ui'] = system_font_ui_preference if change?('setting_system_font_ui')
|
||||
user.settings['noindex'] = noindex_preference if change?('setting_noindex')
|
||||
user.settings['theme'] = theme_preference if change?('setting_theme')
|
||||
user.settings['flavour'] = flavour_preference if change?('setting_flavour')
|
||||
user.settings['skin'] = skin_preference if change?('setting_skin')
|
||||
end
|
||||
|
||||
def merged_notification_emails
|
||||
@ -73,10 +74,14 @@ class UserSettingsDecorator
|
||||
boolean_cast_setting 'setting_noindex'
|
||||
end
|
||||
|
||||
def theme_preference
|
||||
settings['setting_theme']
|
||||
def flavour_preference
|
||||
settings['setting_flavour']
|
||||
end
|
||||
|
||||
|
||||
def skin_preference
|
||||
settings['setting_skin']
|
||||
end
|
||||
|
||||
def boolean_cast_setting(key)
|
||||
settings[key] == '1'
|
||||
end
|
||||
|
Reference in New Issue
Block a user