[icinga-checkins] icinga.org: icinga-web/mfriedrich/fixes: * Added Javascript caching ( squishloader)

git at icinga.org git at icinga.org
Mon Jan 10 09:04:58 CET 2011


Module: icinga-web
Branch: mfriedrich/fixes
Commit: b2bf71cf8db2f56050a834b1cfe9eaa4ed5f8684
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=b2bf71cf8db2f56050a834b1cfe9eaa4ed5f8684

Author: Marius Hein <marius.hein at netways.de>
Date:   Wed Dec  8 14:35:39 2010 +0100

* Added Javascript caching (squishloader)
* Removed applicationState fromsquishloader

---

 .../actions/Widgets/AddHeaderDataAction.class.php  |    3 +-
 app/modules/AppKit/cache/Widgets/SquishLoader.xml  |   11 +++++++-
 app/modules/AppKit/config/module.xml               |    9 ------
 .../AppKit/models/Tasks/ClearCacheModel.class.php  |   29 +++++++++++++++++--
 .../Widgets/SquishLoaderSuccessView.class.php      |   11 +-------
 app/modules/Cronks/config/module.xml               |    2 +-
 .../Cronks/templates/System/CronkPortalSuccess.php |    2 +-
 7 files changed, 41 insertions(+), 26 deletions(-)

diff --git a/app/modules/AppKit/actions/Widgets/AddHeaderDataAction.class.php b/app/modules/AppKit/actions/Widgets/AddHeaderDataAction.class.php
index d94ad9e..28bfafe 100755
--- a/app/modules/AppKit/actions/Widgets/AddHeaderDataAction.class.php
+++ b/app/modules/AppKit/actions/Widgets/AddHeaderDataAction.class.php
@@ -24,7 +24,8 @@ class AppKit_Widgets_AddHeaderDataAction extends AppKitBaseAction {
 		
 		// Adding javascript squishloader
 		$this->setAttribute('js_files_includes', array(
-			$this->getContext()->getRouting()->gen('appkit.squishloader')
+			$this->getContext()->getRouting()->gen('appkit.squishloader'),
+			$this->getContext()->getRouting()->gen('appkit.ext.applicationState', array('cmd' => 'init'))
 		));
 		
 		return $this->getDefaultViewName();
diff --git a/app/modules/AppKit/cache/Widgets/SquishLoader.xml b/app/modules/AppKit/cache/Widgets/SquishLoader.xml
index 9c4ec84..3409d61 100644
--- a/app/modules/AppKit/cache/Widgets/SquishLoader.xml
+++ b/app/modules/AppKit/cache/Widgets/SquishLoader.xml
@@ -3,7 +3,16 @@
 	<ae:configuration>
 
 		<cachings>
-			<caching method="read" lifetime="2 hours" enabled="false">
+			<caching method="read" lifetime="4 hours" enabled="true">
+
+				<group>javascript_content</group>
+
+				<view>Success</view>
+
+				<output_type name="javascript">
+						<layer name="content" />
+				</output_type>
+				
 			</caching>
 		</cachings>
 
diff --git a/app/modules/AppKit/config/module.xml b/app/modules/AppKit/config/module.xml
index a967462..1e384d7 100755
--- a/app/modules/AppKit/config/module.xml
+++ b/app/modules/AppKit/config/module.xml
@@ -93,15 +93,6 @@
 						<ae:parameter name="action">Ext.initI18n</ae:parameter>
 						<ae:parameter name="output_type">javascript</ae:parameter>
 					</ae:parameter>
-
-					<ae:parameter>
-						<ae:parameter name="module">AppKit</ae:parameter>
-						<ae:parameter name="action">Ext.ApplicationState</ae:parameter>
-						<ae:parameter name="output_type">javascript</ae:parameter>
-						<ae:parameter name="arguments">
-							<ae:parameter name="cmd">init</ae:parameter>
-						</ae:parameter>
-					</ae:parameter>
 				</setting>
 
 <!--				<setting name="appkit_module.app.javascript_dynamic"></setting>-->
diff --git a/app/modules/AppKit/models/Tasks/ClearCacheModel.class.php b/app/modules/AppKit/models/Tasks/ClearCacheModel.class.php
index 0072a17..9ab228a 100644
--- a/app/modules/AppKit/models/Tasks/ClearCacheModel.class.php
+++ b/app/modules/AppKit/models/Tasks/ClearCacheModel.class.php
@@ -7,8 +7,8 @@ class AppKit_Tasks_ClearCacheModel extends AppKitBaseModel {
 		
 		$content_dir = $cache_dir. '/content';
 		if (is_dir($content_dir)) {
-			$this->getContext()->getLoggerManager()->log(sprintf('ClearCache: rmdir %s', $content_dir), AgaviLogger::INFO);
-			rmdir($content_dir);
+			$config_count = $this->removeFilesRecursive($content_dir);
+			$this->getContext()->getLoggerManager()->log(sprintf('ClearCache: Deleted %d cache (content) objects', $config_count), AgaviLogger::INFO);
 		}
 		
 		$iterator = new GlobIterator($cache_dir. '/config/*.php', FilesystemIterator::KEY_AS_FILENAME);
@@ -17,10 +17,33 @@ class AppKit_Tasks_ClearCacheModel extends AppKitBaseModel {
 			foreach ($iterator as $fi) {
 				unlink($fi->getRealPath());
 			}
-			$this->getContext()->getLoggerManager()->log(sprintf('ClearCache: Deleted %d cache files', $config_count), AgaviLogger::INFO);
+			$this->getContext()->getLoggerManager()->log(sprintf('ClearCache: Deleted %d cache (config) files', $config_count), AgaviLogger::INFO);
 		}
 	}
 	
+	private function removeFilesRecursive($path) {
+		$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
+		
+		$order = array ();
+		
+		foreach ($iterator as $fileObject) {
+			$order[] =$fileObject->getRealPath();
+		}
+		
+		$count = count($order);
+		
+		while(($file = array_pop($order))) {
+			if (is_dir($file)) {
+				rmdir($file);
+			}
+			elseif (is_file($file)) {
+				unlink($file);
+			}
+		}
+		
+		return $count;
+	}
+	
 }
 
 ?>
