]> source.dussan.org Git - nextcloud-server.git/commitdiff
Theming: Clean up css generation and fix tests
authorJulius Haertl <jus@bitgrid.net>
Tue, 19 Jul 2016 12:39:53 +0000 (14:39 +0200)
committerJulius Haertl <jus@bitgrid.net>
Wed, 27 Jul 2016 17:54:54 +0000 (19:54 +0200)
apps/theming/lib/controller/themingcontroller.php
apps/theming/tests/lib/controller/ThemingControllerTest.php

index 32d96203d62405e9069788d823f60043115dabd9..ed3e23b0c1f15337818aea5819fb6c796ac5d265 100644 (file)
@@ -217,41 +217,39 @@ class ThemingController extends Controller {
                $elementColor = Util::elementColor($color);
                if($color !== '') {
                        $responseCss .= sprintf(
-                               '#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: %s}',
+                               '#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: %s}'."\n",
                                $color
                        );
-                       $responseCss .= sprintf('
-                               input[type="checkbox"].checkbox:checked + label:before {
-                                       background-image:url(\'' . \OC::$WEBROOT . '/core/img/actions/checkmark-white.svg\');
-                                       background-color: %s; background-position: center center; background-size:contain;
-                                       width:12px; height:12px; padding:0; margin:1px 6px 7px 2px;
-                       }',
+                       $responseCss .= sprintf('input[type="checkbox"].checkbox:checked + label:before {' .
+                               'background-image:url(\'' . \OC::$WEBROOT . '/core/img/actions/checkmark-white.svg\');' .
+                               'background-color: %s; background-position: center center; background-size:contain;' .
+                               'width:12px; height:12px; padding:0; margin:1px 6px 7px 2px;' .
+                       '}' . PHP_EOL,
                                $elementColor
                        );
                }
                $logo = $this->config->getAppValue($this->appName, 'logoMime');
                if($logo !== '') {
-                       $responseCss .= sprintf('#header .logo {
-                               background-image: url(\'./logo?v='.$cacheBusterValue.'\');
-                               background-size: contain;
-                       }
-                       #header .logo-icon {
-                               background-image: url(\'./logo?v='.$cacheBusterValue.'\');
-                               background-size: contain;
-                       }'
+                       $responseCss .= sprintf(
+                               '#header .logo {' .
+                               'background-image: url(\'./logo?v='.$cacheBusterValue.'\')' .
+                               'background-size: contain;' .
+                               '}' . PHP_EOL .
+                               '#header .logo-icon {' .
+                               'background-image: url(\'./logo?v='.$cacheBusterValue.'\');' .
+                               'background-size: contain;' .
+                               '}' . PHP_EOL
                        );
                }
                $backgroundLogo = $this->config->getAppValue($this->appName, 'backgroundMime');
                if($backgroundLogo !== '') {
-                       $responseCss .= '#body-login {
-                               background-image: url(\'./loginbackground?v='.$cacheBusterValue.'\');
-                       }';
+                       $responseCss .= '#body-login {background-image: url(\'./loginbackground?v='.$cacheBusterValue.'\');}' . PHP_EOL;
                }
                if(Util::invertTextColor($color)) {
-                       $responseCss .= '#header .header-appname, #expandDisplayName { color: #000000; } ';
-                       $responseCss .= '#header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); } ';
-                       $responseCss .= '.searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }';
-                       $responseCss .= '.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }';
+                       $responseCss .= '#header .header-appname, #expandDisplayName { color: #000000; }' . PHP_EOL;
+                       $responseCss .= '#header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); }' . PHP_EOL;
+                       $responseCss .= '.searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }' . PHP_EOL;
+                       $responseCss .= '.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }' . PHP_EOL;
                }
 
                \OC_Response::setExpiresHeader(gmdate('D, d M Y H:i:s', time() + (60*60*24*45)) . ' GMT');
index 24eb0510f9939d48cb1bd85e7ad578a804791cff..5ad6beb18e539819acea508775ac7691797ea862 100644 (file)
@@ -327,7 +327,13 @@ class ThemingControllerTest extends TestCase {
                        ->with('theming', 'backgroundMime', '')
                        ->willReturn('');
 
-               $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: #000}', 'style', 'text/css');
+               $expectedCss = '#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: #000}' . PHP_EOL .
+                       'input[type="checkbox"].checkbox:checked + label:before {' .
+                       'background-image:url(\'' . \OC::$WEBROOT . '/core/img/actions/checkmark-white.svg\');' .
+                       'background-color: #000; background-position: center center; background-size:contain;' .
+                       'width:12px; height:12px; padding:0; margin:1px 6px 7px 2px;' .
+                       '}' . PHP_EOL;
+               $expected = new Http\DataDownloadResponse($expectedCss, 'style', 'text/css');
                $expected->cacheFor(3600);
                @$this->assertEquals($expected, $this->themingController->getStylesheet());
        }
@@ -354,7 +360,17 @@ class ThemingControllerTest extends TestCase {
                        ->with('theming', 'backgroundMime', '')
                        ->willReturn('');
 
-               $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: #fff}#header .header-appname, #expandDisplayName { color: #000000; } #header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); } .searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }', 'style', 'text/css');
+               $expectedCss = '#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: #fff}' . PHP_EOL .
+                       'input[type="checkbox"].checkbox:checked + label:before {' .
+                       'background-image:url(\'' . \OC::$WEBROOT . '/core/img/actions/checkmark-white.svg\');' .
+                       'background-color: #969696; background-position: center center; background-size:contain;' .
+                       'width:12px; height:12px; padding:0; margin:1px 6px 7px 2px;' .
+                       '}' . PHP_EOL .
+                       '#header .header-appname, #expandDisplayName { color: #000000; }' . PHP_EOL .
+                       '#header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); }' . PHP_EOL .
+                       '.searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }' . PHP_EOL .
+                       '.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }' . PHP_EOL;
+               $expected = new Http\DataDownloadResponse($expectedCss, 'style', 'text/css');
                $expected->cacheFor(3600);
                @$this->assertEquals($expected, $this->themingController->getStylesheet());
        }
@@ -381,14 +397,15 @@ class ThemingControllerTest extends TestCase {
                        ->with('theming', 'backgroundMime', '')
                        ->willReturn('');
 
-               $expected = new Http\DataDownloadResponse('#header .logo {
-                               background-image: url(\'./logo?v=0\');
-                               background-size: contain;
-                       }
-                       #header .logo-icon {
-                               background-image: url(\'./logo?v=0\');
-                               background-size: contain;
-                       }', 'style', 'text/css');
+               $expectedCss = '#header .logo {' .
+                       'background-image: url(\'./logo?v=0\')' .
+                       'background-size: contain;' .
+                       '}' . PHP_EOL .
+                       '#header .logo-icon {' .
+                       'background-image: url(\'./logo?v=0\');' .
+                       'background-size: contain;' .
+                       '}' . PHP_EOL;
+               $expected = new Http\DataDownloadResponse($expectedCss, 'style', 'text/css');
                $expected->cacheFor(3600);
                @$this->assertEquals($expected, $this->themingController->getStylesheet());
        }
@@ -415,9 +432,8 @@ class ThemingControllerTest extends TestCase {
                        ->with('theming', 'backgroundMime', '')
                        ->willReturn('text/svg');
 
-               $expected = new Http\DataDownloadResponse('#body-login {
-                               background-image: url(\'./loginbackground?v=0\');
-                       }', 'style', 'text/css');
+               $expectedCss = '#body-login {background-image: url(\'./loginbackground?v=0\');}' . PHP_EOL;
+               $expected = new Http\DataDownloadResponse($expectedCss, 'style', 'text/css');
                $expected->cacheFor(3600);
                @$this->assertEquals($expected, $this->themingController->getStylesheet());
        }
@@ -444,16 +460,23 @@ class ThemingControllerTest extends TestCase {
                        ->with('theming', 'backgroundMime', '')
                        ->willReturn('image/png');
 
-               $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: #000}#header .logo {
-                               background-image: url(\'./logo?v=0\');
-                               background-size: contain;
-                       }
-                       #header .logo-icon {
-                               background-image: url(\'./logo?v=0\');
-                               background-size: contain;
-                       }#body-login {
-                               background-image: url(\'./loginbackground?v=0\');
-                       }', 'style', 'text/css');
+               $expectedCss = '#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: #000}' . PHP_EOL .
+                       'input[type="checkbox"].checkbox:checked + label:before {' .
+                       'background-image:url(\'' . \OC::$WEBROOT . '/core/img/actions/checkmark-white.svg\');' .
+                       'background-color: #000; background-position: center center; background-size:contain;' .
+                       'width:12px; height:12px; padding:0; margin:1px 6px 7px 2px;' .
+                       '}' . PHP_EOL;
+               $expectedCss .= '#header .logo {' .
+                       'background-image: url(\'./logo?v=0\')' .
+                       'background-size: contain;' .
+                       '}' . PHP_EOL .
+                       '#header .logo-icon {' .
+                       'background-image: url(\'./logo?v=0\');' .
+                       'background-size: contain;' .
+                       '}' . PHP_EOL;
+               $expectedCss .= '#body-login {background-image: url(\'./loginbackground?v=0\');}' . PHP_EOL;
+
+               $expected = new Http\DataDownloadResponse($expectedCss, 'style', 'text/css');
                $expected->cacheFor(3600);
                @$this->assertEquals($expected, $this->themingController->getStylesheet());
        }
@@ -479,16 +502,27 @@ class ThemingControllerTest extends TestCase {
                        ->with('theming', 'backgroundMime', '')
                        ->willReturn('image/png');
 
-               $expected = new Http\DataDownloadResponse('#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: #fff}#header .logo {
-                               background-image: url(\'./logo?v=0\');
-                               background-size: contain;
-                       }
-                       #header .logo-icon {
-                               background-image: url(\'./logo?v=0\');
-                               background-size: contain;
-                       }#body-login {
-                               background-image: url(\'./loginbackground?v=0\');
-                       }#header .header-appname, #expandDisplayName { color: #000000; } #header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); } .searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }', 'style', 'text/css');
+
+               $expectedCss = '#body-user #header,#body-settings #header,#body-public #header,#body-login,.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid {background-color: #fff}' . PHP_EOL .
+                       'input[type="checkbox"].checkbox:checked + label:before {' .
+                       'background-image:url(\'' . \OC::$WEBROOT . '/core/img/actions/checkmark-white.svg\');' .
+                       'background-color: #969696; background-position: center center; background-size:contain;' .
+                       'width:12px; height:12px; padding:0; margin:1px 6px 7px 2px;' .
+                       '}' . PHP_EOL;
+               $expectedCss .= '#header .logo {' .
+                       'background-image: url(\'./logo?v=0\')' .
+                       'background-size: contain;' .
+                       '}' . PHP_EOL .
+                       '#header .logo-icon {' .
+                       'background-image: url(\'./logo?v=0\');' .
+                       'background-size: contain;' .
+                       '}' . PHP_EOL;
+               $expectedCss .= '#body-login {background-image: url(\'./loginbackground?v=0\');}' . PHP_EOL;
+               $expectedCss .= '#header .header-appname, #expandDisplayName { color: #000000; }' . PHP_EOL .
+                       '#header .icon-caret { background-image: url(\'' . \OC::$WEBROOT . '/core/img/actions/caret-dark.svg\'); }' . PHP_EOL .
+                       '.searchbox input[type="search"] { background: transparent url(\'' . \OC::$WEBROOT . '/core/img/actions/search.svg\') no-repeat 6px center; color: #000; }' . PHP_EOL .
+                       '.searchbox input[type="search"]:focus,.searchbox input[type="search"]:active,.searchbox input[type="search"]:valid { color: #000; border: 1px solid rgba(0, 0, 0, .5); }' . PHP_EOL;
+               $expected = new Http\DataDownloadResponse($expectedCss, 'style', 'text/css');
                $expected->cacheFor(3600);
                @$this->assertEquals($expected, $this->themingController->getStylesheet());
        }