NobGit
public nobgit read

NobMail

Based on mailcow: dockerized

Languages

Repository composition by tracked source files.

PHP
PHP 49% JavaScript 35% HTML 9% CSS 4% Shell 2% Python 1% Lua 0% Perl 0% Ruby 0% SCSS 0%
Create file Wiki Documentation
Clone
https://nobgit.com/orgs/nobgit/nobmail.git
ssh://[email protected]:2222/orgs/nobgit/nobmail.git

Commit

cleanup cached js and css

74244c7d
tinect <[email protected]> 7 years ago
data/web/inc/footer.inc.php    |  1 +
 data/web/inc/functions.inc.php | 18 ++++++++++++++++++
 data/web/inc/header.inc.php    |  1 +
 3 files changed, 20 insertions(+)

Diff

diff --git a/data/web/inc/footer.inc.php b/data/web/inc/footer.inc.php
index ae8c80c4..9b36e64e 100644
--- a/data/web/inc/footer.inc.php
+++ b/data/web/inc/footer.inc.php
@@ -9,6 +9,7 @@ logger();
         echo file_get_contents($JSPath);
     } else {
         echo $js_minifier->minify($JSPath);
+        cleanupCSS($css_minifier->getDataHash());
     }
     ?></script>
 <script>
diff --git a/data/web/inc/functions.inc.php b/data/web/inc/functions.inc.php
index dff9bdda..28831272 100644
--- a/data/web/inc/functions.inc.php
+++ b/data/web/inc/functions.inc.php
@@ -1612,4 +1612,22 @@ function solr_status() {
   }
   return false;
 }
+
+function cleanupJS($ignore = '', $folder = '/tmp/*.js') {
+    foreach (glob($folder) as $filename) {
+        if(strpos($filename, $ignore) !== false) {
+            continue;
+        }
+        unlink($filename);
+    }
+}
+
+function cleanupCSS($ignore = '', $folder = '/tmp/*.css') {
+    foreach (glob($folder) as $filename) {
+        if(strpos($filename, $ignore) !== false) {
+            continue;
+        }
+        unlink($filename);
+    }
+}
 ?>
diff --git a/data/web/inc/header.inc.php b/data/web/inc/header.inc.php
index 1ddfa74c..1663413f 100644
--- a/data/web/inc/header.inc.php
+++ b/data/web/inc/header.inc.php
@@ -36,6 +36,7 @@
           echo file_get_contents($CSSPath);
       } else {
           echo $css_minifier->minify($CSSPath);
+          cleanupCSS($css_minifier->getDataHash());
       }
       ?></style>
   <?php if (strtolower(trim($DEFAULT_THEME)) != "lumen"): ?>