Fixed md5 generation and added fallback for scss requests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
820e7b5aba
commit
f018bfc7de
|
@ -188,22 +188,32 @@ 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($web) );
|
$this->append( 'cssfiles', $web.'/'.$file . $this->getVersionHashSuffix($web, $file) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getVersionHashSuffix($app=false) {
|
protected function getVersionHashSuffix($path = false, $file = 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();
|
$v = \OC_App::getAppVersions();
|
||||||
$appName = end(explode('/', $app));
|
|
||||||
|
// Try the webroot path for a match
|
||||||
|
if ($path !== false && $path !== '') {
|
||||||
|
$appName = $this->getAppNamefromPath($path);
|
||||||
if(array_key_exists($appName, $v)) {
|
if(array_key_exists($appName, $v)) {
|
||||||
$appVersion = $v[$appName];
|
$appVersion = $v[$appName];
|
||||||
return '?v=' . substr(md5(implode(',', $appVersion)), 0, 8) . '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
|
return '?v=' . substr(md5($appVersion), 0, 8) . '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// fallback to the file path instead
|
||||||
|
if ($file !== false && $file !== '') {
|
||||||
|
$appName = $this->getAppNamefromPath($file);
|
||||||
|
if(array_key_exists($appName, $v)) {
|
||||||
|
$appVersion = $v[$appName];
|
||||||
|
return '?v=' . substr(md5($appVersion), 0, 8) . '-' . $this->config->getAppValue('theming', 'cachebuster', '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,6 +248,22 @@ class TemplateLayout extends \OC_Template {
|
||||||
return $locator->getResources();
|
return $locator->getResources();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $path
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
static public function getAppNamefromPath($path) {
|
||||||
|
if ($path !== '' && is_string($path)) {
|
||||||
|
$pathParts = explode('/', $path);
|
||||||
|
if ($pathParts[0] === 'css') {
|
||||||
|
// This is a scss request
|
||||||
|
return $pathParts[1];
|
||||||
|
}
|
||||||
|
return end($pathParts);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $scripts
|
* @param array $scripts
|
||||||
* @return array
|
* @return array
|
||||||
|
|
Loading…
Reference in New Issue