|
|
|
|
@ -25,33 +25,22 @@ |
|
|
|
|
|
|
|
|
|
namespace OC\Template; |
|
|
|
|
|
|
|
|
|
use OC\SystemConfig; |
|
|
|
|
use OCP\Files\IAppData; |
|
|
|
|
use OCP\ILogger; |
|
|
|
|
use OCP\IURLGenerator; |
|
|
|
|
|
|
|
|
|
class CSSResourceLocator extends ResourceLocator { |
|
|
|
|
|
|
|
|
|
/** @var IAppData */ |
|
|
|
|
protected $appData; |
|
|
|
|
/** @var IURLGenerator */ |
|
|
|
|
protected $urlGenerator; |
|
|
|
|
/** @var SystemConfig */ |
|
|
|
|
protected $systemConfig; |
|
|
|
|
/** @var SCSSCacher */ |
|
|
|
|
protected $scssCacher; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @param ILogger $logger |
|
|
|
|
* @param string $theme |
|
|
|
|
* @param array $core_map |
|
|
|
|
* @param array $party_map |
|
|
|
|
* @param IAppData $appData |
|
|
|
|
* @param IURLGenerator $urlGenerator |
|
|
|
|
* @param SystemConfig $systemConfig |
|
|
|
|
* @param SCSSCacher $scssCcacher |
|
|
|
|
*/ |
|
|
|
|
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; |
|
|
|
|
public function __construct(ILogger $logger, $theme, $core_map, $party_map, SCSSCacher $scssCacher) { |
|
|
|
|
$this->scssCacher = $scssCacher; |
|
|
|
|
|
|
|
|
|
parent::__construct($logger, $theme, $core_map, $party_map); |
|
|
|
|
} |
|
|
|
|
@ -62,8 +51,8 @@ class CSSResourceLocator extends ResourceLocator { |
|
|
|
|
public function doFind($style) { |
|
|
|
|
if (strpos($style, '3rdparty') === 0 |
|
|
|
|
&& $this->appendIfExist($this->thirdpartyroot, $style.'.css') |
|
|
|
|
|| $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $this->appData, $this->urlGenerator, $this->systemConfig) |
|
|
|
|
|| $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss', $this->appData, $this->urlGenerator, $this->systemConfig) |
|
|
|
|
|| $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss') |
|
|
|
|
|| $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss') |
|
|
|
|
|| $this->appendIfExist($this->serverroot, $style.'.css') |
|
|
|
|
|| $this->appendIfExist($this->serverroot, 'core/'.$style.'.css') |
|
|
|
|
) { |
|
|
|
|
@ -91,22 +80,13 @@ class CSSResourceLocator extends ResourceLocator { |
|
|
|
|
* |
|
|
|
|
* @param string $root path to check |
|
|
|
|
* @param string $file the filename |
|
|
|
|
* @param IAppData $appData |
|
|
|
|
* @param IURLGenerator $urlGenerator |
|
|
|
|
* @param 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, IAppData $appData, IURLGenerator $urlGenerator, SystemConfig $systemConfig, $webRoot = null) { |
|
|
|
|
protected function cacheAndAppendScssIfExist($root, $file, $webRoot = null) { |
|
|
|
|
if (is_file($root.'/'.$file)) { |
|
|
|
|
$scssCache = new SCSSCacher( |
|
|
|
|
$this->logger, |
|
|
|
|
$appData, |
|
|
|
|
$urlGenerator, |
|
|
|
|
$systemConfig); |
|
|
|
|
|
|
|
|
|
if($scssCache->process($root, $file)) { |
|
|
|
|
$this->append($root, $scssCache->getCachedSCSS('core', $file), $webRoot, false); |
|
|
|
|
if($this->scssCacher->process($root, $file)) { |
|
|
|
|
$this->append($root, $this->scssCacher->getCachedSCSS('core', $file), $webRoot, false); |
|
|
|
|
return true; |
|
|
|
|
} else { |
|
|
|
|
$this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); |
|
|
|
|
|