-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
override default dashboard background with theming one
fix getAppValue default value in theming app fix cacheBuster value injection Signed-off-by: Julien Veyssier <[email protected]> Signed-off-by: npmbuildbot-nextcloud[bot] <npmbuildbot-nextcloud[bot]@users.noreply.github.com>
- Loading branch information
1 parent
bb32ba0
commit c1bdfc8
Showing
11 changed files
with
119 additions
and
99 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,9 @@ | |
<a v-if="isAdmin" :href="appStoreUrl" class="button">{{ t('dashboard', 'Get more widgets from the app store') }}</a> | ||
|
||
<h3>{{ t('dashboard', 'Change background image') }}</h3> | ||
<BackgroundSettings :background="background" @update:background="updateBackground" /> | ||
<BackgroundSettings :background="background" | ||
:theming-default-background="themingDefaultBackground" | ||
@update:background="updateBackground" /> | ||
|
||
<h3>{{ t('dashboard', 'Weather service') }}</h3> | ||
<p> | ||
|
@@ -93,11 +95,11 @@ import { generateUrl } from '@nextcloud/router' | |
import isMobile from './mixins/isMobile' | ||
import BackgroundSettings from './components/BackgroundSettings' | ||
import getBackgroundUrl from './helpers/getBackgroundUrl' | ||
import prefixWithBaseUrl from './helpers/prefixWithBaseUrl' | ||
const panels = loadState('dashboard', 'panels') | ||
const firstRun = loadState('dashboard', 'firstRun') | ||
const background = loadState('dashboard', 'background') | ||
const themingDefaultBackground = loadState('dashboard', 'themingDefaultBackground') | ||
const version = loadState('dashboard', 'version') | ||
const shippedBackgroundList = loadState('dashboard', 'shippedBackgrounds') | ||
const statusInfo = { | ||
|
@@ -140,16 +142,17 @@ export default { | |
appStoreUrl: generateUrl('/settings/apps/dashboard'), | ||
statuses: {}, | ||
background, | ||
themingDefaultBackground, | ||
version, | ||
defaultBackground: window.OCA.Accessibility?.theme === 'dark' ? prefixWithBaseUrl('[email protected]?v=1') : prefixWithBaseUrl('flickr-paszczak000-8715851521.jpg?v=1'), | ||
} | ||
}, | ||
computed: { | ||
backgroundImage() { | ||
return getBackgroundUrl(this.background, this.version) | ||
return getBackgroundUrl(this.background, this.version, this.themingDefaultBackground) | ||
}, | ||
backgroundStyle() { | ||
if (this.background.match(/#[0-9A-Fa-f]{6}/g)) { | ||
if ((this.background === 'default' && this.themingDefaultBackground === 'backgroundColor') | ||
|| this.background.match(/#[0-9A-Fa-f]{6}/g)) { | ||
return null | ||
} | ||
return { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
<?php | ||
/** | ||
* @copyright Copyright (c) 2016 Julius Härtl <[email protected]> | ||
* | ||
* @author Christoph Wurst <[email protected]> | ||
* @author Daniel Kesselberg <[email protected]> | ||
* @author Julius Haertl <[email protected]> | ||
* @author Julius Härtl <[email protected]> | ||
* @author Michael Weimann <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
* @copyright Copyright (c) 2016 Julius Härtl <[email protected]> | ||
* | ||
* @author Christoph Wurst <[email protected]> | ||
* @author Daniel Kesselberg <[email protected]> | ||
* @author Julius Haertl <[email protected]> | ||
* @author Julius Härtl <[email protected]> | ||
* @author Michael Weimann <[email protected]> | ||
* @author Roeland Jago Douma <[email protected]> | ||
* | ||
* @license GNU AGPL version 3 or any later version | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
namespace OCA\Theming; | ||
|
||
|
@@ -41,70 +41,70 @@ | |
|
||
class ImageManager { | ||
|
||
/** @var IConfig */ | ||
private $config; | ||
/** @var IAppData */ | ||
private $appData; | ||
/** @var IURLGenerator */ | ||
private $urlGenerator; | ||
/** @var array */ | ||
private $supportedImageKeys = ['background', 'logo', 'logoheader', 'favicon']; | ||
/** @var ICacheFactory */ | ||
private $cacheFactory; | ||
/** @var ILogger */ | ||
private $logger; | ||
/** @var ITempManager */ | ||
private $tempManager; | ||
|
||
public function __construct(IConfig $config, | ||
IAppData $appData, | ||
IURLGenerator $urlGenerator, | ||
ICacheFactory $cacheFactory, | ||
ILogger $logger, | ||
ITempManager $tempManager | ||
) { | ||
$this->config = $config; | ||
$this->appData = $appData; | ||
$this->urlGenerator = $urlGenerator; | ||
$this->cacheFactory = $cacheFactory; | ||
$this->logger = $logger; | ||
$this->tempManager = $tempManager; | ||
} | ||
/** @var IConfig */ | ||
private $config; | ||
/** @var IAppData */ | ||
private $appData; | ||
/** @var IURLGenerator */ | ||
private $urlGenerator; | ||
/** @var array */ | ||
private $supportedImageKeys = ['background', 'logo', 'logoheader', 'favicon']; | ||
/** @var ICacheFactory */ | ||
private $cacheFactory; | ||
/** @var ILogger */ | ||
private $logger; | ||
/** @var ITempManager */ | ||
private $tempManager; | ||
|
||
public function getImageUrl(string $key, bool $useSvg = true): string { | ||
$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); | ||
try { | ||
$image = $this->getImage($key, $useSvg); | ||
return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter; | ||
} catch (NotFoundException $e) { | ||
} | ||
public function __construct(IConfig $config, | ||
IAppData $appData, | ||
IURLGenerator $urlGenerator, | ||
ICacheFactory $cacheFactory, | ||
ILogger $logger, | ||
ITempManager $tempManager | ||
) { | ||
$this->config = $config; | ||
$this->appData = $appData; | ||
$this->urlGenerator = $urlGenerator; | ||
$this->cacheFactory = $cacheFactory; | ||
$this->logger = $logger; | ||
$this->tempManager = $tempManager; | ||
} | ||
|
||
switch ($key) { | ||
case 'logo': | ||
case 'logoheader': | ||
case 'favicon': | ||
return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter; | ||
case 'background': | ||
return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter; | ||
} | ||
public function getImageUrl(string $key, bool $useSvg = true): string { | ||
$cacheBusterCounter = $this->config->getAppValue('theming', 'cachebuster', '0'); | ||
try { | ||
$image = $this->getImage($key, $useSvg); | ||
return $this->urlGenerator->linkToRoute('theming.Theming.getImage', [ 'key' => $key ]) . '?v=' . $cacheBusterCounter; | ||
} catch (NotFoundException $e) { | ||
} | ||
|
||
public function getImageUrlAbsolute(string $key, bool $useSvg = true): string { | ||
return $this->urlGenerator->getAbsoluteURL($this->getImageUrl($key, $useSvg)); | ||
switch ($key) { | ||
case 'logo': | ||
case 'logoheader': | ||
case 'favicon': | ||
return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter; | ||
case 'background': | ||
return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter; | ||
} | ||
} | ||
|
||
/** | ||
* @param string $key | ||
* @param bool $useSvg | ||
* @return ISimpleFile | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
*/ | ||
public function getImage(string $key, bool $useSvg = true): ISimpleFile { | ||
public function getImageUrlAbsolute(string $key, bool $useSvg = true): string { | ||
return $this->urlGenerator->getAbsoluteURL($this->getImageUrl($key, $useSvg)); | ||
} | ||
|
||
/** | ||
* @param string $key | ||
* @param bool $useSvg | ||
* @return ISimpleFile | ||
* @throws NotFoundException | ||
* @throws NotPermittedException | ||
*/ | ||
public function getImage(string $key, bool $useSvg = true): ISimpleFile { | ||
$pngFile = null; | ||
$logo = $this->config->getAppValue('theming', $key . 'Mime', false); | ||
$logo = $this->config->getAppValue('theming', $key . 'Mime', ''); | ||
$folder = $this->appData->getFolder('images'); | ||
if ($logo === false || !$folder->fileExists($key)) { | ||
if ($logo === '' || !$folder->fileExists($key)) { | ||
throw new NotFoundException(); | ||
} | ||
if (!$useSvg && $this->shouldReplaceIcons()) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters