From 62f1156a56a671cb593c0531922976914b1d4fa9 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 9 May 2018 15:52:41 +0200 Subject: allow to specify a link to a legal notice Signed-off-by: Arthur Schiwon --- apps/theming/css/settings-admin.scss | 8 +-- apps/theming/js/settings-admin.js | 23 ++++---- apps/theming/lib/Controller/ThemingController.php | 11 ++++ apps/theming/lib/Settings/Admin.php | 1 + apps/theming/lib/ThemingDefaults.php | 14 +++++ apps/theming/templates/settings-admin.php | 7 +++ apps/theming/tests/ThemingDefaultsTest.php | 71 ++++++++++++++++++++++- core/css/guest.css | 5 ++ 8 files changed, 124 insertions(+), 16 deletions(-) diff --git a/apps/theming/css/settings-admin.scss b/apps/theming/css/settings-admin.scss index ceb560f0f02..00d1cb96fc6 100644 --- a/apps/theming/css/settings-admin.scss +++ b/apps/theming/css/settings-admin.scss @@ -28,7 +28,7 @@ visibility: hidden; } form.uploadButton { - width: 356px; + width: 411px; } form .theme-undo, .theme-remove-bg { @@ -52,7 +52,7 @@ label span { display: inline-block; - min-width: 120px; + min-width: 175px; padding: 8px 0px; vertical-align: top; } @@ -88,7 +88,7 @@ background-size: cover; background-position: center center; text-align: center; - margin-left: 123px; + margin-left: 178px; margin-top: 10px; margin-bottom: 20px; cursor: pointer; @@ -117,4 +117,4 @@ background-repeat: no-repeat; background-size: contain; } -} \ No newline at end of file +} diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js index 25ac092a964..028d08c151a 100644 --- a/apps/theming/js/settings-admin.js +++ b/apps/theming/js/settings-admin.js @@ -175,7 +175,7 @@ $(document).ready(function () { var el = $(this); }); - $('#theming input[type=text]').change(function(e) { + function onChange(e) { var el = $(this); var setting = el.parent().find('div[data-setting]').data('setting'); var value = $(this).val(); @@ -186,14 +186,14 @@ $(document).ready(function () { } } if(setting === 'name') { - if(checkName()){ - $.when(el.focusout()).then(function() { - setThemingValue('name', value); - }); - if (e.keyCode == 13) { - setThemingValue('name', value); - } - } + if(checkName()){ + $.when(el.focusout()).then(function() { + setThemingValue('name', value); + }); + if (e.keyCode == 13) { + setThemingValue('name', value); + } + } } $.when(el.focusout()).then(function() { @@ -202,7 +202,10 @@ $(document).ready(function () { if (e.keyCode == 13) { setThemingValue(setting, value); } - }); + }; + + $('#theming input[type="text"]').change(onChange); + $('#theming input[type="url"]').change(onChange); $('.theme-undo').click(function (e) { var setting = $(this).data('setting'); diff --git a/apps/theming/lib/Controller/ThemingController.php b/apps/theming/lib/Controller/ThemingController.php index 421af051998..27daf756d48 100644 --- a/apps/theming/lib/Controller/ThemingController.php +++ b/apps/theming/lib/Controller/ThemingController.php @@ -161,6 +161,16 @@ class ThemingController extends Controller { ]); } break; + case 'imprintUrl': + if (strlen($value) > 500) { + return new DataResponse([ + 'data' => [ + 'message' => $this->l10n->t('The given legal notice address is too long'), + ], + 'status' => 'error' + ]); + } + break; case 'slogan': if (strlen($value) > 500) { return new DataResponse([ @@ -406,6 +416,7 @@ class ThemingController extends Controller { url: ' . json_encode($this->themingDefaults->getBaseUrl()) . ', slogan: ' . json_encode($this->themingDefaults->getSlogan()) . ', color: ' . json_encode($this->themingDefaults->getColorPrimary()) . ', + imprintUrl: ' . json_encode($this->themingDefaults->getImprintUrl()) . ', inverted: ' . json_encode($this->util->invertTextColor($this->themingDefaults->getColorPrimary())) . ', cacheBuster: ' . json_encode($cacheBusterValue) . ' }; diff --git a/apps/theming/lib/Settings/Admin.php b/apps/theming/lib/Settings/Admin.php index 7c937f19790..ef296688ed2 100644 --- a/apps/theming/lib/Settings/Admin.php +++ b/apps/theming/lib/Settings/Admin.php @@ -84,6 +84,7 @@ class Admin implements ISettings { 'canThemeIcons' => $this->themingDefaults->shouldReplaceIcons(), 'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons'), 'images' => $this->imageManager->getCustomImages(), + 'imprintUrl' => $this->themingDefaults->getImprintUrl(), ]; return new TemplateResponse('theming', 'settings-admin', $parameters, ''); diff --git a/apps/theming/lib/ThemingDefaults.php b/apps/theming/lib/ThemingDefaults.php index 2e6b667b1f6..d2f57471242 100644 --- a/apps/theming/lib/ThemingDefaults.php +++ b/apps/theming/lib/ThemingDefaults.php @@ -141,12 +141,26 @@ class ThemingDefaults extends \OC_Defaults { return \OCP\Util::sanitizeHTML($this->config->getAppValue('theming', 'slogan', $this->slogan)); } + public function getImprintUrl() { + return $this->config->getAppValue('theming', 'imprintUrl', ''); + } + public function getShortFooter() { $slogan = $this->getSlogan(); $footer = '' .$this->getEntity() . ''. ($slogan !== '' ? ' – ' . $slogan : ''); + $imprintUrl = (string)$this->getImprintUrl(); + if($imprintUrl !== '' + && filter_var($imprintUrl, FILTER_VALIDATE_URL, [ + 'flags' => FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED + ]) + ) { + $footer .= '
' . $this->l->t('Legal notice') . ''; + } + return $footer; } diff --git a/apps/theming/templates/settings-admin.php b/apps/theming/templates/settings-admin.php index ea9925f3a64..9fccd2f1e0e 100644 --- a/apps/theming/templates/settings-admin.php +++ b/apps/theming/templates/settings-admin.php @@ -94,6 +94,13 @@ style('theming', 'settings-admin');

t('Advanced options')); ?>

+
+ +
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php index c943af01c6c..b454b21f840 100644 --- a/apps/theming/tests/ThemingDefaultsTest.php +++ b/apps/theming/tests/ThemingDefaultsTest.php @@ -195,6 +195,27 @@ class ThemingDefaultsTest extends TestCase { $this->assertEquals('https://example.com/', $this->template->getBaseUrl()); } + public function imprintUrlProvider() { + return [ + [ '' ], + [ 'https://example.com/imprint.html'] + ]; + } + + /** + * @param $imprintUrl + * @dataProvider imprintUrlProvider + */ + public function testGetImprintURL($imprintUrl) { + $this->config + ->expects($this->once()) + ->method('getAppValue') + ->with('theming', 'imprintUrl', '') + ->willReturn($imprintUrl); + + $this->assertEquals($imprintUrl, $this->template->getImprintUrl()); + } + public function testGetSloganWithDefault() { $this->config ->expects($this->once()) @@ -217,12 +238,13 @@ class ThemingDefaultsTest extends TestCase { public function testGetShortFooter() { $this->config - ->expects($this->exactly(3)) + ->expects($this->exactly(4)) ->method('getAppValue') ->willReturnMap([ ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], ['theming', 'name', 'Nextcloud', 'Name'], ['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'], + ['theming', 'imprintUrl', '', ''], ]); $this->assertEquals('Name – Slogan', $this->template->getShortFooter()); @@ -230,17 +252,62 @@ class ThemingDefaultsTest extends TestCase { public function testGetShortFooterEmptySlogan() { $this->config - ->expects($this->exactly(3)) + ->expects($this->exactly(4)) ->method('getAppValue') ->willReturnMap([ ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], ['theming', 'name', 'Nextcloud', 'Name'], ['theming', 'slogan', $this->defaults->getSlogan(), ''], + ['theming', 'imprintUrl', '', ''], ]); $this->assertEquals('Name', $this->template->getShortFooter()); } + public function testGetShortFooterImprint() { + $this->config + ->expects($this->exactly(4)) + ->method('getAppValue') + ->willReturnMap([ + ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], + ['theming', 'name', 'Nextcloud', 'Name'], + ['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'], + ['theming', 'imprintUrl', '', 'https://example.com/imprint'], + ]); + + $this->l10n + ->expects($this->any()) + ->method('t') + ->willReturnArgument(0); + + $this->assertEquals('Name – Slogan
Legal notice', $this->template->getShortFooter()); + } + + public function invalidImprintUrlProvider() { + return [ + ['example.com/imprint'], # missing scheme + ['https:///imprint'], # missing host + ]; + } + + /** + * @param $invalidImprintUrl + * @dataProvider invalidImprintUrlProvider + */ + public function testGetShortFooterInvalidImprint($invalidImprintUrl) { + $this->config + ->expects($this->exactly(4)) + ->method('getAppValue') + ->willReturnMap([ + ['theming', 'url', $this->defaults->getBaseUrl(), 'url'], + ['theming', 'name', 'Nextcloud', 'Name'], + ['theming', 'slogan', $this->defaults->getSlogan(), 'Slogan'], + ['theming', 'imprintUrl', '', $invalidImprintUrl], + ]); + + $this->assertEquals('Name – Slogan', $this->template->getShortFooter()); + } + public function testgetColorPrimaryWithDefault() { $this->config ->expects($this->once()) diff --git a/core/css/guest.css b/core/css/guest.css index e0e639252ee..04d19bccf08 100644 --- a/core/css/guest.css +++ b/core/css/guest.css @@ -744,6 +744,11 @@ footer .info a { overflow: hidden; } +a.legal { + font-size: smaller; + text-decoration: underline; +} + /* for low-res screens, use Regular font-weight instead of Light */ @media (-webkit-max-device-pixel-ratio: 1.3), (max-resolution: 124.8dpi) { @font-face { -- cgit v1.2.3 From 850e2256f3dee5f94b407ea6b8d85fb84d170eb5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 11 May 2018 15:11:09 +0200 Subject: fix tests Signed-off-by: Arthur Schiwon --- apps/theming/tests/Controller/ThemingControllerTest.php | 2 ++ apps/theming/tests/Settings/AdminTest.php | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php index dda881525f0..f2f14e44a02 100644 --- a/apps/theming/tests/Controller/ThemingControllerTest.php +++ b/apps/theming/tests/Controller/ThemingControllerTest.php @@ -814,6 +814,7 @@ class ThemingControllerTest extends TestCase { url: "", slogan: "", color: "#000", + imprintUrl: null, inverted: false, cacheBuster: null }; @@ -848,6 +849,7 @@ class ThemingControllerTest extends TestCase { url: "nextcloudurl", slogan: "awesome", color: "#ffffff", + imprintUrl: null, inverted: true, cacheBuster: null }; diff --git a/apps/theming/tests/Settings/AdminTest.php b/apps/theming/tests/Settings/AdminTest.php index 4eac689fb3f..f7361677d77 100644 --- a/apps/theming/tests/Settings/AdminTest.php +++ b/apps/theming/tests/Settings/AdminTest.php @@ -81,6 +81,10 @@ class AdminTest extends TestCase { ->expects($this->once()) ->method('getBaseUrl') ->willReturn('https://example.com'); + $this->themingDefaults + ->expects($this->once()) + ->method('getImprintUrl') + ->willReturn(''); $this->themingDefaults ->expects($this->once()) ->method('getSlogan') @@ -105,6 +109,7 @@ class AdminTest extends TestCase { 'canThemeIcons' => null, 'iconDocs' => null, 'images' => [], + 'imprintUrl' => '', ]; $expected = new TemplateResponse('theming', 'settings-admin', $params, ''); @@ -130,6 +135,10 @@ class AdminTest extends TestCase { ->expects($this->once()) ->method('getBaseUrl') ->willReturn('https://example.com'); + $this->themingDefaults + ->expects($this->once()) + ->method('getImprintUrl') + ->willReturn(''); $this->themingDefaults ->expects($this->once()) ->method('getSlogan') @@ -154,6 +163,7 @@ class AdminTest extends TestCase { 'canThemeIcons' => null, 'iconDocs' => '', 'images' => [], + 'imprintUrl' => '', ]; $expected = new TemplateResponse('theming', 'settings-admin', $params, ''); -- cgit v1.2.3 From 84ab102146f4a9443ef1b6382f049eac99b85c6b Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 11 May 2018 15:57:32 +0200 Subject: fix undo for url-typed inputs and minor adjustments Signed-off-by: Arthur Schiwon --- apps/theming/css/settings-admin.scss | 6 +++++- apps/theming/js/settings-admin.js | 3 ++- apps/theming/templates/settings-admin.php | 4 ++-- core/css/guest.css | 1 - 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apps/theming/css/settings-admin.scss b/apps/theming/css/settings-admin.scss index 00d1cb96fc6..7753540ccd2 100644 --- a/apps/theming/css/settings-admin.scss +++ b/apps/theming/css/settings-admin.scss @@ -46,7 +46,11 @@ input[type='text']:hover + .theme-undo, input[type='text'] + .theme-undo:hover, input[type='text']:focus + .theme-undo, - input[type='text']:active + .theme-undo { + input[type='text']:active + .theme-undo, + input[type='url']:hover + .theme-undo, + input[type='url'] + .theme-undo:hover, + input[type='url']:focus + .theme-undo, + input[type='url']:active + .theme-undo{ visibility: visible; } diff --git a/apps/theming/js/settings-admin.js b/apps/theming/js/settings-admin.js index 028d08c151a..76d9fb965ca 100644 --- a/apps/theming/js/settings-admin.js +++ b/apps/theming/js/settings-admin.js @@ -83,7 +83,8 @@ function hideUndoButton(setting, value) { url: 'https://nextcloud.com', color: '#0082c9', logoMime: '', - backgroundMime: '' + backgroundMime: '', + imprintUrl: '' }; if (value === themingDefaults[setting] || value === '') { diff --git a/apps/theming/templates/settings-admin.php b/apps/theming/templates/settings-admin.php index 9fccd2f1e0e..7df92c335c2 100644 --- a/apps/theming/templates/settings-admin.php +++ b/apps/theming/templates/settings-admin.php @@ -48,7 +48,7 @@ style('theming', 'settings-admin');
@@ -97,7 +97,7 @@ style('theming', 'settings-admin');
diff --git a/core/css/guest.css b/core/css/guest.css index 04d19bccf08..88341fb903a 100644 --- a/core/css/guest.css +++ b/core/css/guest.css @@ -746,7 +746,6 @@ footer .info a { a.legal { font-size: smaller; - text-decoration: underline; } /* for low-res screens, use Regular font-weight instead of Light */ -- cgit v1.2.3 From feff9f5bd1f776ade18ec8e196553730ef408a54 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 16 May 2018 00:56:08 +0200 Subject: Use link not address in labels for URLs Signed-off-by: Arthur Schiwon --- apps/theming/templates/settings-admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/theming/templates/settings-admin.php b/apps/theming/templates/settings-admin.php index 7df92c335c2..26ab78637c9 100644 --- a/apps/theming/templates/settings-admin.php +++ b/apps/theming/templates/settings-admin.php @@ -47,7 +47,7 @@ style('theming', 'settings-admin');
@@ -96,7 +96,7 @@ style('theming', 'settings-admin');
-- cgit v1.2.3