about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-12-10 20:15:09 -0800
committerkibigo! <marrus-sh@users.noreply.github.com>2017-12-10 20:32:28 -0800
commitbdca1614d574a4b34633a19776446d2d8cf2d2e6 (patch)
tree39dd38bdacf2b6c25065a63cdc2940c0d71fbbaf /app/lib
parentdabf66e676c693e7e26a6035e0c6296e6804e776 (diff)
Screenshot support for themes
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/themes.rb18
1 files changed, 14 insertions, 4 deletions
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