diff options
author | Joas Schilling <coding@schilljs.com> | 2020-06-10 23:47:01 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-06-10 23:47:01 +0200 |
commit | 291640273dfc17aa240a48d7d4a1553d76d54e41 (patch) | |
tree | e09c0305514882cbcb972d0d5fb166f3a72fc367 | |
parent | 9806dec9b3f985ce8a05c9852064e38fa7b199a5 (diff) | |
download | nextcloud-server-291640273dfc17aa240a48d7d4a1553d76d54e41.tar.gz nextcloud-server-291640273dfc17aa240a48d7d4a1553d76d54e41.zip |
Respect "prefers-color-scheme" media selector for guests
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | apps/accessibility/lib/AppInfo/Application.php | 6 | ||||
-rw-r--r-- | apps/accessibility/lib/Controller/AccessibilityController.php | 12 |
2 files changed, 15 insertions, 3 deletions
diff --git a/apps/accessibility/lib/AppInfo/Application.php b/apps/accessibility/lib/AppInfo/Application.php index 0cac878d34e..02dfeb8c16b 100644 --- a/apps/accessibility/lib/AppInfo/Application.php +++ b/apps/accessibility/lib/AppInfo/Application.php @@ -63,6 +63,12 @@ class Application extends App { $linkToCSS = $this->urlGenerator->linkToRoute(self::APP_NAME . '.accessibility.getCss', ['md5' => $hash]); \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS]); } + } else { + $userValues = ['dark']; + + $hash = md5(implode('-', $userValues)); + $linkToCSS = $this->urlGenerator->linkToRoute(self::APP_NAME . '.accessibility.getCss', ['md5' => $hash]); + \OCP\Util::addHeader('link', ['rel' => 'stylesheet', 'media' => '(prefers-color-scheme: dark)', 'href' => $linkToCSS]); } } diff --git a/apps/accessibility/lib/Controller/AccessibilityController.php b/apps/accessibility/lib/Controller/AccessibilityController.php index 25e117c7155..4f96922324a 100644 --- a/apps/accessibility/lib/Controller/AccessibilityController.php +++ b/apps/accessibility/lib/Controller/AccessibilityController.php @@ -131,7 +131,7 @@ class AccessibilityController extends Controller { } /** - * @NoAdminRequired + * @PublicPage * @NoCSRFRequired * @NoSameSiteCookieRequired * @@ -140,7 +140,11 @@ class AccessibilityController extends Controller { public function getCss(): DataDisplayResponse { $css = ''; $imports = ''; - $userValues = $this->getUserValues(); + if ($this->userSession->isLoggedIn()) { + $userValues = $this->getUserValues(); + } else { + $userValues = ['dark']; + } foreach ($userValues as $key => $scssFile) { if ($scssFile !== false) { @@ -199,7 +203,9 @@ class AccessibilityController extends Controller { $response->addHeader('Pragma', 'cache'); // store current cache hash - $this->config->setUserValue($this->userSession->getUser()->getUID(), $this->appName, 'icons-css', md5($css)); + if ($this->userSession->isLoggedIn()) { + $this->config->setUserValue($this->userSession->getUser()->getUID(), $this->appName, 'icons-css', md5($css)); + } return $response; } |