Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow apps to use scss styles #3237

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions lib/private/Template/CSSResourceLocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ public function doFind($style) {
) {
return;
}


$app = substr($style, 0, strpos($style, '/'));
$style = substr($style, strpos($style, '/')+1);
$app_path = \OC_App::getAppPath($app);
$app_url = \OC_App::getAppWebPath($app);

if ($this->cacheAndAppendScssIfExist($app_path, $style.'.scss', null, $app)) {
return;
}

$this->append($app_path, $style.'.css', $app_url);
}

Expand All @@ -81,13 +88,14 @@ public function doFindTheme($style) {
* @param string $root path to check
* @param string $file the filename
* @param string|null $webRoot base for path, default map $root to $webRoot
* @param string $app
* @return bool True if the resource was found and cached, false otherwise
*/
protected function cacheAndAppendScssIfExist($root, $file, $webRoot = null) {
protected function cacheAndAppendScssIfExist($root, $file, $webRoot = null, $app = 'core') {
if (is_file($root.'/'.$file)) {
if($this->scssCacher !== null) {
if($this->scssCacher->process($root, $file)) {
$this->append($root, $this->scssCacher->getCachedSCSS('core', $file), $webRoot, false);
if($this->scssCacher->process($root, $file, $app)) {
$this->append($root, $this->scssCacher->getCachedSCSS($app, $file), $webRoot, false);
return true;
} else {
$this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']);
Expand Down
6 changes: 3 additions & 3 deletions lib/private/Template/SCSSCacher.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __construct(ILogger $logger, IAppData $appData, IURLGenerator $u
* @param string $file
* @return boolean
*/
public function process($root, $file) {
public function process($root, $file, $app = 'core') {
$path = explode('/', $root . '/' . $file);

$fileNameSCSS = array_pop($path);
Expand All @@ -78,10 +78,10 @@ public function process($root, $file) {
$webDir = implode('/', $webDir);

try {
$folder = $this->appData->getFolder('core');
$folder = $this->appData->getFolder($app);
} catch(NotFoundException $e) {
// creating css appdata folder
$folder = $this->appData->newFolder('core');
$folder = $this->appData->newFolder($app);
}

if($this->isCached($fileNameCSS, $fileNameSCSS, $folder, $path)) {
Expand Down