Browse Source

Maintenance: Repair .gitignore for generated static asset files to prevent accidential check-in.

Martin Gruner 2 years ago
parent
commit
d27272c1f9
2 changed files with 15 additions and 12 deletions
  1. 2 0
      .gitignore
  2. 13 12
      lib/static_assets.rb

+ 2 - 0
.gitignore

@@ -59,6 +59,8 @@
 
 # images
 /public/assets/images/node_modules
+# Ignore generated hashed file names.
+/public/assets/images/????????????????????????????????.*
 
 # Third-Party ------------------------------------------------------------------
 

+ 13 - 12
lib/static_assets.rb

@@ -146,18 +146,19 @@ generate filename based on Store model
 
   def self.filename(file)
     hash = Digest::MD5.hexdigest(file.content)
-    extention = ''
-    case file.preferences['Content-Type']
-    when %r{jpg|jpeg}i
-      extention = '.jpg'
-    when %r{png}i
-      extention = '.png'
-    when %r{gif}i
-      extention = '.gif'
-    when %r{svg}i
-      extention = '.svg'
-    end
-    "#{hash}#{extention}"
+    extension = case file.preferences['Content-Type']
+                when %r{jpg|jpeg}i
+                  '.jpg'
+                when %r{png}i
+                  '.png'
+                when %r{gif}i
+                  '.gif'
+                when %r{svg}i
+                  '.svg'
+                else
+                  ''
+                end
+    "#{hash}#{extension}"
   end
 
 =begin