diff options
author | Joas Schilling <coding@schilljs.com> | 2017-07-13 13:41:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-13 13:41:31 +0200 |
commit | e335121d5ead8b8a223ca12212529c2230bc1c5d (patch) | |
tree | 67c7d37db38d9147c4352ff55c66bffe7dfbe0cc /apps/theming | |
parent | f71457782b1c0e6aa66ba6b2aac126aa5a2bc9dc (diff) | |
parent | ce5ad7e7f48751b25ef9dd377fbbface2adb30b4 (diff) | |
download | nextcloud-server-e335121d5ead8b8a223ca12212529c2230bc1c5d.tar.gz nextcloud-server-e335121d5ead8b8a223ca12212529c2230bc1c5d.zip |
Merge pull request #5070 from nextcloud/theming-vs-themes
Prefer custom theme over the theming app
Diffstat (limited to 'apps/theming')
-rw-r--r-- | apps/theming/appinfo/app.php | 62 | ||||
-rw-r--r-- | apps/theming/lib/Util.php | 13 | ||||
-rw-r--r-- | apps/theming/tests/UtilTest.php | 20 |
3 files changed, 67 insertions, 28 deletions
diff --git a/apps/theming/appinfo/app.php b/apps/theming/appinfo/app.php index 152504c4179..941df6f73df 100644 --- a/apps/theming/appinfo/app.php +++ b/apps/theming/appinfo/app.php @@ -23,33 +23,39 @@ * */ -$linkToCSS = \OC::$server->getURLGenerator()->linkToRoute( - 'theming.Theming.getStylesheet', - [ - 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), - ] -); -\OCP\Util::addHeader( - 'link', - [ - 'rel' => 'stylesheet', - 'href' => $linkToCSS, - ] -); +$app = new \OCP\AppFramework\App('theming'); +/** @var \OCA\Theming\Util $util */ +$util = $app->getContainer()->query(\OCA\Theming\Util::class); +if(!$util->isAlreadyThemed()) { -$linkToJs = \OC::$server->getURLGenerator()->linkToRoute( - 'theming.Theming.getJavascript', - [ - 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), - ] -); -\OCP\Util::addHeader( - 'script', - [ - 'src' => $linkToJs, - 'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() - ], '' -); + $app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class); -$app = new \OCP\AppFramework\App('theming'); -$app->getContainer()->registerCapability(\OCA\Theming\Capabilities::class); + $linkToCSS = \OC::$server->getURLGenerator()->linkToRoute( + 'theming.Theming.getStylesheet', + [ + 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), + ] + ); + \OCP\Util::addHeader( + 'link', + [ + 'rel' => 'stylesheet', + 'href' => $linkToCSS, + ] + ); + + $linkToJs = \OC::$server->getURLGenerator()->linkToRoute( + 'theming.Theming.getJavascript', + [ + 'v' => \OC::$server->getConfig()->getAppValue('theming', 'cachebuster', '0'), + ] + ); + \OCP\Util::addHeader( + 'script', + [ + 'src' => $linkToJs, + 'nonce' => \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() + ], '' + ); + +}
\ No newline at end of file diff --git a/apps/theming/lib/Util.php b/apps/theming/lib/Util.php index 286756a4849..1df16ea4976 100644 --- a/apps/theming/lib/Util.php +++ b/apps/theming/lib/Util.php @@ -199,4 +199,17 @@ class Util { return $svg; } + /** + * Check if a custom theme is set in the server configuration + * + * @return bool + */ + public function isAlreadyThemed() { + $theme = $this->config->getSystemValue('theme', ''); + if ($theme !== '') { + return true; + } + return false; + } + } diff --git a/apps/theming/tests/UtilTest.php b/apps/theming/tests/UtilTest.php index de6690ffe0d..d81c253f98a 100644 --- a/apps/theming/tests/UtilTest.php +++ b/apps/theming/tests/UtilTest.php @@ -180,4 +180,24 @@ class UtilTest extends TestCase { $this->assertEquals($expected, $result); } + public function testIsAlreadyThemedFalse() { + $theme = $this->config->getSystemValue('theme', ''); + $this->config->expects($this->once()) + ->method('getSystemValue') + ->with('theme', '') + ->willReturn(''); + $actual = $this->util->isAlreadyThemed(); + $this->assertFalse($actual); + } + + public function testIsAlreadyThemedTrue() { + $theme = $this->config->getSystemValue('theme', ''); + $this->config->expects($this->once()) + ->method('getSystemValue') + ->with('theme', '') + ->willReturn('example'); + $actual = $this->util->isAlreadyThemed(); + $this->assertTrue($actual); + } + } |