diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-12-27 11:01:27 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-01-03 22:04:59 +0100 |
commit | 00412d1c8ce7c699a83740d20209bd3e0bdda906 (patch) | |
tree | 243681d3b5ceafd342b9798264fd35aa6a3507dc | |
parent | f13b3b6651b81d1bd4a314ce1e66e164e9ac5f1d (diff) | |
download | nextcloud-server-00412d1c8ce7c699a83740d20209bd3e0bdda906.tar.gz nextcloud-server-00412d1c8ce7c699a83740d20209bd3e0bdda906.zip |
Fixed webroot for scss files
Fixed tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
-rw-r--r-- | lib/private/Template/CSSResourceLocator.php | 4 | ||||
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 18 | ||||
-rw-r--r-- | tests/lib/Template/SCSSCacherTest.php | 13 |
3 files changed, 19 insertions, 16 deletions
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index d5e9ce732cc..2226f4f6a39 100644 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -104,7 +104,7 @@ class CSSResourceLocator extends ResourceLocator { if($this->scssCacher !== null) { if($this->scssCacher->process($root, $file, $app)) { - $this->append($root, $this->scssCacher->getCachedSCSS($app, $file), false, true, true); + $this->append($root, $this->scssCacher->getCachedSCSS($app, $file), \OC::$WEBROOT, true, true); return true; } else { $this->logger->warning('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); @@ -141,7 +141,7 @@ class CSSResourceLocator extends ResourceLocator { } } - $this->resources[] = array($webRoot? : '/', $webRoot, $file); + $this->resources[] = array($webRoot? : \OC::$WEBROOT, $webRoot, $file); } } } diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index cfe0e60523d..9b41aae11d7 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -102,8 +102,21 @@ class SCSSCacher { $fileNameCSS = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileNameSCSS)); $path = implode('/', $path); - - $webDir = substr($path, strlen($this->serverRoot)+1); + $webDir = null; + + // Detect if path is within an app path + $app_paths = $this->config->getSystemValue('apps_paths'); + if (!empty($app_paths)) { + foreach ($app_paths as $app_path) { + if (strpos($path, $app_path["path"]) === 0) { + $webDir = $app_path["url"].str_replace($app_path["path"], '', $path); + break; + } + } + } + if (is_null($webDir)) { + $webDir = substr($path, strlen($this->serverRoot)); + } try { $folder = $this->appData->getFolder($app); @@ -294,7 +307,6 @@ class SCSSCacher { * @return string */ public function getCachedSCSS($appName, $fileName) { - //var_dump([$appName, $fileName]); $tmpfileLoc = explode('/', $fileName); $fileName = array_pop($tmpfileLoc); $fileName = $this->prependBaseurlPrefix(str_replace('.scss', '.css', $fileName)); diff --git a/tests/lib/Template/SCSSCacherTest.php b/tests/lib/Template/SCSSCacherTest.php index 345972bb1af..1df8e86f93c 100644 --- a/tests/lib/Template/SCSSCacherTest.php +++ b/tests/lib/Template/SCSSCacherTest.php @@ -352,19 +352,10 @@ class SCSSCacherTest extends \Test\TestCase { } public function testRebaseUrls() { - $webDir = 'apps/files/css'; + $webDir = '/apps/files/css'; $css = '#id { background-image: url(\'../img/image.jpg\'); }'; $actual = self::invokePrivate($this->scssCacher, 'rebaseUrls', [$css, $webDir]); - $expected = '#id { background-image: url(\'../../../apps/files/css/../img/image.jpg\'); }'; - $this->assertEquals($expected, $actual); - } - - public function testRebaseUrlsIgnoreFrontendController() { - $this->config->expects($this->once())->method('getSystemValue')->with('htaccess.IgnoreFrontController', false)->willReturn(true); - $webDir = 'apps/files/css'; - $css = '#id { background-image: url(\'../img/image.jpg\'); }'; - $actual = self::invokePrivate($this->scssCacher, 'rebaseUrls', [$css, $webDir]); - $expected = '#id { background-image: url(\'../../apps/files/css/../img/image.jpg\'); }'; + $expected = '#id { background-image: url(\'/apps/files/css/../img/image.jpg\'); }'; $this->assertEquals($expected, $actual); } |