From bdca1614d574a4b34633a19776446d2d8cf2d2e6 Mon Sep 17 00:00:00 2001 From: kibigo! Date: Sun, 10 Dec 2017 20:15:09 -0800 Subject: Screenshot support for themes --- app/lib/themes.rb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'app/lib') diff --git a/app/lib/themes.rb b/app/lib/themes.rb index 49e9ebbc3..55824a5c4 100644 --- a/app/lib/themes.rb +++ b/app/lib/themes.rb @@ -14,17 +14,27 @@ class Themes result = Hash.new Dir.glob(Rails.root.join('app', 'javascript', 'flavours', '*', 'theme.yml')) do |path| data = YAML.load_file(path) - name = File.basename(File.dirname(path)) + dir = File.dirname(path) + name = File.basename(dir) + locales = [] + screenshots = [] if data['locales'] - locales = [] - Dir.glob(File.join(File.dirname(path), data['locales'], '*.{js,json}')) do |locale| + Dir.glob(File.join(dir, data['locales'], '*.{js,json}')) do |locale| localeName = File.basename(locale, File.extname(locale)) locales.push(localeName) unless localeName.match(/defaultMessages|whitelist|index/) end - data['locales'] = locales + end + if data['screenshot'] + if data['screenshot'].is_a? Array + screenshots = data['screenshot'] + else + screenshots.push(data['screenshot']) + end end if data['pack'] data['name'] = name + data['locales'] = locales + data['screenshot'] = screenshots data['skin'] = { 'default' => [] } result[name] = data end -- cgit