Skip to content

Commit

Permalink
Merge pull request #49142 from nextcloud/feat/sharing-title
Browse files Browse the repository at this point in the history
  • Loading branch information
skjnldsv authored Nov 8, 2024
2 parents deb28f5 + 4d9d617 commit d5caf91
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,16 @@ public function renderPage(IShare $share, string $token, string $path): Template
'index',
);
$response->setContentSecurityPolicy($csp);

// If the share has a label, use it as the title
if ($share->getLabel() !== '') {
$response->setHeaderTitle($share->getLabel());
$response->setParams(['pageTitle' => $share->getLabel()]);
} else {
$response->setHeaderTitle($shareNode->getName());
$response->setParams(['pageTitle' => $shareNode->getName()]);
}

if ($ownerName !== '') {
$response->setHeaderDetails($this->l10n->t('shared by %s', [$ownerName]));
}
Expand Down
3 changes: 3 additions & 0 deletions apps/files_sharing/tests/Controller/ShareControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ public function testShowShare(): void {
$csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse('files', 'index');
$expectedResponse->setParams(['pageTitle' => $filename]);
$expectedResponse->setContentSecurityPolicy($csp);
$expectedResponse->setHeaderTitle($filename);
$expectedResponse->setHeaderDetails('shared by ownerDisplay');
Expand Down Expand Up @@ -477,6 +478,7 @@ public function testShowFileDropShare(): void {
$csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse('files', 'index');
$expectedResponse->setParams(['pageTitle' => $filename]);
$expectedResponse->setContentSecurityPolicy($csp);
$expectedResponse->setHeaderTitle($filename);
$expectedResponse->setHeaderDetails('shared by ownerDisplay');
Expand Down Expand Up @@ -604,6 +606,7 @@ public function testShowShareWithPrivateName(): void {
$csp = new ContentSecurityPolicy();
$csp->addAllowedFrameDomain('\'self\'');
$expectedResponse = new PublicTemplateResponse('files', 'index');
$expectedResponse->setParams(['pageTitle' => $filename]);
$expectedResponse->setContentSecurityPolicy($csp);
$expectedResponse->setHeaderTitle($filename);
$expectedResponse->setHeaderDetails('');
Expand Down
5 changes: 3 additions & 2 deletions core/templates/layout.public.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
<head data-requesttoken="<?php p($_['requesttoken']); ?>">
<meta charset="utf-8">
<title>
<?php
p(!empty($_['application']) ? $_['application'] . ' - ' : '');
<?php
p(!empty($_['pageTitle']) && $_['pageTitle'] !== $_['application'] ? $_['pageTitle'] . ' - ' : '');
p(!empty($_['application']) ? $_['application'] . ' - ' : '');
p($theme->getTitle());
?>
</title>
Expand Down

0 comments on commit d5caf91

Please sign in to comment.