diff options
author | Lukas Reschke <lukas@statuscode.ch> | 2017-03-20 19:49:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-20 19:49:53 +0100 |
commit | 21cf1b22e9efa17aa4b9fcd4575c891c309c30df (patch) | |
tree | ee0dff452a18a887baaed583d081cf03c2608d57 /lib | |
parent | 03a92eaf74ea3898f67a12e3c19216683abb44d8 (diff) | |
parent | a0f7d4b6888466600698a31a50a551f915c69045 (diff) | |
download | nextcloud-server-21cf1b22e9efa17aa4b9fcd4575c891c309c30df.tar.gz nextcloud-server-21cf1b22e9efa17aa4b9fcd4575c891c309c30df.zip |
Merge pull request #3530 from nextcloud/scss-variables
Implement scss variables
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Template/SCSSCacher.php | 31 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 2 |
2 files changed, 19 insertions, 14 deletions
diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index b55cd0b93b0..4f5c66f2409 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -28,7 +28,9 @@ use Leafo\ScssPhp\Formatter\Expanded; use OC\SystemConfig; use OCP\Files\IAppData; use OCP\Files\NotFoundException; +use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFolder; +use OCP\IConfig; use OCP\ILogger; use OCP\IURLGenerator; @@ -43,8 +45,8 @@ class SCSSCacher { /** @var IURLGenerator */ protected $urlGenerator; - /** @var SystemConfig */ - protected $systemConfig; + /** @var IConfig */ + protected $config; /** @var string */ protected $serverRoot; @@ -59,12 +61,12 @@ class SCSSCacher { public function __construct(ILogger $logger, IAppData $appData, IURLGenerator $urlGenerator, - SystemConfig $systemConfig, + IConfig $config, $serverRoot) { $this->logger = $logger; $this->appData = $appData; $this->urlGenerator = $urlGenerator; - $this->systemConfig = $systemConfig; + $this->config = $config; $this->serverRoot = $serverRoot; } @@ -94,9 +96,8 @@ class SCSSCacher { if($this->isCached($fileNameCSS, $fileNameSCSS, $folder, $path)) { return true; - } else { - return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); } + return $this->cache($path, $fileNameCSS, $fileNameSCSS, $folder, $webDir); } /** @@ -108,7 +109,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'); @@ -124,7 +125,6 @@ class SCSSCacher { } catch(NotFoundException $e) { return false; } - return false; } /** @@ -138,8 +138,11 @@ class SCSSCacher { */ private function cache($path, $fileNameCSS, $fileNameSCSS, ISimpleFolder $folder, $webDir) { $scss = new Compiler(); - $scss->setImportPaths($path); - if($this->systemConfig->getValue('debug')) { + $scss->setImportPaths([ + $path, + \OC::$SERVERROOT . '/core/css/', + ]); + if($this->config->getSystemValue('debug')) { // Debug mode $scss->setFormatter(Expanded::class); $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); @@ -163,7 +166,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; @@ -174,7 +179,7 @@ class SCSSCacher { $depFile->putContent(json_encode($scss->getParsedFiles())); $this->logger->debug($webDir.'/'.$fileNameSCSS.' compiled and successfully cached', ['app' => 'core']); return true; - } catch(NotFoundException $e) { + } catch(NotPermittedException $e) { return false; } } @@ -188,7 +193,7 @@ class SCSSCacher { private function rebaseUrls($css, $webDir) { $re = '/url\([\'"]([\.\w?=\/-]*)[\'"]\)/x'; // OC\Route\Router:75 - if(($this->systemConfig->getValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { + if(($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { $subst = 'url(\'../../'.$webDir.'/$1\')'; } else { $subst = 'url(\'../../../'.$webDir.'/$1\')'; diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 6d2c3b2674f..a9bfaf9a7c7 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -218,7 +218,7 @@ class TemplateLayout extends \OC_Template { \OC::$server->getLogger(), \OC::$server->getAppDataDir('css'), \OC::$server->getURLGenerator(), - \OC::$server->getSystemConfig(), + \OC::$server->getConfig(), \OC::$SERVERROOT ); } else { |