Use apps versions to generate suffix when possible

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2017-11-22 13:58:44 +01:00 committed by Morris Jobke
parent 8ed728c1a2
commit 820e7b5aba
No known key found for this signature in database
GPG Key ID: FE03C3A163FEDE68
1 changed files with 14 additions and 5 deletions

View File

@ -125,7 +125,7 @@ class TemplateLayout extends \OC_Template {
if (empty(self::$versionHash)) { if (empty(self::$versionHash)) {
$v = \OC_App::getAppVersions(); $v = \OC_App::getAppVersions();
$v['core'] = implode('.', \OCP\Util::getVersion()); $v['core'] = implode('.', \OCP\Util::getVersion());
self::$versionHash = md5(implode(',', $v)); self::$versionHash = substr(md5(implode(',', $v)), 0, 8);
} }
} else { } else {
self::$versionHash = md5('not installed'); self::$versionHash = md5('not installed');
@ -188,16 +188,25 @@ class TemplateLayout extends \OC_Template {
if (substr($file, -strlen('print.css')) === 'print.css') { if (substr($file, -strlen('print.css')) === 'print.css') {
$this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); $this->append( 'printcssfiles', $web.'/'.$file . $this->getVersionHashSuffix() );
} else { } else {
$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix() ); $this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web) );
} }
} }
} }
protected function getVersionHashSuffix() { protected function getVersionHashSuffix($app=false) {
if(\OC::$server->getConfig()->getSystemValue('debug', false)) { if (\OC::$server->getConfig()->getSystemValue('debug', false)) {
// allows chrome workspace mapping in debug mode // allows chrome workspace mapping in debug mode
return ""; return "";
} }
if ($app !== false && $app !== '') {
$v = \OC_App::getAppVersions();
$appName = end(explode('/', $app));
if(array_key_exists($appName, $v)) {
$appVersion = $v[$appName];
return '?v=' . substr(md5(implode(',', $appVersion)), 0, 8) . '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
}
}
if ($this->config->getSystemValue('installed', false) && \OC::$server->getAppManager()->isInstalled('theming')) { if ($this->config->getSystemValue('installed', false) && \OC::$server->getAppManager()->isInstalled('theming')) {
return '?v=' . self::$versionHash . '-' . $this->config->getAppValue('theming', 'cachebuster', '0'); return '?v=' . self::$versionHash . '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
} }