From 92049c3ceb4121c6e424e8ba902cc6ebc663c690 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Tue, 28 Aug 2018 12:01:32 +0200 Subject: [PATCH 1/6] Switches the default logo color depending on the primary color Signed-off-by: Michael Weimann --- apps/theming/css/theming.scss | 11 +-- apps/theming/lib/ImageManager.php | 2 + apps/theming/lib/ThemingDefaults.php | 20 +++++- apps/theming/tests/ThemingDefaultsTest.php | 67 +++++++++++++++++- core/img/logo-blue.png | Bin 0 -> 6112 bytes core/img/logo-blue.svg | 76 +++++++++++++++++++++ 6 files changed, 168 insertions(+), 8 deletions(-) create mode 100644 core/img/logo-blue.png create mode 100644 core/img/logo-blue.svg diff --git a/apps/theming/css/theming.scss b/apps/theming/css/theming.scss index f12ce4d907..b1b8896d0c 100644 --- a/apps/theming/css/theming.scss +++ b/apps/theming/css/theming.scss @@ -98,20 +98,21 @@ background-image: url(./img/core/filetypes/folder-drag-accept.svg?v=#{$theming-cachebuster}) !important; } +#theming-preview-logo, +#header .logo { + background-image: $image-logo; +} + /* override styles for login screen in guest.css */ @if variable_exists('theming-logo-mime') and $theming-logo-mime != '' { #theming-preview-logo, #header .logo { - background-image: $image-logo; background-size: contain; } + #body-login #header .logo { margin-bottom: 22px; } -} @else { - #theming-preview-logo { - background-image: $image-logo; - } } @if variable_exists('theming-background-mime') and $theming-background-mime != '' { diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index dfbdb582da..6a42c22aba 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -84,6 +84,8 @@ class ImageManager { case 'logoheader': case 'favicon': return $this->urlGenerator->imagePath('core', 'logo.png') . '?v=' . $cacheBusterCounter; + case 'logo-blue': + return $this->urlGenerator->imagePath('core', 'logo-blue.png') . '?v=' . $cacheBusterCounter; case 'background': return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter; } diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 1df7a9f17b..5a14e8a790 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -275,7 +275,7 @@ class ThemingDefaults extends \OC_Defaults { 'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" ]; - $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; + $variables['image-logo'] = "url('". $this->getLogoUrl() ."')"; $variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'"; $variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'"; $variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')"; @@ -300,6 +300,24 @@ class ThemingDefaults extends \OC_Defaults { return $variables; } + /** + * Returns the logo url. + * If there is a custom logo, it just returns it. + * For the default logo it returns the white or blue one depending on the color luminance. + * + * @return string + */ + private function getLogoUrl() { + $logoMime = $this->config->getAppValue('theming', 'logoMime'); + $primaryColor = $this->getColorPrimary(); + $luminance = $this->util->calculateLuminance($primaryColor); + if ($logoMime === '' & $luminance > 0.8) { + return $this->imageManager->getImageUrl('logo-blue'); + } else { + return $this->imageManager->getImageUrl('logo'); + } + } + /** * Check if the image should be replaced by the theming app * and return the new image location then diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 5d075709dc..fc3a737c3c 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -632,6 +632,66 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals(['foo'=>'bar'], $this->template->getScssVariables()); } + /** + * Provides test data for the get logo scss variable test. + * + * @return array + */ + public function provideTestGetImageLogoScssVariableTestData(): array { + return [ + // default logo + ['', '#000000', 0.0, 'logo'], + ['', '#cccccc', 0.8, 'logo'], + ['', '#dddddd', 0.81, 'logo-blue'], + ['', '#ffffff', 1.0, 'logo-blue'], + + // custom logo + ['image/png', '#000000', 0.0, 'logo'], + ['image/png', '#cccccc', 0.8, 'logo'], + ['image/png', '#dddddd', 0.81, 'logo'], + ['image/png', '#ffffff', 1.0, 'logo'], + ]; + } + + /** + * Tests chat the logo url scss variable has the expected value + * depending on color and custom logo presence. + * + * @dataProvider provideTestGetImageLogoScssVariableTestData + * @param string $themingLogoMime The custom logo mime type + * @param string $primaryColor The primary theme color + * @param float $luminance The calculated luminance + * @param string $expected The expected requested logo + * @return void + */ + public function testGetImageLogoScssVariable( + string $themingLogoMime, + string $primaryColor, + float $luminance, + string $expected + ) { + $this->config->expects($this->at(5)) + ->method('getAppValue') + ->with('theming', 'logoMime') + ->willReturn($themingLogoMime); + $this->config->expects($this->at(6)) + ->method('getAppValue') + ->with('theming', 'color', $this->defaults->getColorPrimary()) + ->willReturn($primaryColor); + + $this->util + ->method('calculateLuminance') + ->with($primaryColor) + ->willReturn($luminance); + + $this->imageManager->expects($this->at(0)) + ->method('getImageUrl') + ->with($expected) + ->willReturn('custom-logo?v=0'); + + $this->template->getScssVariables(); + } + public function testGetScssVariables() { $this->config->expects($this->at(0))->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('0'); $this->config->expects($this->at(1))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg'); @@ -639,10 +699,13 @@ class ThemingDefaultsTest extends TestCase { $this->config->expects($this->at(3))->method('getAppValue')->with('theming', 'logoheaderMime', false)->willReturn('jpeg'); $this->config->expects($this->at(4))->method('getAppValue')->with('theming', 'faviconMime', false)->willReturn('jpeg'); - $this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary()); + $this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg'); $this->config->expects($this->at(6))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); - $this->config->expects($this->at(7))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); + + $this->config->expects($this->at(7))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary()); $this->config->expects($this->at(8))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); + $this->config->expects($this->at(9))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); + $this->config->expects($this->at(10))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); $this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false); $this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa'); diff --git a/core/img/logo-blue.png b/core/img/logo-blue.png new file mode 100644 index 0000000000000000000000000000000000000000..e1b7352b3f670df14fbc7ddc841744bda21f848e GIT binary patch literal 6112 zcmV<67a!<}P)7i~#I zK~#9!?VWpgRMpkSf9p&V2!xC6r=YEhSFmbnHOvI0wLxvIms+dh6>s&atyV-@#0xVy z$)JL?pxB$W`q_$95UsXawN+x<05g-Q^;0Vst%6ph`XG>SP3Elck3p16LK0@5IWx20 z|CG$x=e&Epd+oI^Yk`G@g@uKMg@uKMMIJ*e1x1GG3(Hwo)*FDnTh=pv#70Ys6}&}0 z!c7e%lpcc0;V6eAG6XmX=neD*`T@=kzw&^!Kr_$+yp8JX2ul%NiX*RcbJZ$Kt`)pR z&IR6hFi!eJL`I^F0zPM`r4N84LIbML5{;R|Xq+cbT zxY`M=Y|) zQemg`g@t(XIy@Fyv2TY1fai%Pud!5E4_`R(dR=lFB0sWZbi@;Pq2Y13;#o4R;PVsi zYh{F5?ngP_lF=#5WYu*A{OKKeeF`n@Yb5T8&60Foe$E5c7cLpo>8ofO@H--GTo}wh?R~d z8o4W{@8H&#P|`b$$0+bdfD8c+?7}R06|fkj5taF9%Rg|dTMAe3nIom=0v71Np{&41NIYJ zKt>V^H~K5`*UAXBoPz2Ykgo$3S$ujMum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Syi0000 + + + + + image/svg+xml + + + + + + + + + + + + + From d855c38e078f2cd0bec86d5a20fc2f448799433b Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Tue, 28 Aug 2018 15:58:27 +0200 Subject: [PATCH 2/6] Moves the logo files to logo Signed-off-by: Michael Weimann --- apps/theming/lib/ImageManager.php | 7 ++++--- apps/theming/lib/ThemingDefaults.php | 8 ++++---- apps/theming/tests/ImageManagerTest.php | 6 +++--- apps/theming/tests/ThemingDefaultsTest.php | 4 ++-- core/Controller/LoginController.php | 2 +- core/Controller/SvgController.php | 5 ++--- core/css/guest.css | 2 +- core/img/logo-blue.png | Bin 6112 -> 0 bytes core/img/logo.svg | 1 - core/img/{ => logo}/logo-icon-175px.png | Bin core/img/{ => logo}/logo-mail.png | Bin core/img/{ => logo}/logo.png | Bin core/img/{logo-blue.svg => logo/logo.svg} | 17 ++++++----------- lib/private/legacy/defaults.php | 4 ++-- tests/lib/Files/Cache/ScannerTest.php | 4 ++-- tests/lib/Files/Cache/UpdaterLegacyTest.php | 8 ++++---- tests/lib/Files/Cache/WatcherTest.php | 2 +- .../lib/Files/ObjectStore/NoopScannerTest.php | 2 +- tests/lib/Files/ViewTest.php | 4 ++-- 19 files changed, 35 insertions(+), 41 deletions(-) delete mode 100644 core/img/logo-blue.png delete mode 100644 core/img/logo.svg rename core/img/{ => logo}/logo-icon-175px.png (100%) rename core/img/{ => logo}/logo-mail.png (100%) rename core/img/{ => logo}/logo.png (100%) rename core/img/{logo-blue.svg => logo/logo.svg} (82%) diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index 6a42c22aba..46598673f1 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -80,12 +80,13 @@ class ImageManager { } switch ($key) { + case 'logo-blue': + // the blue logo is only available as svg + return $this->urlGenerator->getAbsoluteURL('svg/core/logo/logo/0082C9') . '?v=' . $cacheBusterCounter; case 'logo': case 'logoheader': case 'favicon': - return $this->urlGenerator->imagePath('core', 'logo.png') . '?v=' . $cacheBusterCounter; - case 'logo-blue': - return $this->urlGenerator->imagePath('core', 'logo-blue.png') . '?v=' . $cacheBusterCounter; + return $this->urlGenerator->imagePath('core', 'logo/logo.png') . '?v=' . $cacheBusterCounter; case 'background': return $this->urlGenerator->imagePath('core', 'background.png') . '?v=' . $cacheBusterCounter; } diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 5a14e8a790..7a26b46516 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -217,9 +217,9 @@ class ThemingDefaults extends \OC_Defaults { if(!$logo || !$logoExists) { if($useSvg) { - $logo = $this->urlGenerator->imagePath('core', 'logo.svg'); + $logo = $this->urlGenerator->imagePath('core', 'logo/logo.svg'); } else { - $logo = $this->urlGenerator->imagePath('core', 'logo.png'); + $logo = $this->urlGenerator->imagePath('core', 'logo/logo.png'); } return $logo . '?v=' . $cacheBusterCounter; } @@ -312,9 +312,9 @@ class ThemingDefaults extends \OC_Defaults { $primaryColor = $this->getColorPrimary(); $luminance = $this->util->calculateLuminance($primaryColor); if ($logoMime === '' & $luminance > 0.8) { - return $this->imageManager->getImageUrl('logo-blue'); + return $this->imageManager->getImageUrl('logo-blue', true); } else { - return $this->imageManager->getImageUrl('logo'); + return $this->imageManager->getImageUrl('logo', true); } } diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php index 38f5fb0496..fc9eac7f14 100644 --- a/apps/theming/tests/ImageManagerTest.php +++ b/apps/theming/tests/ImageManagerTest.php @@ -144,9 +144,9 @@ class ImageManagerTest extends TestCase { ->willReturnOnConsecutiveCalls(0, false); $this->urlGenerator->expects($this->once()) ->method('imagePath') - ->with('core', 'logo.png') - ->willReturn('logo.png'); - $this->assertEquals('logo.png?v=0', $this->imageManager->getImageUrl('logo')); + ->with('core', 'logo/logo.png') + ->willReturn('logo/logo.png'); + $this->assertEquals('logo/logo.png?v=0', $this->imageManager->getImageUrl('logo')); } public function testGetImageUrlAbsolute() { diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index fc3a737c3c..3da39fbbf2 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -593,11 +593,11 @@ class ThemingDefaultsTest extends TestCase { } public function testGetLogoDefaultWithSvg() { - $this->getLogoHelper('logo.svg', true); + $this->getLogoHelper('logo/logo.svg', true); } public function testGetLogoDefaultWithoutSvg() { - $this->getLogoHelper('logo.png', false); + $this->getLogoHelper('logo/logo.png', false); } public function testGetLogoCustom() { diff --git a/core/Controller/LoginController.php b/core/Controller/LoginController.php index 09b6fe5438..fed97177ee 100644 --- a/core/Controller/LoginController.php +++ b/core/Controller/LoginController.php @@ -194,7 +194,7 @@ class LoginController extends Controller { Util::addHeader('meta', ['property' => 'og:site_name', 'content' => Util::sanitizeHTML($this->defaults->getName())]); Util::addHeader('meta', ['property' => 'og:url', 'content' => $this->urlGenerator->getAbsoluteURL('/')]); Util::addHeader('meta', ['property' => 'og:type', 'content' => 'website']); - Util::addHeader('meta', ['property' => 'og:image', 'content' => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core','favicon-touch.png'))]); + Util::addHeader('meta', ['property' => 'og:image', 'content' => $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'favicon-touch.png'))]); return new TemplateResponse( $this->appName, 'login', $parameters, 'guest' diff --git a/core/Controller/SvgController.php b/core/Controller/SvgController.php index 1fad9c39c3..f0fc1dac4d 100644 --- a/core/Controller/SvgController.php +++ b/core/Controller/SvgController.php @@ -91,7 +91,7 @@ class SvgController extends Controller { $appRootPath = $this->appManager->getAppPath($app); $appPath = substr($appRootPath, strlen($this->serverRoot)); - + if (!$appPath) { return new NotFoundResponse(); } @@ -119,8 +119,7 @@ class SvgController extends Controller { } // add fill (fill is not present on black elements) - $fillRe = '/<((circle|rect|path)((?!fill)[a-z0-9 =".\-#():;])+)\/>/mi'; - + $fillRe = '/<((circle|rect|path)((!fill)[a-z0-9 =".\-#():;])+)\/>/mi'; $svg = preg_replace($fillRe, '<$1 fill="#' . $color . '"/>', $svg); // replace any fill or stroke colors diff --git a/core/css/guest.css b/core/css/guest.css index fc926688c4..52386e904c 100644 --- a/core/css/guest.css +++ b/core/css/guest.css @@ -69,7 +69,7 @@ body { } #header .logo { - background-image: url('../img/logo.svg?v=1'); + background-image: url('../img/logo/logo.svg?v=1'); background-repeat: no-repeat; background-size: 175px; background-position: center; diff --git a/core/img/logo-blue.png b/core/img/logo-blue.png deleted file mode 100644 index e1b7352b3f670df14fbc7ddc841744bda21f848e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6112 zcmV<67a!<}P)7i~#I zK~#9!?VWpgRMpkSf9p&V2!xC6r=YEhSFmbnHOvI0wLxvIms+dh6>s&atyV-@#0xVy z$)JL?pxB$W`q_$95UsXawN+x<05g-Q^;0Vst%6ph`XG>SP3Elck3p16LK0@5IWx20 z|CG$x=e&Epd+oI^Yk`G@g@uKMg@uKMMIJ*e1x1GG3(Hwo)*FDnTh=pv#70Ys6}&}0 z!c7e%lpcc0;V6eAG6XmX=neD*`T@=kzw&^!Kr_$+yp8JX2ul%NiX*RcbJZ$Kt`)pR z&IR6hFi!eJL`I^F0zPM`r4N84LIbML5{;R|Xq+cbT zxY`M=Y|) zQemg`g@t(XIy@Fyv2TY1fai%Pud!5E4_`R(dR=lFB0sWZbi@;Pq2Y13;#o4R;PVsi zYh{F5?ngP_lF=#5WYu*A{OKKeeF`n@Yb5T8&60Foe$E5c7cLpo>8ofO@H--GTo}wh?R~d z8o4W{@8H&#P|`b$$0+bdfD8c+?7}R06|fkj5taF9%Rg|dTMAe3nIom=0v71Np{&41NIYJ zKt>V^H~K5`*UAXBoPz2Ykgo$3S$ujMumE&6UXQtc9Wgd9_`1g9z#9jg4*0PM^C2n^ z5^9~nq~n(RG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ity index 100% rename from core/img/logo-icon-175px.png rename to core/img/logo/logo-icon-175px.png diff --git a/core/img/logo-mail.png b/core/img/logo/logo-mail.png similarity index 100% rename from core/img/logo-mail.png rename to core/img/logo/logo-mail.png diff --git a/core/img/logo.png b/core/img/logo/logo.png similarity index 100% rename from core/img/logo.png rename to core/img/logo/logo.png diff --git a/core/img/logo-blue.svg b/core/img/logo/logo.svg similarity index 82% rename from core/img/logo-blue.svg rename to core/img/logo/logo.svg index 66b17330d1..dda265dfa1 100644 --- a/core/img/logo-blue.svg +++ b/core/img/logo/logo.svg @@ -12,7 +12,7 @@ width="256" viewBox="0 0 256 128" id="svg10" - sodipodi:docname="logo-blue.svg" + sodipodi:docname="logo.svg" inkscape:version="0.92.3 (2405546, 2018-03-11)"> @@ -22,7 +22,6 @@ image/svg+xml - @@ -43,7 +42,7 @@ showgrid="false" inkscape:zoom="1.4296875" inkscape:cx="128" - inkscape:cy="64" + inkscape:cy="91.978142" inkscape:window-x="0" inkscape:window-y="27" inkscape:window-maximized="1" @@ -52,25 +51,21 @@ stroke="#fff" stroke-width="22" fill="none" - id="g8" - style="stroke:#0082c9;stroke-opacity:1"> + id="g8"> + id="circle2" /> + id="circle4" /> + id="circle6" /> diff --git a/lib/private/legacy/defaults.php b/lib/private/legacy/defaults.php index 3a22c91a8d..0c95c1b81b 100644 --- a/lib/private/legacy/defaults.php +++ b/lib/private/legacy/defaults.php @@ -315,9 +315,9 @@ class OC_Defaults { } if($useSvg) { - $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.svg'); + $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.svg'); } else { - $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo.png'); + $logo = \OC::$server->getURLGenerator()->imagePath('core', 'logo/logo.png'); } return $logo . '?v=' . hash('sha1', implode('.', \OCP\Util::getVersion())); } diff --git a/tests/lib/Files/Cache/ScannerTest.php b/tests/lib/Files/Cache/ScannerTest.php index 075716f803..736df2174d 100644 --- a/tests/lib/Files/Cache/ScannerTest.php +++ b/tests/lib/Files/Cache/ScannerTest.php @@ -60,7 +60,7 @@ class ScannerTest extends \Test\TestCase { $this->assertEquals($cachedData['mimetype'], 'text/plain'); $this->assertNotEquals($cachedData['parent'], -1); //parent folders should be scanned automatically - $data = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); + $data = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $this->storage->file_put_contents('foo.png', $data); $this->scanner->scanFile('foo.png'); @@ -98,7 +98,7 @@ class ScannerTest extends \Test\TestCase { private function fillTestFolders() { $textData = "dummy file data\n"; - $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); + $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $this->storage->mkdir('folder'); $this->storage->file_put_contents('foo.txt', $textData); $this->storage->file_put_contents('foo.png', $imgData); diff --git a/tests/lib/Files/Cache/UpdaterLegacyTest.php b/tests/lib/Files/Cache/UpdaterLegacyTest.php index 707ed70af2..66fa8d5193 100644 --- a/tests/lib/Files/Cache/UpdaterLegacyTest.php +++ b/tests/lib/Files/Cache/UpdaterLegacyTest.php @@ -42,7 +42,7 @@ class UpdaterLegacyTest extends \Test\TestCase { $this->storage = new \OC\Files\Storage\Temporary(array()); $textData = "dummy file data\n"; - $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); + $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $this->storage->mkdir('folder'); $this->storage->file_put_contents('foo.txt', $textData); $this->storage->file_put_contents('foo.png', $imgData); @@ -84,7 +84,7 @@ class UpdaterLegacyTest extends \Test\TestCase { public function testWrite() { $textSize = strlen("dummy file data\n"); - $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png'); + $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $this->cache->put('foo.txt', array('mtime' => 100, 'storage_mtime' => 150)); $rootCachedData = $this->cache->get(''); $this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']); @@ -145,7 +145,7 @@ class UpdaterLegacyTest extends \Test\TestCase { public function testDelete() { $textSize = strlen("dummy file data\n"); - $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png'); + $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $rootCachedData = $this->cache->get(''); $oldEtag = $rootCachedData['etag']; $this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']); @@ -206,7 +206,7 @@ class UpdaterLegacyTest extends \Test\TestCase { public function testRename() { $textSize = strlen("dummy file data\n"); - $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png'); + $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $rootCachedData = $this->cache->get(''); $this->assertEquals(3 * $textSize + $imageSize, $rootCachedData['size']); diff --git a/tests/lib/Files/Cache/WatcherTest.php b/tests/lib/Files/Cache/WatcherTest.php index 3834b5591f..d4aa9ac875 100644 --- a/tests/lib/Files/Cache/WatcherTest.php +++ b/tests/lib/Files/Cache/WatcherTest.php @@ -179,7 +179,7 @@ class WatcherTest extends \Test\TestCase { private function getTestStorage($scan = true) { $storage = new \OC\Files\Storage\Temporary(array()); $textData = "dummy file data\n"; - $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); + $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $storage->mkdir('folder'); $storage->file_put_contents('foo.txt', $textData); $storage->file_put_contents('foo.png', $imgData); diff --git a/tests/lib/Files/ObjectStore/NoopScannerTest.php b/tests/lib/Files/ObjectStore/NoopScannerTest.php index 16bd325a8d..6d593225e9 100644 --- a/tests/lib/Files/ObjectStore/NoopScannerTest.php +++ b/tests/lib/Files/ObjectStore/NoopScannerTest.php @@ -38,7 +38,7 @@ class NoopScannerTest extends \Test\TestCase { private function fillTestFolders() { $textData = "dummy file data\n"; - $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); + $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $this->storage->mkdir('folder'); $this->storage->file_put_contents('foo.txt', $textData); $this->storage->file_put_contents('foo.png', $imgData); diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 9b435f2b93..97e3d42684 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -142,7 +142,7 @@ class ViewTest extends \Test\TestCase { Filesystem::mount($storage2, array(), $root . '/substorage'); Filesystem::mount($storage3, array(), $root . '/folder/anotherstorage'); $textSize = strlen("dummy file data\n"); - $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo.png'); + $imageSize = filesize(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $storageSize = $textSize * 2 + $imageSize; $storageInfo = $storage3->getCache()->get(''); @@ -658,7 +658,7 @@ class ViewTest extends \Test\TestCase { */ $storage = new $class(array()); $textData = "dummy file data\n"; - $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo.png'); + $imgData = file_get_contents(\OC::$SERVERROOT . '/core/img/logo/logo.png'); $storage->mkdir('folder'); $storage->file_put_contents('foo.txt', $textData); $storage->file_put_contents('foo.png', $imgData); From c7e81e17c86a6e6beff433238a6923f5d931c22f Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Tue, 28 Aug 2018 18:21:17 +0200 Subject: [PATCH 3/6] Updates inverted logo handling to work like the app icons Signed-off-by: Michael Weimann --- apps/theming/css/theming.scss | 26 +++++++- apps/theming/lib/ImageManager.php | 3 - apps/theming/lib/ThemingDefaults.php | 21 +------ apps/theming/tests/ThemingDefaultsTest.php | 67 +------------------- core/img/logo/logo.svg | 72 +--------------------- 5 files changed, 27 insertions(+), 162 deletions(-) diff --git a/apps/theming/css/theming.scss b/apps/theming/css/theming.scss index b1b8896d0c..35341159f1 100644 --- a/apps/theming/css/theming.scss +++ b/apps/theming/css/theming.scss @@ -7,6 +7,17 @@ @return (0.2126 * $-local-red + 0.7152 * $-local-green + 0.0722 * $-local-blue) / 255; } +$has-custom-logo: variable_exists('theming-logo-mime') and $theming-logo-mime != ''; +$invert: luma($color-primary) > 0.6; + +@if ($has-custom-logo == false) { + @if ($invert) { + $image-logo: url('../../../../svg/core/logo/logo/000000?v=1'); + } @else { + $image-logo: url('../../../../svg/core/logo/logo/ffffff?v=1'); + } +} + .nc-theming-main-background { background-color: $color-primary; } @@ -19,7 +30,7 @@ color: $color-primary-text; } -@if (luma($color-primary) > 0.6) { +@if ($invert) { #appmenu:not(.inverted) svg { filter: invert(1); } @@ -104,7 +115,8 @@ } /* override styles for login screen in guest.css */ -@if variable_exists('theming-logo-mime') and $theming-logo-mime != '' { +@if ($has-custom-logo) { + // custom logo #theming-preview-logo, #header .logo { background-size: contain; @@ -113,6 +125,14 @@ #body-login #header .logo { margin-bottom: 22px; } +} @else { + // default logo + @if ($invert) { + #theming-preview-logo, + #header .logo { + opacity: .6; + } + } } @if variable_exists('theming-background-mime') and $theming-background-mime != '' { @@ -157,7 +177,7 @@ input.primary, color: $color-primary-text; } -@if (luma($color-primary) > 0.6) { +@if ($invert) { #body-login #submit-wrapper .icon-confirm-white { background-image: url('../../../core/img/actions/confirm.svg'); } diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index 46598673f1..75c978f2ad 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -80,9 +80,6 @@ class ImageManager { } switch ($key) { - case 'logo-blue': - // the blue logo is only available as svg - return $this->urlGenerator->getAbsoluteURL('svg/core/logo/logo/0082C9') . '?v=' . $cacheBusterCounter; case 'logo': case 'logoheader': case 'favicon': diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 7a26b46516..0573f7b84d 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -33,7 +33,6 @@ namespace OCA\Theming; - use OCP\App\AppPathNotFoundException; use OCP\App\IAppManager; use OCP\Files\NotFoundException; @@ -275,7 +274,7 @@ class ThemingDefaults extends \OC_Defaults { 'theming-favicon-mime' => "'" . $this->config->getAppValue('theming', 'faviconMime') . "'" ]; - $variables['image-logo'] = "url('". $this->getLogoUrl() ."')"; + $variables['image-logo'] = "url('".$this->imageManager->getImageUrl('logo')."')"; $variables['image-logoheader'] = "'".$this->imageManager->getImageUrl('logoheader')."'"; $variables['image-favicon'] = "'".$this->imageManager->getImageUrl('favicon')."'"; $variables['image-login-background'] = "url('".$this->imageManager->getImageUrl('background')."')"; @@ -300,24 +299,6 @@ class ThemingDefaults extends \OC_Defaults { return $variables; } - /** - * Returns the logo url. - * If there is a custom logo, it just returns it. - * For the default logo it returns the white or blue one depending on the color luminance. - * - * @return string - */ - private function getLogoUrl() { - $logoMime = $this->config->getAppValue('theming', 'logoMime'); - $primaryColor = $this->getColorPrimary(); - $luminance = $this->util->calculateLuminance($primaryColor); - if ($logoMime === '' & $luminance > 0.8) { - return $this->imageManager->getImageUrl('logo-blue', true); - } else { - return $this->imageManager->getImageUrl('logo', true); - } - } - /** * Check if the image should be replaced by the theming app * and return the new image location then diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index 3da39fbbf2..68435dd148 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -632,66 +632,6 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals(['foo'=>'bar'], $this->template->getScssVariables()); } - /** - * Provides test data for the get logo scss variable test. - * - * @return array - */ - public function provideTestGetImageLogoScssVariableTestData(): array { - return [ - // default logo - ['', '#000000', 0.0, 'logo'], - ['', '#cccccc', 0.8, 'logo'], - ['', '#dddddd', 0.81, 'logo-blue'], - ['', '#ffffff', 1.0, 'logo-blue'], - - // custom logo - ['image/png', '#000000', 0.0, 'logo'], - ['image/png', '#cccccc', 0.8, 'logo'], - ['image/png', '#dddddd', 0.81, 'logo'], - ['image/png', '#ffffff', 1.0, 'logo'], - ]; - } - - /** - * Tests chat the logo url scss variable has the expected value - * depending on color and custom logo presence. - * - * @dataProvider provideTestGetImageLogoScssVariableTestData - * @param string $themingLogoMime The custom logo mime type - * @param string $primaryColor The primary theme color - * @param float $luminance The calculated luminance - * @param string $expected The expected requested logo - * @return void - */ - public function testGetImageLogoScssVariable( - string $themingLogoMime, - string $primaryColor, - float $luminance, - string $expected - ) { - $this->config->expects($this->at(5)) - ->method('getAppValue') - ->with('theming', 'logoMime') - ->willReturn($themingLogoMime); - $this->config->expects($this->at(6)) - ->method('getAppValue') - ->with('theming', 'color', $this->defaults->getColorPrimary()) - ->willReturn($primaryColor); - - $this->util - ->method('calculateLuminance') - ->with($primaryColor) - ->willReturn($luminance); - - $this->imageManager->expects($this->at(0)) - ->method('getImageUrl') - ->with($expected) - ->willReturn('custom-logo?v=0'); - - $this->template->getScssVariables(); - } - public function testGetScssVariables() { $this->config->expects($this->at(0))->method('getAppValue')->with('theming', 'cachebuster', '0')->willReturn('0'); $this->config->expects($this->at(1))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg'); @@ -699,13 +639,10 @@ class ThemingDefaultsTest extends TestCase { $this->config->expects($this->at(3))->method('getAppValue')->with('theming', 'logoheaderMime', false)->willReturn('jpeg'); $this->config->expects($this->at(4))->method('getAppValue')->with('theming', 'faviconMime', false)->willReturn('jpeg'); - $this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'logoMime', false)->willReturn('jpeg'); + $this->config->expects($this->at(5))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary()); $this->config->expects($this->at(6))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); - - $this->config->expects($this->at(7))->method('getAppValue')->with('theming', 'color', null)->willReturn($this->defaults->getColorPrimary()); + $this->config->expects($this->at(7))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); $this->config->expects($this->at(8))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); - $this->config->expects($this->at(9))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); - $this->config->expects($this->at(10))->method('getAppValue')->with('theming', 'color', $this->defaults->getColorPrimary())->willReturn($this->defaults->getColorPrimary()); $this->util->expects($this->any())->method('invertTextColor')->with($this->defaults->getColorPrimary())->willReturn(false); $this->util->expects($this->any())->method('elementColor')->with($this->defaults->getColorPrimary())->willReturn('#aaaaaa'); diff --git a/core/img/logo/logo.svg b/core/img/logo/logo.svg index dda265dfa1..dbc3e7f3f8 100644 --- a/core/img/logo/logo.svg +++ b/core/img/logo/logo.svg @@ -1,71 +1 @@ - - - - - - image/svg+xml - - - - - - - - - - - - + From a45ec3d32430f40be93fa5f09832917b82c83f15 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Thu, 30 Aug 2018 20:00:13 +0200 Subject: [PATCH 4/6] Refactors the scss svg functions Signed-off-by: Michael Weimann --- apps/theming/css/theming.scss | 4 +- core/Controller/SvgController.php | 4 +- core/css/functions.scss | 52 ++++++-- core/img/logo/logo.svg | 2 +- tests/Core/Controller/SvgControllerTest.php | 139 ++++++++++++++++++++ tests/data/svg/mixed-red.svg | 1 + tests/data/svg/mixed-source.svg | 1 + tests/data/svg/rect-black.svg | 1 + tests/data/svg/rect-red.svg | 1 + 9 files changed, 185 insertions(+), 20 deletions(-) create mode 100644 tests/Core/Controller/SvgControllerTest.php create mode 100644 tests/data/svg/mixed-red.svg create mode 100644 tests/data/svg/mixed-source.svg create mode 100644 tests/data/svg/rect-black.svg create mode 100644 tests/data/svg/rect-red.svg diff --git a/apps/theming/css/theming.scss b/apps/theming/css/theming.scss index 35341159f1..e2cd8fb11e 100644 --- a/apps/theming/css/theming.scss +++ b/apps/theming/css/theming.scss @@ -12,9 +12,9 @@ $invert: luma($color-primary) > 0.6; @if ($has-custom-logo == false) { @if ($invert) { - $image-logo: url('../../../../svg/core/logo/logo/000000?v=1'); + $image-logo: url(icon-color-path('logo', 'logo', #000000, 1, true)); } @else { - $image-logo: url('../../../../svg/core/logo/logo/ffffff?v=1'); + $image-logo: url(icon-color-path('logo', 'logo', #ffffff, 1, true)); } } diff --git a/core/Controller/SvgController.php b/core/Controller/SvgController.php index f0fc1dac4d..c6bf7b94da 100644 --- a/core/Controller/SvgController.php +++ b/core/Controller/SvgController.php @@ -29,7 +29,6 @@ use OCP\AppFramework\Http; use OCP\AppFramework\Http\DataDisplayResponse; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Utility\ITimeFactory; -use OCP\Files\NotFoundException; use OCP\App\IAppManager; use OCP\IRequest; @@ -99,7 +98,6 @@ class SvgController extends Controller { return $this->getSvg($path, $color, $fileName); } - /** * Generate svg from filename with the requested color * @@ -119,7 +117,7 @@ class SvgController extends Controller { } // add fill (fill is not present on black elements) - $fillRe = '/<((circle|rect|path)((!fill)[a-z0-9 =".\-#():;])+)\/>/mi'; + $fillRe = '/<((circle|rect|path)((?!fill)[a-z0-9 =".\-#():;])+)\/>/mi'; $svg = preg_replace($fillRe, '<$1 fill="#' . $color . '"/>', $svg); // replace any fill or stroke colors diff --git a/core/css/functions.scss b/core/css/functions.scss index 0815ba29ab..5007c3bbe7 100644 --- a/core/css/functions.scss +++ b/core/css/functions.scss @@ -19,31 +19,55 @@ * along with this program. If not, see . * */ - + +/** + * Removes the "#" from a color. + * + * @param string $color The color + * @return string The color without # + */ +@function remove-hash-from-color($color) { + $index: str-index(inspect($color), '#'); + @if $index { + $color: str-slice(inspect($color), 2); + } + @return $color; +} + +/** + * Calculates the URL to the svg under the SVG API. + * + * @param string $icon the icon filename + * @param string $dir the icon folder within /core/img if $core or app name + * @param string $color the desired color in hexadecimal + * @param int [$version] the version of the file + * @param bool [$core] search icon in core + * @return string The URL to the svg. + */ +@function icon-color-path($icon, $dir, $color, $version: 1, $core: false) { + $color: remove-hash-from-color($color); + @if $core { + @return '#{$webroot}/svg/core/#{$dir}/#{$icon}/#{$color}?v=#{$version}'; + } @else { + @return '#{$webroot}/svg/#{$dir}/#{$icon}/#{$color}?v=#{$version}'; + } +} + /** * SVG COLOR API - * + * * @param string $icon the icon filename * @param string $dir the icon folder within /core/img if $core or app name * @param string $color the desired color in hexadecimal * @param int $version the version of the file * @param bool [$core] search icon in core * - * @returns string the url to the svg api endpoint + * @returns A background image with the url to the set to the requested icon. */ @mixin icon-color($icon, $dir, $color, $version: 1, $core: false) { - // remove # from color - // inspect cast int to string - $index: str-index(inspect($color), '#'); - @if $index { - $color: str-slice(inspect($color), 2); - } + $color: remove-hash-from-color($color); $varName: "--icon-#{$icon}-#{$color}"; - @if $core { - #{$varName}: url('#{$webroot}/svg/core/#{$dir}/#{$icon}/#{$color}?v=#{$version}'); - } @else { - #{$varName}: url('#{$webroot}/svg/#{$dir}/#{$icon}/#{$color}?v=#{$version}'); - } + #{$varName}: url(icon-color-path($icon, $dir, $color, $version, $core)); background-image: var(#{$varName}); } diff --git a/core/img/logo/logo.svg b/core/img/logo/logo.svg index dbc3e7f3f8..076f295e4d 100644 --- a/core/img/logo/logo.svg +++ b/core/img/logo/logo.svg @@ -1 +1 @@ - + diff --git a/tests/Core/Controller/SvgControllerTest.php b/tests/Core/Controller/SvgControllerTest.php new file mode 100644 index 0000000000..7a31d02b90 --- /dev/null +++ b/tests/Core/Controller/SvgControllerTest.php @@ -0,0 +1,139 @@ + + * + * @author Michael Weimann + * + * @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 . + * + */ + +namespace Tests\Core\Controller; + +use OC\AppFramework\Http; +use OC\Core\Controller\SvgController; +use OCP\App\IAppManager; +use OCP\AppFramework\Utility\ITimeFactory; +use OCP\IRequest; +use Test\TestCase; + +/** + * This class provides test cases for the svg controller + */ +class SvgControllerTest extends TestCase { + + const TEST_IMAGES_SOURCE_PATH = __DIR__ . '/../../data/svg'; + const TEST_IMAGES_PATH = __DIR__ . '/../../../core/img/testImages'; + const TEST_IMAGE_MIXED = 'mixed-source.svg'; + const TEST_IMAGE_RECT = 'rect-black.svg'; + const TEST_IMAGES = [ + self::TEST_IMAGE_MIXED, + self::TEST_IMAGE_RECT, + ]; + + /** + * @var SvgController + */ + private $svgController; + + /** + * Copy test svgs into the core img "test" directory. + * + * @beforeClass + * @return void + */ + public static function copyTestImagesIntoPlace() { + mkdir(self::TEST_IMAGES_PATH); + foreach (self::TEST_IMAGES as $testImage) { + copy( + self::TEST_IMAGES_SOURCE_PATH .'/' . $testImage, + self::TEST_IMAGES_PATH . '/' . $testImage + ); + } + } + + /** + * Removes the test svgs from the core img "test" directory. + * + * @afterClass + * @return void + */ + public static function removeTestImages() { + foreach (self::TEST_IMAGES as $testImage) { + unlink(self::TEST_IMAGES_PATH . '/' . $testImage); + } + rmdir(self::TEST_IMAGES_PATH); + } + + /** + * Setups a SVG controller instance for tests. + * + * @before + * @return void + */ + public function setupSvgController() { + $request = $this->getMockBuilder(IRequest::class)->getMock(); + $timeFactory = $this->getMockBuilder(ITimeFactory::class)->getMock(); + $appManager = $this->getMockBuilder(IAppManager::class)->getMock(); + $this->svgController = new SvgController('core', $request, $timeFactory, $appManager); + } + + /** + * Checks that requesting an unknown image results in a 404. + * + * @test + * @return void + */ + public function testGetSvgFromCoreNotFound() { + $response = $this->svgController->getSvgFromCore('huhuu', '2342', '#ff0000'); + self::assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus()); + } + + /** + * Provides svg coloring test data. + * + * @return array + */ + public function provideGetSvgFromCoreTestData(): array { + return [ + 'mixed' => ['mixed-source', 'f00', file_get_contents(self::TEST_IMAGES_SOURCE_PATH . '/mixed-red.svg')], + 'black rect' => ['rect-black', 'f00', file_get_contents(self::TEST_IMAGES_SOURCE_PATH . '/rect-red.svg')], + ]; + } + + /** + * Tests that retrieving a colored SVG works. + * + * @test + * @dataProvider provideGetSvgFromCoreTestData + * @param string $name The requested svg name + * @param string $color The requested color + * @param string $expected The expected svg + * @return void + */ + public function testGetSvgFromCore(string $name, string $color, string $expected) { + $response = $this->svgController->getSvgFromCore('testImages', $name, $color); + + self::assertEquals(Http::STATUS_OK, $response->getStatus()); + + $headers = $response->getHeaders(); + self::assertArrayHasKey('Content-Type', $headers); + self::assertEquals($headers['Content-Type'], 'image/svg+xml'); + + self::assertEquals($expected, $response->getData()); + } +} diff --git a/tests/data/svg/mixed-red.svg b/tests/data/svg/mixed-red.svg new file mode 100644 index 0000000000..5e3727abd4 --- /dev/null +++ b/tests/data/svg/mixed-red.svg @@ -0,0 +1 @@ + diff --git a/tests/data/svg/mixed-source.svg b/tests/data/svg/mixed-source.svg new file mode 100644 index 0000000000..e4a94136c5 --- /dev/null +++ b/tests/data/svg/mixed-source.svg @@ -0,0 +1 @@ + diff --git a/tests/data/svg/rect-black.svg b/tests/data/svg/rect-black.svg new file mode 100644 index 0000000000..85ab8442c3 --- /dev/null +++ b/tests/data/svg/rect-black.svg @@ -0,0 +1 @@ + diff --git a/tests/data/svg/rect-red.svg b/tests/data/svg/rect-red.svg new file mode 100644 index 0000000000..8f0fae7f61 --- /dev/null +++ b/tests/data/svg/rect-red.svg @@ -0,0 +1 @@ + From 065e0c0e491d819658b5e7128fff967244db6681 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Wed, 3 Oct 2018 19:26:47 +0200 Subject: [PATCH 5/6] Fixes the logo test Signed-off-by: Michael Weimann --- apps/theming/tests/UtilTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php index 61d1dc4830..6348f8423e 100644 --- a/apps/theming/tests/UtilTest.php +++ b/apps/theming/tests/UtilTest.php @@ -92,7 +92,7 @@ class UtilTest extends TestCase { $invert = $this->util->invertTextColor('aaabbbcccddd123'); $this->assertEquals(false, $invert); } - + public function testInvertTextColorEmpty() { $invert = $this->util->invertTextColor(''); $this->assertEquals(false, $invert); @@ -174,7 +174,7 @@ class UtilTest extends TestCase { public function dataGetAppImage() { return [ - ['core', 'logo.svg', \OC::$SERVERROOT . '/core/img/logo.svg'], + ['core', 'logo/logo.svg', \OC::$SERVERROOT . '/core/img/logo/logo.svg'], ['files', 'external', \OC::$SERVERROOT . '/apps/files/img/external.svg'], ['files', 'external.svg', \OC::$SERVERROOT . '/apps/files/img/external.svg'], ['noapplikethis', 'foobar.svg', false], From 044ab0cbecf46d537e892dfa4efd862182798291 Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Thu, 4 Oct 2018 20:43:27 +0200 Subject: [PATCH 6/6] Adapts the theming util to the new core logo image path Signed-off-by: Michael Weimann --- apps/theming/lib/Util.php | 4 ++-- apps/theming/tests/UtilTest.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php index b17382334d..38b876f361 100644 --- a/apps/theming/lib/Util.php +++ b/apps/theming/lib/Util.php @@ -161,7 +161,7 @@ class Util { } } catch (NotFoundException $e) {} } - return \OC::$SERVERROOT . '/core/img/logo.svg'; + return \OC::$SERVERROOT . '/core/img/logo/logo.svg'; } /** @@ -223,7 +223,7 @@ class Util { /** * Check if a custom theme is set in the server configuration - * + * * @return bool */ public function isAlreadyThemed() { diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php index 6348f8423e..d0263e1122 100644 --- a/apps/theming/tests/UtilTest.php +++ b/apps/theming/tests/UtilTest.php @@ -139,7 +139,7 @@ class UtilTest extends TestCase { public function dataGetAppIcon() { return [ ['user_ldap', \OC_App::getAppPath('user_ldap') . '/img/app.svg'], - ['noapplikethis', \OC::$SERVERROOT . '/core/img/logo.svg'], + ['noapplikethis', \OC::$SERVERROOT . '/core/img/logo/logo.svg'], ['comments', \OC_App::getAppPath('comments') . '/img/comments.svg'], ]; }