You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by ch...@apache.org on 2009/02/15 20:56:46 UTC

svn commit: r744735 - /incubator/shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php

Author: chabotc
Date: Sun Feb 15 19:56:45 2009
New Revision: 744735

URL: http://svn.apache.org/viewvc?rev=744735&view=rev
Log:
Re-enable javascript compression (it now also compresses inline and remote url content, need to make sure this doesn't destroy anything)

Modified:
    incubator/shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php

Modified: incubator/shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php?rev=744735&r1=744734&r2=744735&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/GadgetFeatureRegistry.php Sun Feb 15 19:56:45 2009
@@ -37,6 +37,7 @@
     if (!isset($this->features[$feature])) {
       throw new GadgetException("Invalid feature: ".htmlentities($feature));
     }
+    $featureName = $feature;
     $feature = $this->features[$feature];
     $filesContext = $isGadgetContext ? 'gadgetJs' : 'containerJs';
     if (!isset($feature[$filesContext])) {
@@ -44,6 +45,13 @@
       return '';
     }
     $ret = '';
+    if (Config::get('compress_javascript')) {
+      $featureCache = Config::get('feature_cache');
+      $featureCache = new $featureCache();
+      if (($featureContent = $featureCache->get(md5('features:'.$featureName.$isGadgetContext)))) {
+        return $featureContent;
+      }
+    }
     foreach ($feature[$filesContext] as $entry) {
       switch ($entry['type']) {
         case 'URL':
@@ -55,7 +63,6 @@
           break;
         case 'FILE':
           $file = $feature['basePath'] . '/' . $entry['content'];
-          // add jsmin compression here
           $ret .= file_get_contents($file). "\n";
           break;
         case 'INLINE':
@@ -63,6 +70,10 @@
           break;
       }
     }
+    if (Config::get('compress_javascript')) {
+      $ret = JsMin::minify($ret);
+      $featureCache->set(md5('features:'.$featureName.$isGadgetContext), $ret);
+    }
     return $ret;
   }