diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2016-11-30 16:30:04 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2017-01-06 09:42:14 +0100 |
commit | d9eaed5ffafd5252545f490401981d1e9b0fc889 (patch) | |
tree | 5e901570ee6bb8baa55bc5e6c7071a3c5341a376 | |
parent | 1e44a15dd1cba215bf10d0f73a7ef2730a77c2b0 (diff) | |
download | nextcloud-server-d9eaed5ffafd5252545f490401981d1e9b0fc889.tar.gz nextcloud-server-d9eaed5ffafd5252545f490401981d1e9b0fc889.zip |
Formatting
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
-rwxr-xr-x | lib/private/Template/CSSResourceLocator.php | 53 | ||||
-rwxr-xr-x | lib/private/Template/ResourceLocator.php | 32 | ||||
-rwxr-xr-x | lib/private/Template/SCSSCacher.php | 68 |
3 files changed, 89 insertions, 64 deletions
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index b592dd63ae1..59b49c73376 100755 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -25,25 +25,30 @@ namespace OC\Template; +use OC\SystemConfig; +use OCP\Files\IAppData; +use OCP\ILogger; +use OCP\IURLGenerator; + class CSSResourceLocator extends ResourceLocator { - /** @var \OCP\Files\IAppData */ + /** @var IAppData */ protected $appData; - /** @var \OCP\IURLGenerator */ + /** @var IURLGenerator */ protected $urlGenerator; - /** @var \OC\SystemConfig */ + /** @var SystemConfig */ protected $systemConfig; /** - * @param \OCP\ILogger $logger + * @param ILogger $logger * @param string $theme * @param array $core_map * @param array $party_map - * @param \OCP\Files\IAppData $appData - * @param \OCP\IURLGenerator $urlGenerator - * @param \OC\SystemConfig $systemConfig + * @param IAppData $appData + * @param IURLGenerator $urlGenerator + * @param SystemConfig $systemConfig */ - public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, \OC\SystemConfig $systemConfig) { + public function __construct(ILogger $logger, $theme, $core_map, $party_map, IAppData $appData, IURLGenerator $urlGenerator, SystemConfig $systemConfig) { $this->appData = $appData; $this->urlGenerator = $urlGenerator; $this->systemConfig = $systemConfig; @@ -80,4 +85,36 @@ class CSSResourceLocator extends ResourceLocator { || $this->appendIfExist($this->serverroot, $theme_dir.$style.'.css') || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$style.'.css'); } + + /** + * cache and append the scss $file if exist at $root + * + * @param string $root path to check + * @param string $file the filename + * @param \OCP\Files\IAppData $appData + * @param \OCP\IURLGenerator $urlGenerator + * @param \OC\SystemConfig $systemConfig + * @param string|null $webRoot base for path, default map $root to $webRoot + * @return bool True if the resource was found and cached, false otherwise + */ + protected function cacheAndAppendScssIfExist($root, $file, $appData, $urlGenerator, $systemConfig, $webRoot = null) { + if (is_file($root.'/'.$file)) { + $scssCache = new SCSSCacher( + $this->logger, + $root, + $file, + $appData, + $urlGenerator, + $systemConfig); + + if($scssCache->process()) { + $this->append($root, $scssCache->getCachedSCSS('core'), $webRoot, false); + return true; + } else { + $this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); + return false; + } + } + return false; + } } diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php index 07a4387df8a..420317d27ac 100755 --- a/lib/private/Template/ResourceLocator.php +++ b/lib/private/Template/ResourceLocator.php @@ -107,38 +107,6 @@ abstract class ResourceLocator { } /** - * cache and append the scss $file if exist at $root - * - * @param string $root path to check - * @param string $file the filename - * @param \OCP\Files\IAppData $appData - * @param \OCP\IURLGenerator $urlGenerator - * @param \OC\SystemConfig $systemConfig - * @param string|null $webRoot base for path, default map $root to $webRoot - * @return bool True if the resource was found and cached, false otherwise - */ - protected function cacheAndAppendScssIfExist($root, $file, $appData, $urlGenerator, $systemConfig, $webRoot = null) { - if (is_file($root.'/'.$file)) { - $scssCache = new \OC\Template\SCSSCacher( - $this->logger, - $root, - $file, - $appData, - $urlGenerator, - $systemConfig); - - if($scssCache->process()) { - $this->append($root, $scssCache->getCachedSCSS('core'), $webRoot, false); - return true; - } else { - $this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); - return false; - } - } - return false; - } - - /** * append the $file resource at $root * * @param string $root path to check diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index db08653c884..8e42c623d7e 100755 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -23,39 +23,59 @@ namespace OC\Template; use Leafo\ScssPhp\Compiler; use Leafo\ScssPhp\Exception\ParserException; +use Leafo\ScssPhp\Formatter\Crunched; +use Leafo\ScssPhp\Formatter\Expanded; use OC\Files\SimpleFS\SimpleFolder; +use OC\SystemConfig; +use OCP\Files\IAppData; use OCP\Files\NotFoundException; +use OCP\ILogger; +use OCP\IURLGenerator; class SCSSCacher { - /** - * @var string The root path to the nextcloud installation - * @var array The exploded absolute path to the file - * @var string The scss filename with extension - * @var string The css filename with extension - * @var string Absolute path to scss file location folder - * @var string Path to scss file from the root installation - * @var SimpleFolder The folder we're putting our compiled css files - */ - protected $root, $file, $fileNameSCSS, $fileNameCSS, $fileLoc, $rootCssLoc, $folder; + /** @var string The root path to the nextcloud installation */ + protected $root; - /** - * @var \OCP\ILogger - * @var \OCP\Files\IAppData - * @var \OCP\IURLGenerator - * @var \OC\SystemConfig - */ - protected $logger, $appData, $urlGenerator, $systemConfig; + /** @var array The exploded absolute path to the file */ + protected $file; + + /** @var string The scss filename with extension */ + protected $fileNameSCSS; + + /** @var string The css filename with extension */ + protected $fileNameCSS; + + /** @var string Absolute path to scss file location folder */ + protected $fileLoc; + + /** @var string Path to scss file from the root installation */ + protected $rootCssLoc; + + /** @var SimpleFolder The folder we're putting our compiled css files */ + protected $folder; + + /** @var ILogger */ + protected $logger; + + /** @var IAppData */ + protected $appData; + + /** @var IURLGenerator */ + protected $urlGenerator; + + /** @var SystemConfig */ + protected $systemConfig; /** - * @param \OCP\ILogger $logger + * @param ILogger $logger * @param string $root Root path to the nextcloud installation * @param string $file - * @param \OCP\Files\IAppData $appData - * @param \OCP\IURLGenerator $urlGenerator - * @param \OC\SystemConfig $systemConfig + * @param IAppData $appData + * @param IURLGenerator $urlGenerator + * @param SystemConfig $systemConfig */ - public function __construct(\OCP\ILogger $logger, $root, $file, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, \OC\SystemConfig $systemConfig) { + public function __construct(ILogger $logger, $root, $file, IAppData $appData, IURLGenerator $urlGenerator, SystemConfig $systemConfig) { $this->logger = $logger; $this->appData = $appData; $this->urlGenerator = $urlGenerator; @@ -122,11 +142,11 @@ class SCSSCacher { $scss->setImportPaths($this->fileLoc); if($this->systemConfig->getValue('debug')) { // Debug mode - $scss->setFormatter('Leafo\ScssPhp\Formatter\Expanded'); + $scss->setFormatter(Expanded::class); $scss->setLineNumberStyle(Compiler::LINE_COMMENTS); } else { // Compression - $scss->setFormatter('Leafo\ScssPhp\Formatter\Crunched'); + $scss->setFormatter(Crunched::class); } try { |