Author: rande
Date: 2010-03-21 23:34:03 +0100 (Sun, 21 Mar 2010)
New Revision: 28656
Added:
plugins/swCombinePlugin/trunk/config/swCombinePluginConfiguration.class.php
plugins/swCombinePlugin/trunk/lib/helper/
plugins/swCombinePlugin/trunk/lib/helper/swCombineHelper.php
Removed:
plugins/swCombinePlugin/trunk/config/core_compile.yml
Modified:
plugins/swCombinePlugin/trunk/README
plugins/swCombinePlugin/trunk/lib/combine/swCombineJavascript.class.php
plugins/swCombinePlugin/trunk/lib/combine/swCombineStylesheet.class.php
plugins/swCombinePlugin/trunk/lib/config/swCombineViewConfigHandler.class.php
Log:
[swCombinePlugin] add version management, add more note
Modified: plugins/swCombinePlugin/trunk/README
===================================================================
--- plugins/swCombinePlugin/trunk/README 2010-03-21 21:35:18 UTC (rev
28655)
+++ plugins/swCombinePlugin/trunk/README 2010-03-21 22:34:03 UTC (rev
28656)
@@ -36,19 +36,29 @@
));
}
}
+
+ * edit your app.yml file and add an optional version value
+ [yaml]
+ swToolbox:
+ swCombine:
+ # the version number can be used to force load of new files from
the media server
+ # you can configure a never ending expired time on your media
server
+ # if the version is never updated, media will be never reloaded
...
+ version: 3
+
* add a config_handlers.yml inside APP/config
[yaml]
modules/*/config/view.yml:
- class: swCombineViewConfigHandler
+ # put sfViewConfigHandler to restore the default symfony config
handler
+ # class: sfViewConfigHandler
+ class: swCombineViewConfigHandler
param:
- enabled: true
private_path: %SF_WEB_DIR%/sw-combine
public_path: /sw-combine
configuration:
javascript:
- enabled: true
combine: swCombineJavascript
driver: swDriverJSMinPlus
filename: %s.js # %s will by replace by
the combined name
@@ -76,7 +86,6 @@
stylesheet:
- enabled: true
combine: swCombineStylesheet
driver: swDriverCssmin
filename: %s.css # %s will by replace by
the combined name
Deleted: plugins/swCombinePlugin/trunk/config/core_compile.yml
===================================================================
--- plugins/swCombinePlugin/trunk/config/core_compile.yml 2010-03-21
21:35:18 UTC (rev 28655)
+++ plugins/swCombinePlugin/trunk/config/core_compile.yml 2010-03-21
22:34:03 UTC (rev 28656)
@@ -1 +0,0 @@
-#-
%SF_ROOT_DIR%/plugins/swCombinePlugin/lib/config/swCombineViewConfigHandler.class.php
\ No newline at end of file
Added:
plugins/swCombinePlugin/trunk/config/swCombinePluginConfiguration.class.php
===================================================================
--- plugins/swCombinePlugin/trunk/config/swCombinePluginConfiguration.class.php
(rev 0)
+++ plugins/swCombinePlugin/trunk/config/swCombinePluginConfiguration.class.php
2010-03-21 22:34:03 UTC (rev 28656)
@@ -0,0 +1,17 @@
+<?php
+/*
+ * This file is part of the swCombinePlugin package.
+ *
+ * (c) 2009-2010 Thomas Rabaix <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+class swCombinePluginConfiguration extends sfPluginConfiguration
+{
+ public function initialize()
+ {
+
+ }
+}
\ No newline at end of file
Modified:
plugins/swCombinePlugin/trunk/lib/combine/swCombineJavascript.class.php
===================================================================
--- plugins/swCombinePlugin/trunk/lib/combine/swCombineJavascript.class.php
2010-03-21 21:35:18 UTC (rev 28655)
+++ plugins/swCombinePlugin/trunk/lib/combine/swCombineJavascript.class.php
2010-03-21 22:34:03 UTC (rev 28656)
@@ -23,10 +23,8 @@
$this->path_pos = -1;
$this->paths = array();
- // echo `cat $asset`;
$contents = @file_get_contents($asset);
-
if(!$contents)
{
throw new Exception('unable to read the asset : '.$asset);
Modified:
plugins/swCombinePlugin/trunk/lib/combine/swCombineStylesheet.class.php
===================================================================
--- plugins/swCombinePlugin/trunk/lib/combine/swCombineStylesheet.class.php
2010-03-21 21:35:18 UTC (rev 28655)
+++ plugins/swCombinePlugin/trunk/lib/combine/swCombineStylesheet.class.php
2010-03-21 22:34:03 UTC (rev 28656)
@@ -42,7 +42,7 @@
// get the version, otherwise set to the current time
// so each time the cache is cleared then the image are reload from the
webserver
- $version = sfConfig::get('app_sfCombinePlugin_asset_version',
strtotime('now'));
+ $version = sfConfig::get('app_swCombine_asset_version', strtotime('now'));
$pattern = '/url\(("|\'|)(.*)("|\'|)\)/smU';
$replacement = "url(\${2}?${version})";
Modified:
plugins/swCombinePlugin/trunk/lib/config/swCombineViewConfigHandler.class.php
===================================================================
---
plugins/swCombinePlugin/trunk/lib/config/swCombineViewConfigHandler.class.php
2010-03-21 21:35:18 UTC (rev 28655)
+++
plugins/swCombinePlugin/trunk/lib/config/swCombineViewConfigHandler.class.php
2010-03-21 22:34:03 UTC (rev 28656)
@@ -26,10 +26,11 @@
*/
protected function addHtmlAsset($viewName = '')
{
+
// Merge the current view's stylesheets with the app's default stylesheets
$stylesheets = $this->mergeConfigValue('stylesheets', $viewName);
$stylesheets = $this->combineValues('stylesheet', $stylesheets, $viewName);
-
+
$css = $this->addAssets('Stylesheet', $stylesheets);
// Merge the current view's javascripts with the app's default javascripts
@@ -144,7 +145,6 @@
public function getCombinedName($type, array $assets)
{
- // TODO : add the media revision number in the hash
$format =
$this->getParameterHolder()->get('configuration['.$type.'][filename]', '%s');
// make sure we have a flat list
@@ -160,16 +160,18 @@
$assets = array_unique($assets);
sort($assets);
- return sprintf($format, md5(serialize($assets)));
+ // compute the name
+ $name = md5(serialize($assets));
+
+ return sprintf($format, $name);
}
public function getPackageName($type, $name)
{
- // TODO : add the media revision number in the hash
- $format =
$this->getParameterHolder()->get('configuration['.$type.'][filename]', '%s');
-
- // var_dump(sprintf($format,
md5(sfInflector::underscore('package_'.$type.'_'.$name)))); die();
- return sprintf($format,
md5(sfInflector::underscore('package_'.$type.'_'.$name)));
+ $format =
$this->getParameterHolder()->get('configuration['.$type.'][filename]', '%s');
+ $name = md5(sfInflector::underscore('package_'.$type.'_'.$name));
+
+ return sprintf($format, $name);
}
/**
Added: plugins/swCombinePlugin/trunk/lib/helper/swCombineHelper.php
===================================================================
--- plugins/swCombinePlugin/trunk/lib/helper/swCombineHelper.php
(rev 0)
+++ plugins/swCombinePlugin/trunk/lib/helper/swCombineHelper.php
2010-03-21 22:34:03 UTC (rev 28656)
@@ -0,0 +1,58 @@
+<?php
+/*
+ * This file is part of the swCombinePlugin package.
+ *
+ * (c) 2009-2010 Thomas Rabaix <[email protected]>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+function sw_get_javascripts()
+{
+ $params = sfConfig::get('app_swToolbox_swCombine', array('version' =>
false));
+ $version = $params['version'];
+
+ $response = sfContext::getInstance()->getResponse();
+ sfConfig::set('symfony.asset.javascripts_included', true);
+
+ $html = '';
+ foreach ($response->getJavascripts() as $file => $options)
+ {
+ $file = $version ? $file.'?v='.$version : $file;
+
+ $html .= javascript_include_tag($file, $options);
+ }
+
+ return $html;
+}
+
+function sw_get_stylesheets()
+{
+ $params = sfConfig::get('app_swToolbox_swCombine', array('version' =>
false));
+ $version = $params['version'];
+
+ $response = sfContext::getInstance()->getResponse();
+ sfConfig::set('symfony.asset.stylesheets_included', true);
+
+ $html = '';
+ foreach ($response->getStylesheets() as $file => $options)
+ {
+ $file = $version ? $file.'?v='.$version : $file;
+
+ $html .= stylesheet_tag($file, $options);
+ }
+
+ return $html;
+}
+
+function sw_include_stylesheets()
+{
+ echo sw_get_stylesheets();
+}
+
+function sw_include_javascripts()
+{
+ echo sw_get_javascripts();
+}
+
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.