\ No newline at end of file
diff --git a/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php b/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
index b6d523b..c647537 100755
--- a/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
+++ b/app/modules/AppKit/views/Widgets/SquishLoaderSuccessView.class.php
@@ -4,16 +4,6 @@ class AppKit_Widgets_SquishLoaderSuccessView extends AppKitBaseView
 {
 	public function executeJavascript(AgaviRequestDataHolder $rd) {
 		
-		// Get the magick
-		$response = $this->getContainer()->getResponse();
-		if(AgaviConfig::get('org.icinga.appkit.include_javascript.allowcache')) {
-			$response->clearHttpHeaders();
-			$response->setHttpHeader('Expires', gmdate('D, d M Y H:i:s \G\M\T', time() + (3600*24)), true);
-			$response->setHttpHeader('Cache-Control', 'public', true);
-			$response->setHttpHeader('Age', 10, true);
-			$response->setHttpHeader('Pragma', null, true);
-		}
-
 		if ($this->getAttribute('errors', false)) {
 			return "throw '". join(", ", $this->getAttribute('errors')). "';";
 		}
@@ -25,6 +15,7 @@ class AppKit_Widgets_SquishLoaderSuccessView extends AppKitBaseView
 			$content .= $this->executeActions(
 				$this->getAttribute('javascript_actions')
 			);
+			
 			return $content;
 		}
 	}
diff --git a/app/modules/Cronks/config/module.xml b/app/modules/Cronks/config/module.xml
index c8740f2..2526c15 100755
--- a/app/modules/Cronks/config/module.xml
+++ b/app/modules/Cronks/config/module.xml
@@ -62,7 +62,7 @@
 				<!--
 					* How log we preload the portal (showing the funny throbber, idling arround)
 				-->
-				<setting name="portal.loadmasktimeout">2300</setting>
+				<setting name="portal.loadmasktimeout">1800</setting>
 
 				<!--
 					* Grid settings
diff --git a/app/modules/Cronks/templates/System/CronkPortalSuccess.php b/app/modules/Cronks/templates/System/CronkPortalSuccess.php
index 80f1956..545e397 100755
--- a/app/modules/Cronks/templates/System/CronkPortalSuccess.php
+++ b/app/modules/Cronks/templates/System/CronkPortalSuccess.php
@@ -1,7 +1,7 @@
 <script type="text/javascript">
 Cronk.util.initEnvironment('viewport-center', function() {
 
-	AppKit.pageLoadingMask(<?php echo (int)AgaviConfig::get('modules.cronks.portal.loadmasktimeout', '2500') ?>);
+	AppKit.pageLoadingMask(<?php echo (int)AgaviConfig::get('modules.cronks.portal.loadmasktimeout', '1500') ?>);
 
 	var portal = AppKit.util.Layout.addTo({
 		xtype: 'panel',





More information about the icinga-checkins mailing list