diff options
author | Julius Haertl <jus@bitgrid.net> | 2017-02-17 11:45:08 +0100 |
---|---|---|
committer | Julius Härtl <jus@bitgrid.net> | 2017-03-20 12:49:05 +0100 |
commit | 2bd06e0d37c32e354d537d08a066dccc31a07fbe (patch) | |
tree | 233e5d0c7b51d2172d34f8529f236e4dbe247eb6 /lib/private/Template | |
parent | 85a5c24934d0ed4d7e2d266a18a25ba649a53d63 (diff) | |
download | nextcloud-server-2bd06e0d37c32e354d537d08a066dccc31a07fbe.tar.gz nextcloud-server-2bd06e0d37c32e354d537d08a066dccc31a07fbe.zip |
Add variables.scss and import it for each scss file
Signed-off-by: Julius Haertl <jus@bitgrid.net>
Diffstat (limited to 'lib/private/Template')
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index b55cd0b93b0..c02d2c67279 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -92,11 +92,10 @@ class SCSSCacher { $folder = $this->appData->newFolder($app); } - if($this->isCached($fileNameCSS, $fileNameSCSS, $folder, $path)) { + if($this->isCached($fileNameCSS, $fileNameSCSS, $folder, $path) && !$this->variablesChanged($fileNameCSS, $folder)) { return true; - } else { - return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); } + return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); } /** @@ -108,7 +107,7 @@ class SCSSCacher { * @return boolean */ private function isCached($fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $path) { - try{ + try { $cachedFile = $folder->getFile($fileNameCSS); if ($cachedFile->getSize() > 0) { $depFile = $folder->getFile($fileNameCSS . '.deps'); @@ -128,6 +127,27 @@ class SCSSCacher { } /** + * Check if the variables file has changed + * @param string $fileNameCSS + * @param ISimpleFolder $folder + * @return bool + */ + private function variablesChanged($fileNameCSS, ISimpleFolder $folder) { + $variablesFile = \OC::$SERVERROOT . '/core/css/variables.scss'; + try { + $cachedFile = $folder->getFile($fileNameCSS); + if ($cachedFile->getMTime() < filemtime($variablesFile) + || $cachedFile->getSize() === 0 + ) { + return true; + } + } catch (NotFoundException $e) { + return true; + } + return false; + } + + /** * Cache the file with AppData * @param string $path * @param string $fileNameCSS @@ -138,7 +158,10 @@ class SCSSCacher { */ private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) { $scss = new Compiler(); - $scss->setImportPaths($path); + $scss->setImportPaths([ + $path, + \OC::$SERVERROOT . '/core/css/', + ]); if($this->systemConfig->getValue('debug')) { // Debug mode $scss->setFormatter(Expanded::class); @@ -163,7 +186,9 @@ class SCSSCacher { // Compile try { - $compiledScss = $scss->compile('@import "'.$fileNameSCSS.'";'); + $compiledScss = $scss->compile( + '@import "variables.scss";' . + '@import "'.$fileNameSCSS.'";'); } catch(ParserException $e) { $this->logger->error($e, ['app' => 'core']); return false; |