diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-27 10:21:54 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-03-28 16:11:10 +0200 |
commit | 05f76b346981ccc1b55ef5038da845100d1160b6 (patch) | |
tree | 88ca9ed90fa3c9c092c7cab512535c96b16fbba9 /lib | |
parent | f2e69bd8685dca6f8621bc9de3c1c45d491fd99f (diff) | |
download | nextcloud-server-05f76b346981ccc1b55ef5038da845100d1160b6.tar.gz nextcloud-server-05f76b346981ccc1b55ef5038da845100d1160b6.zip |
Use app version to generate scss filename
Fixed scsscacher tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index ba3c1a0ffe3..0718736c037 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -107,7 +107,7 @@ class SCSSCacher { $path = explode('/', $root . '/' . $file); $fileNameSCSS = array_pop($path); - $fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)); + $fileNameCSS = $this->prependVersionPrefix($this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)), $app); $path = implode('/', $path); $webDir = $this->getWebDir($path, $app, $this->serverRoot, \OC::$WEBROOT); @@ -133,7 +133,8 @@ class SCSSCacher { */ public function getCachedCSS($appName, $fileName) { $folder = $this->appData->getFolder($appName); - return $folder->getFile($this->prependBaseurlPrefix($fileName)); + $cachedFileName = $this->prependVersionPrefix($this->prependBaseurlPrefix($fileName), $appName); + return $folder->getFile($cachedFileName); } /** @@ -314,19 +315,34 @@ class SCSSCacher { public function getCachedSCSS($appName, $fileName) { $tmpfileLoc = explode('/', $fileName); $fileName = array_pop($tmpfileLoc); - $fileName = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileName)); + $fileName = $this->prependVersionPrefix($this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileName)), $appName); - return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $fileName, 'appName' => $appName)), strlen(\OC::$WEBROOT) + 1); + return substr($this->urlGenerator->linkToRoute('core.Css.getCss', ['fileName' => $fileName, 'appName' => $appName]), strlen(\OC::$WEBROOT) + 1); } /** * Prepend hashed base url to the css file - * @param $cssFile + * @param string $cssFile * @return string */ private function prependBaseurlPrefix($cssFile) { $frontendController = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); - return substr(md5($this->urlGenerator->getBaseUrl() . $frontendController), 0, 8) . '-' . $cssFile; + return substr(md5($this->urlGenerator->getBaseUrl() . $frontendController), 0, 4) . '-' . $cssFile; + } + + /** + * Prepend hashed app version hash + * @param string $cssFile + * @param string $appId + * @return string + */ + private function prependVersionPrefix($cssFile, $appId) { + $appVersion = \OC_App::getAppVersion($appId); + if ($appVersion !== '0') { + return substr(md5($appVersion), 0, 4) . '-' . $cssFile; + } + $coreVersion = \OC_Util::getVersionString(); + return substr(md5($coreVersion), 0, 4) . '-' . $cssFile; } /** |