]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat(files_sharing): use share node or label as page title feat/sharing-title 49142/head
authorskjnldsv <skjnldsv@protonmail.com>
Fri, 8 Nov 2024 07:57:22 +0000 (08:57 +0100)
committerskjnldsv <skjnldsv@protonmail.com>
Fri, 8 Nov 2024 13:20:58 +0000 (14:20 +0100)
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
apps/files_sharing/tests/Controller/ShareControllerTest.php
core/templates/layout.public.php

index dad1f3324588bae0073b2224eb2a2d3485d337b3..0c76f0e1742d67412f268822896f6c4ed303b08d 100644 (file)
@@ -130,12 +130,16 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider
                        '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]));
                }
index 5d962dff4c008e140dc44030fbc0d1299b000a72..bc8e5dede63cbc2ed5cae859cef680cdb6622e14 100644 (file)
@@ -338,6 +338,7 @@ class ShareControllerTest extends \Test\TestCase {
                $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');
@@ -477,6 +478,7 @@ class ShareControllerTest extends \Test\TestCase {
                $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');
@@ -604,6 +606,7 @@ class ShareControllerTest extends \Test\TestCase {
                $csp = new ContentSecurityPolicy();
                $csp->addAllowedFrameDomain('\'self\'');
                $expectedResponse = new PublicTemplateResponse('files', 'index');
+               $expectedResponse->setParams(['pageTitle' => $filename]);
                $expectedResponse->setContentSecurityPolicy($csp);
                $expectedResponse->setHeaderTitle($filename);
                $expectedResponse->setHeaderDetails('');
index e2ed47d071662d74f30e6374cefb1a93fa83e920..bd46ee4f7fc7e8b7d08a71fdc0b11557572c50bf 100644 (file)
@@ -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>