Css cache folder name fix, route fix and various fixes

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2016-11-10 16:36:58 +01:00 committed by Roeland Jago Douma
parent 35b13b856b
commit 6380d503af
No known key found for this signature in database
GPG Key ID: F941078878347C0C
8 changed files with 28 additions and 19 deletions

View File

@ -58,11 +58,12 @@ class CssController extends Controller {
* @NoCSRFRequired * @NoCSRFRequired
* *
* @param string $fileName css filename with extension * @param string $fileName css filename with extension
* @param string $appName css folder name
* @return text/css * @return text/css
*/ */
public function getCss($fileName) { public function getCss($fileName, $appName) {
try { try {
$cssFile = $this->cssManager->getCss($fileName); $cssFile = $this->cssManager->getCss($fileName, $appName);
} catch(NotFoundException $e) { } catch(NotFoundException $e) {
return new NotFoundResponse(); return new NotFoundResponse();
} }

View File

@ -55,7 +55,7 @@ $application->registerRoutes($this, [
['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'], ['name' => 'OCJS#getConfig', 'url' => '/core/js/oc.js', 'verb' => 'GET'],
['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'], ['name' => 'Preview#getPreview', 'url' => '/core/preview', 'verb' => 'GET'],
['name' => 'Preview#getPreview', 'url' => '/core/preview.png', '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' => [ 'ocs' => [
['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'], ['root' => '/cloud', 'name' => 'OCS#getCapabilities', 'url' => '/capabilities', 'verb' => 'GET'],

View File

@ -48,11 +48,12 @@ class CssManager implements ICssManager {
* Get the css file and return ISimpleFile * Get the css file and return ISimpleFile
* *
* @param string $fileName css filename with extension * @param string $fileName css filename with extension
* @param string $appName css app name
* @return ISimpleFile * @return ISimpleFile
*/ */
public function getCss($fileName) { public function getCss($fileName, $appName) {
try { try {
$folder = $this->appData->getFolder('css'); $folder = $this->appData->getFolder($appName);
} catch(NotFoundException $e) { } catch(NotFoundException $e) {
throw new NotFoundException(); throw new NotFoundException();
} }

View File

@ -419,7 +419,7 @@ class Server extends ServerContainer implements IServerContainer {
}); });
$this->registerService('CssManager', function (Server $c) { $this->registerService('CssManager', function (Server $c) {
return new CssManager( return new CssManager(
$c->getAppDataDir('server') $c->getAppDataDir('css')
); );
}); });
$this->registerService('Logger', function (Server $c) { $this->registerService('Logger', function (Server $c) {

View File

@ -27,11 +27,11 @@ namespace OC\Template;
class CSSResourceLocator extends ResourceLocator { class CSSResourceLocator extends ResourceLocator {
/** @var IAppData */ /** @var \OCP\Files\IAppData */
protected $appData; protected $appData;
/** @var \OCP\IURLGenerator */ /** @var \OCP\IURLGenerator */
protected $urlGenerator; protected $urlGenerator;
/** @var \OCP\Files\IConfig */ /** @var \OC\SystemConfig */
protected $systemConfig; protected $systemConfig;
/** /**
@ -39,9 +39,11 @@ class CSSResourceLocator extends ResourceLocator {
* @param string $theme * @param string $theme
* @param array $core_map * @param array $core_map
* @param array $party_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->appData = $appData;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$this->systemConfig = $systemConfig; $this->systemConfig = $systemConfig;

View File

@ -111,7 +111,9 @@ abstract class ResourceLocator {
* *
* @param string $root path to check * @param string $root path to check
* @param string $file the filename * @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 * @param string|null $webRoot base for path, default map $root to $webRoot
* @return bool True if the resource was found and cached, false otherwise * @return bool True if the resource was found and cached, false otherwise
*/ */
@ -126,7 +128,7 @@ abstract class ResourceLocator {
$systemConfig); $systemConfig);
if($scssCache->process()) { if($scssCache->process()) {
$this->append($root, $scssCache->getCachedSCSS(), $webRoot, false); $this->append($root, $scssCache->getCachedSCSS('core'), $webRoot, false);
return true; return true;
} else { } else {
$this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); $this->logger->error('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']);

View File

@ -42,7 +42,7 @@ class SCSSCacher {
protected $appData; protected $appData;
/** @var \OCP\IURLGenerator */ /** @var \OCP\IURLGenerator */
protected $urlGenerator; protected $urlGenerator;
/** @var \OCP\Files\IConfig */ /** @var \OC\SystemConfig */
protected $systemConfig; protected $systemConfig;
/** /**
@ -50,8 +50,10 @@ class SCSSCacher {
* @param string $root * @param string $root
* @param string $file * @param string $file
* @param \OCP\Files\IAppData $appData * @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->logger = $logger;
$this->appData = $appData; $this->appData = $appData;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
@ -90,7 +92,6 @@ class SCSSCacher {
} else { } else {
return $this->cache(); return $this->cache();
} }
return false;
} }
/** /**
@ -107,7 +108,7 @@ class SCSSCacher {
} catch(NotFoundException $e) { } catch(NotFoundException $e) {
return false; return false;
} }
return false; return false;
} }
/** /**
@ -163,9 +164,10 @@ class SCSSCacher {
/** /**
* Return the cached css file uri * Return the cached css file uri
* @param string $appName the app name
* @return string * @return string
*/ */
public function getCachedSCSS() { public function getCachedSCSS($appName) {
return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $this->fileNameCSS)), 1); return substr($this->urlGenerator->linkToRoute('core.Css.getCss', array('fileName' => $this->fileNameCSS, 'appName' => $appName)), 1);
} }
} }

View File

@ -32,7 +32,8 @@ interface ICssManager {
* Get the css file and return ISimpleFile * Get the css file and return ISimpleFile
* *
* @param string $fileName css filename with extension * @param string $fileName css filename with extension
* @param string $appName css app name
* @return ISimpleFile * @return ISimpleFile
*/ */
public function getCss($fileName); public function getCss($fileName, $appName);
} }