Css cache folder name fix, route fix and various fixes
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
35b13b856b
commit
6380d503af
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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'],
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue