about summary refs log tree commit diff
path: root/app/lib/themes.rb
diff options
context:
space:
mode:
authorkibigo! <marrus-sh@users.noreply.github.com>2017-11-30 19:29:47 -0800
committerkibigo! <marrus-sh@users.noreply.github.com>2017-11-30 19:29:47 -0800
commit541fe9b110fce15c42ba15df27926552c234afd0 (patch)
treef4c0a74cb87d4d40ca44e99f1825fa9cd47edf96 /app/lib/themes.rb
parent8812bab6875024f76c59ab43d1dd3717e5e6da68 (diff)
Skins support
Diffstat (limited to 'app/lib/themes.rb')
-rw-r--r--app/lib/themes.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/app/lib/themes.rb b/app/lib/themes.rb
index 7ced9f945..0819e2c90 100644
--- a/app/lib/themes.rb
+++ b/app/lib/themes.rb
@@ -17,10 +17,31 @@ class Themes
       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
 
@@ -37,4 +58,8 @@ class Themes
   def names
     @conf.keys
   end
+
+  def skins_for(name)
+    @conf[name]['skin'].keys
+  end
 end