Skip to content

Commit e7523b0

Browse files
authored
Merge pull request #3197 from nextcloud/enable-scss-for-all-apps
Enable every app to generate their scss file
2 parents feab1e5 + dcad603 commit e7523b0

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

lib/private/Template/CSSResourceLocator.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,22 @@ public function __construct(ILogger $logger, $theme, $core_map, $party_map, $scs
4949
* @param string $style
5050
*/
5151
public function doFind($style) {
52+
$app = substr($style, 0, strpos($style, '/'));
5253
if (strpos($style, '3rdparty') === 0
5354
&& $this->appendIfExist($this->thirdpartyroot, $style.'.css')
54-
|| $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss')
55+
|| $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $app)
5556
|| $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss')
5657
|| $this->appendIfExist($this->serverroot, $style.'.css')
5758
|| $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
5859
) {
5960
return;
6061
}
61-
$app = substr($style, 0, strpos($style, '/'));
6262
$style = substr($style, strpos($style, '/')+1);
6363
$app_path = \OC_App::getAppPath($app);
6464
$app_url = \OC_App::getAppWebPath($app);
65-
$this->append($app_path, $style.'.css', $app_url);
65+
if(!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) {
66+
$this->append($app_path, $style.'.css', $app_url);
67+
}
6668
}
6769

6870
/**
@@ -80,14 +82,13 @@ public function doFindTheme($style) {
8082
*
8183
* @param string $root path to check
8284
* @param string $file the filename
83-
* @param string|null $webRoot base for path, default map $root to $webRoot
8485
* @return bool True if the resource was found and cached, false otherwise
8586
*/
86-
protected function cacheAndAppendScssIfExist($root, $file, $webRoot = null) {
87+
protected function cacheAndAppendScssIfExist($root, $file, $app = 'core') {
8788
if (is_file($root.'/'.$file)) {
8889
if($this->scssCacher !== null) {
89-
if($this->scssCacher->process($root, $file)) {
90-
$this->append($root, $this->scssCacher->getCachedSCSS('core', $file), $webRoot, false);
90+
if($this->scssCacher->process($root, $file, $app)) {
91+
$this->append($root, $this->scssCacher->getCachedSCSS($app, $file), false);
9192
return true;
9293
} else {
9394
$this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']);

lib/private/Template/SCSSCacher.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ public function __construct(ILogger $logger, IAppData $appData, IURLGenerator $u
6363
* Process the caching process if needed
6464
* @param string $root Root path to the nextcloud installation
6565
* @param string $file
66+
* @param string $app The app name
6667
* @return boolean
6768
*/
68-
public function process($root, $file) {
69+
public function process($root, $file, $app) {
6970
$path = explode('/', $root . '/' . $file);
7071

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

8081
try {
81-
$folder = $this->appData->getFolder('core');
82+
$folder = $this->appData->getFolder($app);
8283
} catch(NotFoundException $e) {
8384
// creating css appdata folder
84-
$folder = $this->appData->newFolder('core');
85+
$folder = $this->appData->newFolder($app);
8586
}
8687

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

0 commit comments

Comments
 (0)