aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <213943+nickvergessen@users.noreply.github.com>2020-06-22 15:56:11 +0200
committerGitHub <noreply@github.com>2020-06-22 15:56:11 +0200
commit64f5a20aea5e49328b0d42a0e3825a35c4bf46df (patch)
tree0c6cccb0bd7b7861d4422b06d8abf779cfd6f99f
parent859941db3228286be0bea1692ce39624df3236f6 (diff)
parent291640273dfc17aa240a48d7d4a1553d76d54e41 (diff)
downloadnextcloud-server-64f5a20aea5e49328b0d42a0e3825a35c4bf46df.tar.gz
nextcloud-server-64f5a20aea5e49328b0d42a0e3825a35c4bf46df.zip
Merge pull request #21366 from nextcloud/feature/noid/respect-prefers-color-scheme
Respect "prefers-color-scheme" media selector for guests
-rw-r--r--apps/accessibility/lib/AppInfo/Application.php6
-rw-r--r--apps/accessibility/lib/Controller/AccessibilityController.php12
2 files changed, 15 insertions, 3 deletions
diff --git a/apps/accessibility/lib/AppInfo/Application.php b/apps/accessibility/lib/AppInfo/Application.php
index c5c495c1829..9b79cadb4b6 100644
--- a/apps/accessibility/lib/AppInfo/Application.php
+++ b/apps/accessibility/lib/AppInfo/Application.php
@@ -78,6 +78,12 @@ class Application extends App implements IBootstrap {
$linkToCSS = $urlGenerator->linkToRoute(self::APP_ID . '.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 bafe8eb3e4b..ca8e84851f9 100644
--- a/apps/accessibility/lib/Controller/AccessibilityController.php
+++ b/apps/accessibility/lib/Controller/AccessibilityController.php
@@ -130,7 +130,7 @@ class AccessibilityController extends Controller {
}
/**
- * @NoAdminRequired
+ * @PublicPage
* @NoCSRFRequired
* @NoSameSiteCookieRequired
*
@@ -139,7 +139,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) {
@@ -198,7 +202,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;
}