]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
If a theme server is being used, do not minify theme CSS (as doing so could cause...
authorCraig Andrews <candrews@integralblue.com>
Sat, 5 Dec 2009 04:17:46 +0000 (23:17 -0500)
committerCraig Andrews <candrews@integralblue.com>
Sat, 5 Dec 2009 04:17:46 +0000 (23:17 -0500)
plugins/Minify/MinifyPlugin.php
plugins/Minify/README

index 4d37fbc708d354ca0b088bb06fd6dde1662b53db..77fd76a84963330437835f60d30d3e8f6329f736 100644 (file)
@@ -79,23 +79,33 @@ class MinifyPlugin extends Plugin
         $url = parse_url($src);
         if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
         {
-            $src = common_path('main/min?f='.$src.'&v=' . STATUSNET_VERSION);
+            $src = $this->minifyUrl($src);
         }
     }
 
     function onStartCssLinkElement($action,&$src,&$theme,&$media) {
+        $allowThemeMinification =
+            is_null(common_config('theme', 'dir'))
+            && is_null(common_config('theme', 'path'))
+            && is_null(common_config('theme', 'server'));
         $url = parse_url($src);
         if( empty($url->scheme) && empty($url->host) && empty($url->query) && empty($url->fragment))
         {
-            if(file_exists(Theme::file($src,$theme))){
-                //src is a relative path, so we can do minification
-                if(isset($theme)) {
-                    $src = common_path('main/min?f=theme/'.$theme.'/'.$src.'&v=' . STATUSNET_VERSION);
-                } else {
-                    $src = common_path('main/min?f=theme/default/'.$src.'&v=' . STATUSNET_VERSION);
-                }
+            if(!isset($theme)) {
+                $theme = common_config('site', 'theme');
+            }
+            if($allowThemeMinification && file_exists(INSTALLDIR.'/local/theme/'.$theme.'/'.$src)) {
+                $src = $this->minifyUrl('local/theme/'.$theme.'/'.$src);
+            } else if($allowThemeMinification && file_exists(INSTALLDIR.'/theme/'.$theme.'/'.$src)) {
+                $src = $this->minifyUrl('theme/'.$theme.'/'.$src);
+            }else if(file_exists(INSTALLDIR.'/'.$src)){
+                $src = $this->minifyUrl($src);
             }
         }
     }
+
+    function minifyUrl($src) {
+        return common_local_url('minify',null,array('f' => $src ,v => STATUSNET_VERSION));
+    }
 }
 
index 7fb7e239a31ccd12b0ab19b8606e97b1ba3b7b2a..8f2eefa2c7d0800f4e4829889dea4dc36919cef0 100644 (file)
@@ -1,7 +1,8 @@
 The Minify plugin minifies your CSS and Javascript, removing whitespace and comments.
 
-Note that if enabled this plugin and use a theme server
-    ($config['theme']['server']), your theme server will not be used.
+Note that if enabled this plugin and use a theme server,
+    (if any of $config['theme']['server'], $config['theme']['path'],
+    $config['theme']['dir'] are set) theme CSS will not be minified.
 
 Installation
 ============