From: John Molakvoæ (skjnldsv) Date: Thu, 10 Nov 2016 15:36:58 +0000 (+0100) Subject: Css cache folder name fix, route fix and various fixes X-Git-Tag: v12.0.0beta1~732^2~32 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6380d503af3252e0fea8d25e8bbe2f91d5aee1da;p=nextcloud-server.git Css cache folder name fix, route fix and various fixes Signed-off-by: John Molakvoæ (skjnldsv) --- diff --git a/core/Controller/CssController.php b/core/Controller/CssController.php index 31ec801d21c..323dd21496b 100644 --- a/core/Controller/CssController.php +++ b/core/Controller/CssController.php @@ -58,11 +58,12 @@ class CssController extends Controller { * @NoCSRFRequired * * @param string $fileName css filename with extension + * @param string $appName css folder name * @return text/css */ - public function getCss($fileName) { + public function getCss($fileName, $appName) { try { - $cssFile = $this->cssManager->getCss($fileName); + $cssFile = $this->cssManager->getCss($fileName, $appName); } catch(NotFoundException $e) { return new NotFoundResponse(); } diff --git a/core/routes.php b/core/routes.php index dec979c8ce2..6f1892d19ac 100644 --- a/core/routes.php +++ b/core/routes.php @@ -55,7 +55,7 @@ $application->registerRoutes($this, [ ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], ['name' => 'Preview#getPreview', 'url' => '/core/preview.png', 'verb' => 'GET'], - ['name' => 'Css#getCss', 'url' => '/css/{fileName}', 'verb' => 'GET'], + ['name' => 'Css#getCss', 'url' => '/css/{appName}/{fileName}', 'verb' => 'GET'], ], 'ocs' => [ ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], diff --git a/lib/private/CssManager.php b/lib/private/CssManager.php index 77e1e421eae..e22cb069306 100644 --- a/lib/private/CssManager.php +++ b/lib/private/CssManager.php @@ -48,11 +48,12 @@ class CssManager implements ICssManager { * Get the css file and return ISimpleFile * * @param string $fileName css filename with extension + * @param string $appName css app name * @return ISimpleFile */ - public function getCss($fileName) { + public function getCss($fileName, $appName) { try { - $folder = $this->appData->getFolder('css'); + $folder = $this->appData->getFolder($appName); } catch(NotFoundException $e) { throw new NotFoundException(); } diff --git a/lib/private/Server.php b/lib/private/Server.php index 2dbf827844d..a8825f9ff24 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -419,7 +419,7 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerService('CssManager', function (Server $c) { return new CssManager( - $c->getAppDataDir('server') + $c->getAppDataDir('css') ); }); $this->registerService('Logger', function (Server $c) { diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index 8e1cb3a761a..b592dd63ae1 100755 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -27,11 +27,11 @@ namespace OC\Template; class CSSResourceLocator extends ResourceLocator { - /** @var IAppData */ + /** @var \OCP\Files\IAppData */ protected $appData; /** @var \OCP\IURLGenerator */ protected $urlGenerator; - /** @var \OCP\Files\IConfig */ + /** @var \OC\SystemConfig */ protected $systemConfig; /** @@ -39,9 +39,11 @@ class CSSResourceLocator extends ResourceLocator { * @param string $theme * @param array $core_map * @param array $party_map - * @param IAppData $appData + * @param \OCP\Files\IAppData $appData + * @param \OCP\IURLGenerator $urlGenerator + * @param \OC\SystemConfig $systemConfig */ - public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, $systemConfig) { + public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, \OC\SystemConfig $systemConfig) { $this->appData = $appData; $this->urlGenerator = $urlGenerator; $this->systemConfig = $systemConfig; diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php index d5187ef0710..07a4387df8a 100755 --- a/lib/private/Template/ResourceLocator.php +++ b/lib/private/Template/ResourceLocator.php @@ -111,7 +111,9 @@ abstract class ResourceLocator { * * @param string $root path to check * @param string $file the filename - * @param IAppData $appData the appData folder + * @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 */ @@ -126,7 +128,7 @@ abstract class ResourceLocator { $systemConfig); if($scssCache->process()) { - $this->append($root, $scssCache->getCachedSCSS(), $webRoot, false); + $this->append($root, $scssCache->getCachedSCSS('core'), $webRoot, false); return true; } else { $this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 800b6b18bac..e72e122155c 100755 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -42,7 +42,7 @@ class SCSSCacher { protected $appData; /** @var \OCP\IURLGenerator */ protected $urlGenerator; - /** @var \OCP\Files\IConfig */ + /** @var \OC\SystemConfig */ protected $systemConfig; /** @@ -50,8 +50,10 @@ class SCSSCacher { * @param string $root * @param string $file * @param \OCP\Files\IAppData $appData + * @param \OCP\IURLGenerator $urlGenerator + * @param \OC\SystemConfig $systemConfig */ - public function __construct(\OCP\ILogger $logger, $root, $file, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, $systemConfig) { + public function __construct(\OCP\ILogger $logger, $root, $file, \OCP\Files\IAppData $appData, \OCP\IURLGenerator $urlGenerator, \OC\SystemConfig $systemConfig) { $this->logger = $logger; $this->appData = $appData; $this->urlGenerator = $urlGenerator; @@ -90,7 +92,6 @@ class SCSSCacher { } else { return $this->cache(); } - return false; } /** @@ -107,7 +108,7 @@ class SCSSCacher { } catch(NotFoundException $e) { return false; } - return false; + return false; } /** @@ -163,9 +164,10 @@ class SCSSCacher { /** * Return the cached css file uri + * @param string $appName the app name * @return string */ - public function getCachedSCSS() { - return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $this->fileNameCSS)), 1); + public function getCachedSCSS($appName) { + return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $this->fileNameCSS, 'appName' => $appName)), 1); } } diff --git a/lib/public/ICssManager.php b/lib/public/ICssManager.php index 0af1472b5c4..776ffefd823 100644 --- a/lib/public/ICssManager.php +++ b/lib/public/ICssManager.php @@ -32,7 +32,8 @@ interface ICssManager { * Get the css file and return ISimpleFile * * @param string $fileName css filename with extension + * @param string $appName css app name * @return ISimpleFile */ - public function getCss($fileName); + public function getCss($fileName, $appName); }