Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/theming/css/settings-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
visibility: hidden;
}
form.uploadButton {
width: 356px;
width: 411px;
}
#theming form .theme-undo,
#theming .theme-remove-bg {
Expand All @@ -51,7 +51,7 @@ form.uploadButton {

#theming label span {
display: inline-block;
min-width: 120px;
min-width: 175px;
padding: 8px 0px;
vertical-align: top;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ form.uploadButton {
background-size: cover;
background-position: center center;
text-align: center;
margin-left: 123px;
margin-left: 178px;
margin-top: 10px;
cursor: pointer;
}
Expand All @@ -104,4 +104,4 @@ form.uploadButton {

.theming-hints {
margin-top: 20px;
}
}
13 changes: 12 additions & 1 deletion apps/theming/js/settings-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ function hideUndoButton(setting, value) {
url: 'https://nextcloud.com',
color: '#0082c9',
logoMime: '',
backgroundMime: ''
backgroundMime: '',
imprintUrl: ''
};

if (value === themingDefaults[setting] || value === '') {
Expand Down Expand Up @@ -195,6 +196,16 @@ $(document).ready(function () {
}
});

$('#theming-imprintUrl').change(function(e) {
var el = $(this);
$.when(el.focusout()).then(function () {
setThemingValue('imprintUrl', $(this).val());
});
if (e.keyCode == 13) {
setThemingValue('imprintUrl', $(this).val());
}
});

$('#theming-slogan').change(function(e) {
var el = $(this);
$.when(el.focusout()).then(function() {
Expand Down
11 changes: 11 additions & 0 deletions apps/theming/lib/Controller/ThemingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ public function updateStylesheet($setting, $value) {
]);
}
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([
Expand Down Expand Up @@ -459,6 +469,7 @@ public function getJavascript() {
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) . '
};
Expand Down
3 changes: 2 additions & 1 deletion apps/theming/lib/Settings/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public function getForm() {
'backgroundMime' => $this->config->getAppValue('theming', 'backgroundMime', ''),
'uploadLogoRoute' => $path,
'canThemeIcons' => $this->themingDefaults->shouldReplaceIcons(),
'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons')
'iconDocs' => $this->urlGenerator->linkToDocs('admin-theming-icons'),
'imprintUrl' => $this->themingDefaults->getImprintUrl(),
];

return new TemplateResponse('theming', 'settings-admin', $parameters, '');
Expand Down
14 changes: 14 additions & 0 deletions apps/theming/lib/ThemingDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,26 @@ public function getSlogan() {
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 = '<a href="'. $this->getBaseUrl() . '" target="_blank"' .
' rel="noreferrer noopener">' .$this->getEntity() . '</a>'.
($slogan !== '' ? ' – ' . $slogan : '');

$imprintUrl = (string)$this->getImprintUrl();
if($imprintUrl !== ''
&& filter_var($imprintUrl, FILTER_VALIDATE_URL, [
'flags' => FILTER_FLAG_SCHEME_REQUIRED | FILTER_FLAG_HOST_REQUIRED
])
) {
$footer .= '<br/><a href="' . $imprintUrl . '" class="legal" target="_blank"' .
' rel="noreferrer noopener">' . $this->l->t('Legal notice') . '</a>';
}

return $footer;
}

Expand Down
9 changes: 8 additions & 1 deletion apps/theming/templates/settings-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</div>
<div>
<label>
<span><?php p($l->t('Web address')) ?></span>
<span><?php p($l->t('Web link')) ?></span>
<input id="theming-url" type="text" placeholder="<?php p($l->t('Web address https://…')); ?>" value="<?php p($_['url']) ?>" maxlength="500" />
<div data-setting="url" data-toggle="tooltip" data-original-title="<?php p($l->t('Reset to default')); ?>" class="theme-undo icon icon-history"></div>
</label>
Expand Down Expand Up @@ -88,6 +88,13 @@
<div id="theming-preview">
<img src="<?php p($_['logo']); ?>" id="theming-preview-logo" />
</div>
<div>
<label>
<span><?php p($l->t('Legal notice link')) ?></span>
<input id="theming-imprintUrl" type="text" placeholder="<?php p($l->t('https://…')); ?>" value="<?php p($_['imprintUrl']) ?>" maxlength="500" />
<div data-setting="imprintUrl" data-toggle="tooltip" data-original-title="<?php p($l->t('Reset to default')); ?>" class="theme-undo icon icon-history"></div>
</label>
</div>
<div class="theming-hints">
<?php if (!$_['canThemeIcons']) { ?>
<p class="info">
Expand Down
2 changes: 2 additions & 0 deletions apps/theming/tests/Controller/ThemingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,7 @@ public function testGetJavascript() {
url: "",
slogan: "",
color: "#000",
imprintUrl: null,
inverted: false,
cacheBuster: null
};
Expand Down Expand Up @@ -910,6 +911,7 @@ public function testGetJavascriptInverted() {
url: "nextcloudurl",
slogan: "awesome",
color: "#ffffff",
imprintUrl: null,
inverted: true,
cacheBuster: null
};
Expand Down
10 changes: 10 additions & 0 deletions apps/theming/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ public function testGetFormNoErrors() {
->expects($this->once())
->method('getBaseUrl')
->willReturn('https://example.com');
$this->themingDefaults
->expects($this->once())
->method('getImprintUrl')
->willReturn('');
$this->themingDefaults
->expects($this->once())
->method('getSlogan')
Expand Down Expand Up @@ -103,6 +107,7 @@ public function testGetFormNoErrors() {
'backgroundMime' => null,
'canThemeIcons' => null,
'iconDocs' => null,
'imprintUrl' => '',
];

$expected = new TemplateResponse('theming', 'settings-admin', $params, '');
Expand All @@ -128,6 +133,10 @@ public function testGetFormWithErrors() {
->expects($this->once())
->method('getBaseUrl')
->willReturn('https://example.com');
$this->themingDefaults
->expects($this->once())
->method('getImprintUrl')
->willReturn('');
$this->themingDefaults
->expects($this->once())
->method('getSlogan')
Expand Down Expand Up @@ -155,6 +164,7 @@ public function testGetFormWithErrors() {
'backgroundMime' => null,
'canThemeIcons' => null,
'iconDocs' => null,
'imprintUrl' => '',
];

$expected = new TemplateResponse('theming', 'settings-admin', $params, '');
Expand Down
71 changes: 69 additions & 2 deletions apps/theming/tests/ThemingDefaultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,27 @@ public function testGetBaseUrlWithCustom() {
$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())
Expand All @@ -215,30 +236,76 @@ public function testGetSloganWithCustom() {

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('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan', $this->template->getShortFooter());
}

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('<a href="url" target="_blank" rel="noreferrer noopener">Name</a>', $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('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan<br/><a href="https://example.com/imprint" class="legal" target="_blank" rel="noreferrer noopener">Legal notice</a>', $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('<a href="url" target="_blank" rel="noreferrer noopener">Name</a> – Slogan', $this->template->getShortFooter());
}

public function testgetColorPrimaryWithDefault() {
$this->config
->expects($this->once())
Expand Down
4 changes: 4 additions & 0 deletions core/css/guest.css
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,10 @@ footer .info a {
overflow: hidden;
}

a.legal {
font-size: smaller;
}

/* 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 {
Expand Down