Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2022-04-01 16:19:15 +0300
committerJohn Molakvoæ <skjnldsv@protonmail.com>2022-04-21 10:31:06 +0300
commita1aaaaa0c86c002a0a406464724b8a0236fe8406 (patch)
treed578929dbff3330c6c00f3068453cd5b943d8a52 /apps/theming/lib
parent738fcba51a4947213b8b240ebbecc948308340cb (diff)
Update and fix theming images
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/theming/lib')
-rw-r--r--apps/theming/lib/Listener/BeforeTemplateRenderedListener.php14
-rw-r--r--apps/theming/lib/Themes/DefaultTheme.php41
2 files changed, 30 insertions, 25 deletions
diff --git a/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php b/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php
index 6842a731b5f..185289f6ff8 100644
--- a/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php
+++ b/apps/theming/lib/Listener/BeforeTemplateRenderedListener.php
@@ -58,20 +58,6 @@ class BeforeTemplateRenderedListener implements IEventListener {
return $serverContainer->query(JSDataService::class);
});
- // $linkToCSS = $this->urlGenerator->linkToRoute(
- // 'theming.Theming.getStylesheet',
- // [
- // 'v' => $this->config->getAppValue('theming', 'cachebuster', '0'),
- // ]
- // );
- // \OCP\Util::addHeader(
- // 'link',
- // [
- // 'rel' => 'stylesheet',
- // 'href' => $linkToCSS,
- // ]
- // );
-
$this->themeInjectionService->injectHeaders();
// Making sure to inject just after core
diff --git a/apps/theming/lib/Themes/DefaultTheme.php b/apps/theming/lib/Themes/DefaultTheme.php
index 97650bf6292..990b011bae9 100644
--- a/apps/theming/lib/Themes/DefaultTheme.php
+++ b/apps/theming/lib/Themes/DefaultTheme.php
@@ -24,21 +24,32 @@ declare(strict_types=1);
*/
namespace OCA\Theming\Themes;
+use OCA\Theming\ImageManager;
use OCA\Theming\ThemingDefaults;
use OCA\Theming\Util;
use OCA\Theming\ITheme;
+use OCP\IConfig;
use OCP\IURLGenerator;
class DefaultTheme implements ITheme {
public Util $util;
public ThemingDefaults $themingDefaults;
public IURLGenerator $urlGenerator;
+ public ImageManager $imageManager;
+ public IConfig $config;
+
public string $primaryColor;
- public function __construct(Util $util, ThemingDefaults $themingDefaults, IURLGenerator $urlGenerator) {
+ public function __construct(Util $util,
+ ThemingDefaults $themingDefaults,
+ IURLGenerator $urlGenerator,
+ ImageManager $imageManager,
+ IConfig $config) {
$this->util = $util;
$this->themingDefaults = $themingDefaults;
$this->urlGenerator = $urlGenerator;
+ $this->imageManager = $imageManager;
+ $this->config = $config;
$this->primaryColor = $this->themingDefaults->getColorPrimary();
}
@@ -58,11 +69,7 @@ class DefaultTheme implements ITheme {
$colorBoxShadow = $this->util->darken($colorMainBackground, 70);
$colorBoxShadowRGB = join(',', $this->util->hexToRGB($colorBoxShadow));
- // Logo variables
- $logoSvgPath = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo());
- $backgroundSvgPath = $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getBackground());
-
- return [
+ $variables = [
'--color-main-background' => $colorMainBackground,
'--color-main-background-rgb' => $colorMainBackgroundRGB,
'--color-main-background-translucent' => 'rgba(var(--color-main-background-rgb), .97)',
@@ -124,11 +131,6 @@ class DefaultTheme implements ITheme {
'--animation-slow' => '300ms',
// Default variables --------------------------------------------
- '--image-logo' => "url('$logoSvgPath')",
- '--image-login' => "url('$backgroundSvgPath')",
- '--image-logoheader' => "url('$logoSvgPath')",
- '--image-favicon' => "url('$logoSvgPath')",
-
'--border-radius' => '3px',
'--border-radius-large' => '10px',
// pill-style button, value is large so big buttons also have correct roundness
@@ -156,5 +158,22 @@ class DefaultTheme implements ITheme {
'--primary-invert-if-bright' => $this->util->invertTextColor($this->primaryColor) ? 'invert(100%)' : 'unset',
'--background-invert-if-bright' => 'unset',
];
+
+ // Register image variables only if custom-defined
+ $backgroundDeleted = $this->config->getAppValue('theming', 'backgroundMime', '') === 'backgroundColor';
+ foreach(['logo', 'logoheader', 'favicon', 'background'] as $image) {
+ if ($this->imageManager->hasImage($image)) {
+ // If primary as background has been request, let's not define the background image
+ if ($image === 'background' && $backgroundDeleted) {
+ $variables["--image-background-plain"] = true;
+ continue;
+ } else if ($image === 'background') {
+ $variables['--image-background-size'] = 'cover';
+ }
+ $variables["--image-$image"] = "url('".$this->imageManager->getImageUrl($image)."')";
+ }
+ }
+
+ return $variables;
}
}