diff options
author | Lukas Reschke <lukas@owncloud.com> | 2014-10-16 15:54:57 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@owncloud.com> | 2014-10-16 15:54:57 +0200 |
commit | a37dcf94fdc6a86faaa45a1a720b40048afbcbfa (patch) | |
tree | 3964b393535dba5e6a262b98880a22e09e0074ab | |
parent | df5b98afa85c9cd0ff9a8623608af46620215474 (diff) | |
parent | a04159090fcba6a503d749014c39b81a75dd2f7b (diff) | |
download | nextcloud-server-a37dcf94fdc6a86faaa45a1a720b40048afbcbfa.tar.gz nextcloud-server-a37dcf94fdc6a86faaa45a1a720b40048afbcbfa.zip |
Merge pull request #11591 from owncloud/addAppVersionToCSSandJS
Add app version to JS and CSS
-rw-r--r-- | lib/private/templatelayout.php | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php index e9172fd2da5..9f996e19f81 100644 --- a/lib/private/templatelayout.php +++ b/lib/private/templatelayout.php @@ -14,6 +14,8 @@ use Assetic\Filter\CssImportFilter; class OC_TemplateLayout extends OC_Template { + private static $versionHash = ''; + /** * @param string $renderas * @param string $appid application id @@ -70,26 +72,25 @@ class OC_TemplateLayout extends OC_Template { parent::__construct('core', 'layout.base'); } - $versionParameter = '?v=' . md5(implode(OC_Util::getVersion())); + if(empty(self::$versionHash)) { + self::$versionHash = md5(implode(',', OC_App::getAppVersions())); + } + $useAssetPipeline = $this->isAssetPipelineEnabled(); if ($useAssetPipeline) { - - $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter); - + $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash))); $this->generateAssets(); - } else { - // Add the js files $jsfiles = self::findJavascriptFiles(OC_Util::$scripts); $this->assign('jsfiles', array(), false); if (OC_Config::getValue('installed', false) && $renderas!='error') { - $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config') . $versionParameter); + $this->append( 'jsfiles', OC_Helper::linkToRoute('js_config', array('v' => self::$versionHash))); } foreach($jsfiles as $info) { $web = $info[1]; $file = $info[2]; - $this->append( 'jsfiles', $web.'/'.$file . $versionParameter); + $this->append( 'jsfiles', $web.'/'.$file . '?v=' . self::$versionHash); } // Add the css files @@ -99,7 +100,7 @@ class OC_TemplateLayout extends OC_Template { $web = $info[1]; $file = $info[2]; - $this->append( 'cssfiles', $web.'/'.$file . $versionParameter); + $this->append( 'cssfiles', $web.'/'.$file . '?v=' . self::$versionHash); } } } @@ -202,6 +203,8 @@ class OC_TemplateLayout extends OC_Template { }, $files); sort($files); + // include the apps' versions hash to invalidate the cached assets + $files[]= self::$versionHash; return hash('md5', implode('', $files)); } |