1
0
Fork 0
mirror of https://github.com/mwalbeck/nextcloud-breeze-dark.git synced 2025-04-08 06:50:11 +00:00

Only load custom styling when there actually is custom styling to get

This commit is contained in:
Magnus Walbeck 2021-02-28 13:45:58 +01:00
parent 41fa3f68e3
commit 0bb63e0b42
Signed by: mwalbeck
GPG key ID: CCB78CFF3F950769
3 changed files with 21 additions and 25 deletions

View file

@ -2,6 +2,10 @@
## [Unreleased]
### Changed
- Only load custom styling when there actually is custom styling to get
## 21.0.2 - 2021-02-27
### Added

View file

@ -94,16 +94,19 @@ class Application extends App implements IBootstrap {
Util::addStyle($this->appName, 'guest');
}
$linkToCustomStyling = $urlGenerator->linkToRoute(
'breezedark.Theming.getCustomStyling',
['v' => $cachebuster,]
);
Util::addHeader(
'link',
[
'rel' => 'stylesheet',
'href' => $linkToCustomStyling,
]
);
// Only request the stylesheet if there is any styling to request
if ($cachebuster) {
$linkToCustomStyling = $urlGenerator->linkToRoute(
'breezedark.Theming.getCustomStyling',
['v' => $cachebuster,]
);
Util::addHeader(
'link',
[
'rel' => 'stylesheet',
'href' => $linkToCustomStyling,
]
);
}
}
}

View file

@ -99,21 +99,10 @@ class SettingsController extends Controller {
$this->config->setAppValue($this->appName, "theme_custom_styling", $this->request->getParam("theme_custom_styling"));
$this->config->setAppValue($this->appName, "theme_cachebuster", time());
} else {
// If the request is empty set custom_styling to empty string and
// set cachebuster to 0 to indicate that no custom styling is available
$this->config->setAppValue($this->appName, "theme_custom_styling", "");
$this->config->setAppValue($this->appName, "theme_cachebuster", 0);
}
}
/**
* @NoCSRFRequired
* @PublicPage
* @NoSameSiteCookieRequired
*
* @return DataDisplayResponse|NotFoundResponse
*/
public function getCustomStyling(): DataDisplayResponse {
$customStyling = $this->config->getAppValue($this->appName, 'theme_custom_styling', '');
$response = new DataDisplayResponse($customStyling, Http::STATUS_OK, ['Content-Type' => 'text/css']);
$response->cacheFor(86400);
return $response;
}
}