summaryrefslogtreecommitdiffstats
path: root/apps/accessibility
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-08-15 07:25:31 +0200
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2018-08-15 07:25:31 +0200
commita7c426aa5cce521b44c24d245b816f60e7806c53 (patch)
tree5e8fd04da0265b46597fc9974c742985d3b5fe7f /apps/accessibility
parent62a9ec12bc1b2114f8566b1f2fc89d01d40b5e66 (diff)
downloadnextcloud-server-a7c426aa5cce521b44c24d245b816f60e7806c53.tar.gz
nextcloud-server-a7c426aa5cce521b44c24d245b816f60e7806c53.zip
Add default theming into accessibility compiler
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/accessibility')
-rw-r--r--apps/accessibility/lib/Controller/AccessibilityController.php35
1 files changed, 34 insertions, 1 deletions
diff --git a/apps/accessibility/lib/Controller/AccessibilityController.php b/apps/accessibility/lib/Controller/AccessibilityController.php
index 4ee88b90a7a..0a1d091d1c5 100644
--- a/apps/accessibility/lib/Controller/AccessibilityController.php
+++ b/apps/accessibility/lib/Controller/AccessibilityController.php
@@ -70,6 +70,12 @@ class AccessibilityController extends Controller {
/** @var IconsCacher */
protected $iconsCacher;
+ /** @var \OC_Defaults */
+ private $defaults;
+
+ /** @var null|string */
+ private $injectedVariables;
+
/**
* Account constructor.
*
@@ -82,6 +88,7 @@ class AccessibilityController extends Controller {
* @param ITimeFactory $timeFactory
* @param IUserSession $userSession
* @param IAppManager $appManager
+ * @param \OC_Defaults $defaults
*/
public function __construct(string $appName,
IRequest $request,
@@ -92,7 +99,8 @@ class AccessibilityController extends Controller {
ITimeFactory $timeFactory,
IUserSession $userSession,
IAppManager $appManager,
- IconsCacher $iconsCacher) {
+ IconsCacher $iconsCacher,
+ \OC_Defaults $defaults) {
parent::__construct($appName, $request);
$this->appName = $appName;
$this->config = $config;
@@ -103,6 +111,7 @@ class AccessibilityController extends Controller {
$this->userSession = $userSession;
$this->appManager = $appManager;
$this->iconsCacher = $iconsCacher;
+ $this->defaults = $defaults;
$this->serverRoot = \OC::$SERVERROOT;
$this->appRoot = $this->appManager->getAppPath($this->appName);
@@ -141,6 +150,7 @@ class AccessibilityController extends Controller {
$css .= $scss->compile(
$imports .
'@import "variables.scss";' .
+ $this->getInjectedVariables() .
'@import "css-variables.scss";'
);
} catch (ParserException $e) {
@@ -220,4 +230,27 @@ class AccessibilityController extends Controller {
private function invertSvgIconsColor(string $css) {
return str_replace(['/000', '/fff', '/***'], ['/***', '/000', '/fff'], $css);
}
+
+ /**
+ * @return string SCSS code for variables from OC_Defaults
+ */
+ private function getInjectedVariables(): string {
+ if ($this->injectedVariables !== null) {
+ return $this->injectedVariables;
+ }
+ $variables = '';
+ foreach ($this->defaults->getScssVariables() as $key => $value) {
+ $variables .= '$' . $key . ': ' . $value . ';';
+ }
+
+ // check for valid variables / otherwise fall back to defaults
+ try {
+ $scss = new Compiler();
+ $scss->compile($variables);
+ $this->injectedVariables = $variables;
+ } catch (ParserException $e) {
+ $this->logger->error($e, ['app' => 'core']);
+ }
+ return $variables;
+ }
}