summaryrefslogtreecommitdiffstats
path: root/lib/private/Template/CSSResourceLocator.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-03-10 19:13:44 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2017-03-10 19:13:44 +0100
commitf7ebf1d47d40f42f22356e04c53d08a350aaf2cd (patch)
treefe6950a6780ce975e913c01540e669380a4649d7 /lib/private/Template/CSSResourceLocator.php
parent3ca9d53194d2a52ea3798d447cd70ffc2e595fcf (diff)
downloadnextcloud-server-f7ebf1d47d40f42f22356e04c53d08a350aaf2cd.tar.gz
nextcloud-server-f7ebf1d47d40f42f22356e04c53d08a350aaf2cd.zip
SCSS files don't exist on the default fs so just add them to the
resource list Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Template/CSSResourceLocator.php')
-rw-r--r--lib/private/Template/CSSResourceLocator.php50
1 files changed, 49 insertions, 1 deletions
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php
index 3a474a1ecfd..5f210ef307a 100644
--- a/lib/private/Template/CSSResourceLocator.php
+++ b/lib/private/Template/CSSResourceLocator.php
@@ -88,7 +88,8 @@ class CSSResourceLocator extends ResourceLocator {
if (is_file($root.'/'.$file)) {
if($this->scssCacher !== null) {
if($this->scssCacher->process($root, $file, $app)) {
- $this->append($root, $this->scssCacher->getCachedSCSS($app, $file), false);
+
+ $this->append($root, $this->scssCacher->getCachedSCSS($app, $file), false, true, true);
return true;
} else {
$this->logger->warning('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']);
@@ -101,4 +102,51 @@ class CSSResourceLocator extends ResourceLocator {
}
return false;
}
+
+ public function append($root, $file, $webRoot = null, $throw = true, $scss = false) {
+ if (!$scss) {
+ parent::append($root, $file, $webRoot, $throw);
+ } else {
+ if (!$webRoot) {
+ $tmpRoot = $root;
+ /*
+ * traverse the potential web roots upwards in the path
+ *
+ * example:
+ * - root: /srv/www/apps/myapp
+ * - available mappings: ['/srv/www']
+ *
+ * First we check if a mapping for /srv/www/apps/myapp is available,
+ * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
+ * valid web root
+ */
+ do {
+ if (isset($this->mapping[$tmpRoot])) {
+ $webRoot = $this->mapping[$tmpRoot];
+ break;
+ }
+
+ if ($tmpRoot === '/') {
+ $webRoot = '';
+ $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
+ 'app' => 'lib',
+ 'root' => $root,
+ 'file' => $file,
+ 'webRoot' => $webRoot,
+ 'throw' => $throw ? 'true' : 'false'
+ ]);
+ break;
+ }
+ $tmpRoot = dirname($tmpRoot);
+ } while(true);
+
+ }
+
+ if ($throw && $tmpRoot === '/') {
+ throw new ResourceNotFoundException($file, $webRoot);
+ }
+
+ $this->resources[] = array($tmpRoot, $webRoot, $file);
+ }
+ }
}