]> source.dussan.org Git - nextcloud-server.git/commitdiff
Pluggable share provider 35736/head
authorLouis Chemineau <louis@chmn.me>
Wed, 18 Jan 2023 15:53:22 +0000 (16:53 +0100)
committerLouis Chemineau <louis@chmn.me>
Thu, 2 Feb 2023 14:41:26 +0000 (15:41 +0100)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Signed-off-by: Louis Chemineau <louis@chmn.me>
14 files changed:
apps/files_sharing/composer/composer/autoload_classmap.php
apps/files_sharing/composer/composer/autoload_static.php
apps/files_sharing/lib/Controller/ShareController.php
apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php [new file with mode: 0644]
apps/files_sharing/templates/public.php
apps/files_sharing/tests/Controller/ShareControllerTest.php
lib/composer/composer/autoload_classmap.php
lib/composer/composer/autoload_static.php
lib/private/AppFramework/Bootstrap/RegistrationContext.php
lib/private/Server.php
lib/private/Share20/PublicShareTemplateFactory.php [new file with mode: 0644]
lib/public/AppFramework/Bootstrap/IRegistrationContext.php
lib/public/Share/IPublicShareTemplateFactory.php [new file with mode: 0644]
lib/public/Share/IPublicShareTemplateProvider.php [new file with mode: 0644]

index e4a493cadfb04949aed6594678e0b490bd4423f5..50cbfe40d8aae7b9008090319140e0a3753128c3 100644 (file)
@@ -35,6 +35,7 @@ return array(
     'OCA\\Files_Sharing\\Controller\\ShareController' => $baseDir . '/../lib/Controller/ShareController.php',
     'OCA\\Files_Sharing\\Controller\\ShareInfoController' => $baseDir . '/../lib/Controller/ShareInfoController.php',
     'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => $baseDir . '/../lib/Controller/ShareesAPIController.php',
+    'OCA\\Files_Sharing\\DefaultPublicShareTemplateProvider' => $baseDir . '/../lib/DefaultPublicShareTemplateProvider.php',
     'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => $baseDir . '/../lib/DeleteOrphanedSharesJob.php',
     'OCA\\Files_Sharing\\Event\\BeforeTemplateRenderedEvent' => $baseDir . '/../lib/Event/BeforeTemplateRenderedEvent.php',
     'OCA\\Files_Sharing\\Event\\ShareLinkAccessedEvent' => $baseDir . '/../lib/Event/ShareLinkAccessedEvent.php',
index 3c92a46fc82fbbbca69a1aa9200869b3099b6611..4ba0fd52421a0bef0a7c983cfae773490d4cf543 100644 (file)
@@ -50,6 +50,7 @@ class ComposerStaticInitFiles_Sharing
         'OCA\\Files_Sharing\\Controller\\ShareController' => __DIR__ . '/..' . '/../lib/Controller/ShareController.php',
         'OCA\\Files_Sharing\\Controller\\ShareInfoController' => __DIR__ . '/..' . '/../lib/Controller/ShareInfoController.php',
         'OCA\\Files_Sharing\\Controller\\ShareesAPIController' => __DIR__ . '/..' . '/../lib/Controller/ShareesAPIController.php',
+        'OCA\\Files_Sharing\\DefaultPublicShareTemplateProvider' => __DIR__ . '/..' . '/../lib/DefaultPublicShareTemplateProvider.php',
         'OCA\\Files_Sharing\\DeleteOrphanedSharesJob' => __DIR__ . '/..' . '/../lib/DeleteOrphanedSharesJob.php',
         'OCA\\Files_Sharing\\Event\\BeforeTemplateRenderedEvent' => __DIR__ . '/..' . '/../lib/Event/BeforeTemplateRenderedEvent.php',
         'OCA\\Files_Sharing\\Event\\ShareLinkAccessedEvent' => __DIR__ . '/..' . '/../lib/Event/ShareLinkAccessedEvent.php',
index 6a6fd1c9f7fdb31c046434c3980df84d4a6204b9..ae21259e21e7a5c7071bf6e3e64a049c3da81ae0 100644 (file)
@@ -77,6 +77,7 @@ use OCP\Share;
 use OCP\Share\Exceptions\ShareNotFound;
 use OCP\Share\IManager as ShareManager;
 use OCP\Share\IShare;
+use OCP\Share\IPublicShareTemplateFactory;
 use OCP\Template;
 
 /**
@@ -99,24 +100,28 @@ class ShareController extends AuthPublicShareController {
        protected ShareManager $shareManager;
        protected ISecureRandom $secureRandom;
        protected ?Share\IShare $share = null;
-
-       public function __construct(string $appName,
-                                                               IRequest $request,
-                                                               IConfig $config,
-                                                               IURLGenerator $urlGenerator,
-                                                               IUserManager $userManager,
-                                                               ILogger $logger,
-                                                               \OCP\Activity\IManager $activityManager,
-                                                               ShareManager $shareManager,
-                                                               ISession $session,
-                                                               IPreview $previewManager,
-                                                               IRootFolder $rootFolder,
-                                                               FederatedShareProvider $federatedShareProvider,
-                                                               IAccountManager $accountManager,
-                                                               IEventDispatcher $eventDispatcher,
-                                                               IL10N $l10n,
-                                                               ISecureRandom $secureRandom,
-                                                               Defaults $defaults) {
+       private IPublicShareTemplateFactory $publicShareTemplateFactory;
+
+       public function __construct(
+               string $appName,
+               IRequest $request,
+               IConfig $config,
+               IURLGenerator $urlGenerator,
+               IUserManager $userManager,
+               ILogger $logger,
+               \OCP\Activity\IManager $activityManager,
+               ShareManager $shareManager,
+               ISession $session,
+               IPreview $previewManager,
+               IRootFolder $rootFolder,
+               FederatedShareProvider $federatedShareProvider,
+               IAccountManager $accountManager,
+               IEventDispatcher $eventDispatcher,
+               IL10N $l10n,
+               ISecureRandom $secureRandom,
+               Defaults $defaults,
+               IPublicShareTemplateFactory $publicShareTemplateFactory
+       ) {
                parent::__construct($appName, $request, $session, $urlGenerator);
 
                $this->config = $config;
@@ -132,6 +137,7 @@ class ShareController extends AuthPublicShareController {
                $this->secureRandom = $secureRandom;
                $this->defaults = $defaults;
                $this->shareManager = $shareManager;
+               $this->publicShareTemplateFactory = $publicShareTemplateFactory;
        }
 
        public const SHARE_ACCESS = 'access';
@@ -367,6 +373,15 @@ class ShareController extends AuthPublicShareController {
 
                $shareNode = $share->getNode();
 
+               try {
+                       $templateProvider = $this->publicShareTemplateFactory->getProvider($share);
+                       $response = $templateProvider->renderPage($share, $this->getToken(), $path);
+               } catch (NotFoundException $e) {
+                       $this->emitAccessShareHook($share, 404, 'Share not found');
+                       $this->emitShareAccessEvent($share, ShareController::SHARE_ACCESS, 404, 'Share not found');
+                       throw new NotFoundException();
+               }
+
                // We can't get the path of a file share
                try {
                        if ($shareNode instanceof \OCP\Files\File && $path !== '') {
@@ -380,205 +395,6 @@ class ShareController extends AuthPublicShareController {
                        throw $e;
                }
 
-               $shareTmpl = [];
-               $shareTmpl['owner'] = '';
-               $shareTmpl['shareOwner'] = '';
-
-               $owner = $this->userManager->get($share->getShareOwner());
-               if ($owner instanceof IUser) {
-                       $ownerAccount = $this->accountManager->getAccount($owner);
-
-                       $ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
-                       if ($ownerName->getScope() === IAccountManager::SCOPE_PUBLISHED) {
-                               $shareTmpl['owner'] = $owner->getUID();
-                               $shareTmpl['shareOwner'] = $owner->getDisplayName();
-                       }
-               }
-
-               $shareTmpl['filename'] = $shareNode->getName();
-               $shareTmpl['directory_path'] = $share->getTarget();
-               $shareTmpl['note'] = $share->getNote();
-               $shareTmpl['mimetype'] = $shareNode->getMimetype();
-               $shareTmpl['previewSupported'] = $this->previewManager->isMimeSupported($shareNode->getMimetype());
-               $shareTmpl['dirToken'] = $this->getToken();
-               $shareTmpl['sharingToken'] = $this->getToken();
-               $shareTmpl['server2serversharing'] = $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
-               $shareTmpl['protected'] = $share->getPassword() !== null ? 'true' : 'false';
-               $shareTmpl['dir'] = '';
-               $shareTmpl['nonHumanFileSize'] = $shareNode->getSize();
-               $shareTmpl['fileSize'] = \OCP\Util::humanFileSize($shareNode->getSize());
-               $shareTmpl['hideDownload'] = $share->getHideDownload();
-
-               $hideFileList = false;
-
-               if ($shareNode instanceof \OCP\Files\Folder) {
-                       $shareIsFolder = true;
-
-                       try {
-                               $folderNode = $shareNode->get($path);
-                       } catch (\OCP\Files\NotFoundException $e) {
-                               $this->emitAccessShareHook($share, 404, 'Share not found');
-                               $this->emitShareAccessEvent($share, self::SHARE_ACCESS, 404, 'Share not found');
-                               throw new NotFoundException();
-                       }
-
-                       $shareTmpl['dir'] = $shareNode->getRelativePath($folderNode->getPath());
-
-                       /*
-                        * The OC_Util methods require a view. This just uses the node API
-                        */
-                       $freeSpace = $share->getNode()->getStorage()->free_space($share->getNode()->getInternalPath());
-                       if ($freeSpace < \OCP\Files\FileInfo::SPACE_UNLIMITED) {
-                               $freeSpace = (int)max($freeSpace, 0);
-                       } else {
-                               $freeSpace = (INF > 0) ? INF: PHP_INT_MAX; // work around https://bugs.php.net/bug.php?id=69188
-                       }
-
-                       $hideFileList = !($share->getPermissions() & \OCP\Constants::PERMISSION_READ);
-                       $maxUploadFilesize = $freeSpace;
-
-                       $folder = new Template('files', 'list', '');
-
-                       $folder->assign('dir', $shareNode->getRelativePath($folderNode->getPath()));
-                       $folder->assign('dirToken', $this->getToken());
-                       $folder->assign('permissions', \OCP\Constants::PERMISSION_READ);
-                       $folder->assign('isPublic', true);
-                       $folder->assign('hideFileList', $hideFileList);
-                       $folder->assign('publicUploadEnabled', 'no');
-                       // default to list view
-                       $folder->assign('showgridview', false);
-                       $folder->assign('uploadMaxFilesize', $maxUploadFilesize);
-                       $folder->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize));
-                       $folder->assign('freeSpace', $freeSpace);
-                       $folder->assign('usedSpacePercent', 0);
-                       $folder->assign('trash', false);
-                       $shareTmpl['folder'] = $folder->fetchPage();
-               } else {
-                       $shareIsFolder = false;
-               }
-
-               // default to list view
-               $shareTmpl['showgridview'] = false;
-
-               $shareTmpl['hideFileList'] = $hideFileList;
-               $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', [
-                       'token' => $this->getToken(),
-                       'filename' => $shareIsFolder ? null : $shareNode->getName()
-               ]);
-               $shareTmpl['shareUrl'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $this->getToken()]);
-               $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
-               $shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true);
-               $shareTmpl['previewMaxX'] = $this->config->getSystemValue('preview_max_x', 1024);
-               $shareTmpl['previewMaxY'] = $this->config->getSystemValue('preview_max_y', 1024);
-               $shareTmpl['disclaimer'] = $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null);
-               $shareTmpl['previewURL'] = $shareTmpl['downloadURL'];
-
-               if ($shareTmpl['previewSupported']) {
-                       $shareTmpl['previewImage'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview',
-                               ['x' => 200, 'y' => 200, 'file' => $shareTmpl['directory_path'], 'token' => $shareTmpl['dirToken']]);
-                       $ogPreview = $shareTmpl['previewImage'];
-
-                       // We just have direct previews for image files
-                       if ($shareNode->getMimePart() === 'image') {
-                               $shareTmpl['previewURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.publicpreview.directLink', ['token' => $this->getToken()]);
-
-                               $ogPreview = $shareTmpl['previewURL'];
-
-                               //Whatapp is kind of picky about their size requirements
-                               if ($this->request->isUserAgent(['/^WhatsApp/'])) {
-                                       $ogPreview = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview', [
-                                               'token' => $this->getToken(),
-                                               'x' => 256,
-                                               'y' => 256,
-                                               'a' => true,
-                                       ]);
-                               }
-                       }
-               } else {
-                       $shareTmpl['previewImage'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'favicon-fb.png'));
-                       $ogPreview = $shareTmpl['previewImage'];
-               }
-
-               // Load files we need
-               \OCP\Util::addScript('files', 'semaphore');
-               \OCP\Util::addScript('files', 'file-upload');
-               \OCP\Util::addStyle('files_sharing', 'publicView');
-               \OCP\Util::addScript('files_sharing', 'public');
-               \OCP\Util::addScript('files_sharing', 'templates');
-               \OCP\Util::addScript('files', 'fileactions');
-               \OCP\Util::addScript('files', 'fileactionsmenu');
-               \OCP\Util::addScript('files', 'jquery.fileupload');
-               \OCP\Util::addScript('files_sharing', 'files_drop');
-
-               if (isset($shareTmpl['folder'])) {
-                       // JS required for folders
-                       \OCP\Util::addStyle('files', 'merged');
-                       \OCP\Util::addScript('files', 'filesummary');
-                       \OCP\Util::addScript('files', 'templates');
-                       \OCP\Util::addScript('files', 'breadcrumb');
-                       \OCP\Util::addScript('files', 'fileinfomodel');
-                       \OCP\Util::addScript('files', 'newfilemenu');
-                       \OCP\Util::addScript('files', 'files');
-                       \OCP\Util::addScript('files', 'filemultiselectmenu');
-                       \OCP\Util::addScript('files', 'filelist');
-                       \OCP\Util::addScript('files', 'keyboardshortcuts');
-                       \OCP\Util::addScript('files', 'operationprogressbar');
-               }
-
-               // Load Viewer scripts
-               if (class_exists(LoadViewer::class)) {
-                       $this->eventDispatcher->dispatchTyped(new LoadViewer());
-               }
-               // OpenGraph Support: http://ogp.me/
-               \OCP\Util::addHeader('meta', ['property' => "og:title", 'content' => $shareTmpl['filename']]);
-               \OCP\Util::addHeader('meta', ['property' => "og:description", 'content' => $this->defaults->getName() . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')]);
-               \OCP\Util::addHeader('meta', ['property' => "og:site_name", 'content' => $this->defaults->getName()]);
-               \OCP\Util::addHeader('meta', ['property' => "og:url", 'content' => $shareTmpl['shareUrl']]);
-               \OCP\Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]);
-               \OCP\Util::addHeader('meta', ['property' => "og:image", 'content' => $ogPreview]);
-
-               $this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($share));
-
-               $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy();
-               $csp->addAllowedFrameDomain('\'self\'');
-
-               $response = new PublicTemplateResponse($this->appName, 'public', $shareTmpl);
-               $response->setHeaderTitle($shareTmpl['filename']);
-               if ($shareTmpl['shareOwner'] !== '') {
-                       $response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['shareOwner']]));
-               }
-
-               $isNoneFileDropFolder = $shareIsFolder === false || $share->getPermissions() !== \OCP\Constants::PERMISSION_CREATE;
-
-               if ($isNoneFileDropFolder && !$share->getHideDownload()) {
-                       \OCP\Util::addScript('files_sharing', 'public_note');
-
-                       $downloadWhite = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $shareTmpl['downloadURL'], 0);
-                       $downloadAllWhite = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download-white', $shareTmpl['downloadURL'], 0);
-                       $download = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']);
-                       $downloadAll = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']);
-                       $directLink = new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $shareTmpl['previewURL']);
-                       // TRANSLATORS The placeholder refers to the software product name as in 'Add to your Nextcloud'
-                       $externalShare = new ExternalShareMenuAction($this->l10n->t('Add to your %s', [$this->defaults->getProductName()]), 'icon-external', $shareTmpl['owner'], $shareTmpl['shareOwner'], $shareTmpl['filename']);
-
-                       $responseComposer = [];
-
-                       if ($shareIsFolder) {
-                               $responseComposer[] = $downloadAllWhite;
-                               $responseComposer[] = $downloadAll;
-                       } else {
-                               $responseComposer[] = $downloadWhite;
-                               $responseComposer[] = $download;
-                       }
-                       $responseComposer[] = $directLink;
-                       if ($this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) {
-                               $responseComposer[] = $externalShare;
-                       }
-
-                       $response->setHeaderActions($responseComposer);
-               }
-
-               $response->setContentSecurityPolicy($csp);
 
                $this->emitAccessShareHook($share);
                $this->emitShareAccessEvent($share, self::SHARE_ACCESS);
diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php
new file mode 100644 (file)
index 0000000..cb0ba70
--- /dev/null
@@ -0,0 +1,292 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2023 Louis Chemineau <louis@chmn.me>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Files_Sharing;
+
+use OCA\FederatedFileSharing\FederatedShareProvider;
+use OCA\Files_Sharing\AppInfo\Application;
+use OCA\Files_Sharing\Event\BeforeTemplateRenderedEvent;
+use OCA\Viewer\Event\LoadViewer;
+use OCP\Accounts\IAccountManager;
+use OCP\AppFramework\Http\ContentSecurityPolicy;
+use OCP\AppFramework\Http\Template\ExternalShareMenuAction;
+use OCP\AppFramework\Http\Template\LinkMenuAction;
+use OCP\AppFramework\Http\Template\PublicTemplateResponse;
+use OCP\AppFramework\Http\Template\SimpleMenuAction;
+use OCP\AppFramework\Http\TemplateResponse;
+use OCP\Constants;
+use OCP\Defaults;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\FileInfo;
+use OCP\Files\Folder;
+use OCP\Files\NotFoundException;
+use OCP\IConfig;
+use OCP\IL10N;
+use OCP\IPreview;
+use OCP\IRequest;
+use OCP\IURLGenerator;
+use OCP\IUser;
+use OCP\IUserManager;
+use OCP\Share\IShare;
+use OCP\Share\IPublicShareTemplateProvider;
+use OCP\Template;
+use OCP\Util;
+
+class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider {
+       private IUserManager $userManager;
+       private IAccountManager $accountManager;
+       private IPreview $previewManager;
+       protected FederatedShareProvider $federatedShareProvider;
+       private IURLGenerator $urlGenerator;
+       private IEventDispatcher $eventDispatcher;
+       private IL10N $l10n;
+       private Defaults $defaults;
+       private IConfig $config;
+       private IRequest $request;
+
+       public function __construct(
+               IUserManager $userManager,
+               IAccountManager $accountManager,
+               IPreview $previewManager,
+               FederatedShareProvider $federatedShareProvider,
+               IUrlGenerator $urlGenerator,
+               IEventDispatcher $eventDispatcher,
+               IL10N $l10n,
+               Defaults $defaults,
+               IConfig $config,
+               IRequest $request
+       ) {
+               $this->userManager = $userManager;
+               $this->accountManager = $accountManager;
+               $this->previewManager = $previewManager;
+               $this->federatedShareProvider = $federatedShareProvider;
+               $this->urlGenerator = $urlGenerator;
+               $this->eventDispatcher = $eventDispatcher;
+               $this->l10n = $l10n;
+               $this->defaults = $defaults;
+               $this->config = $config;
+               $this->request = $request;
+       }
+
+       public function shouldRespond(IShare $share): bool {
+               return true;
+       }
+
+       public function renderPage(IShare $share, string $token, string $path): TemplateResponse {
+               $shareNode = $share->getNode();
+
+               $shareTmpl = [];
+               $shareTmpl['owner'] = '';
+               $shareTmpl['shareOwner'] = '';
+
+               $owner = $this->userManager->get($share->getShareOwner());
+               if ($owner instanceof IUser) {
+                       $ownerAccount = $this->accountManager->getAccount($owner);
+
+                       $ownerName = $ownerAccount->getProperty(IAccountManager::PROPERTY_DISPLAYNAME);
+                       if ($ownerName->getScope() === IAccountManager::SCOPE_PUBLISHED) {
+                               $shareTmpl['owner'] = $owner->getUID();
+                               $shareTmpl['shareOwner'] = $owner->getDisplayName();
+                       }
+               }
+
+               $shareTmpl['filename'] = $shareNode->getName();
+               $shareTmpl['directory_path'] = $share->getTarget();
+               $shareTmpl['note'] = $share->getNote();
+               $shareTmpl['mimetype'] = $shareNode->getMimetype();
+               $shareTmpl['previewSupported'] = $this->previewManager->isMimeSupported($shareNode->getMimetype());
+               $shareTmpl['dirToken'] = $token;
+               $shareTmpl['sharingToken'] = $token;
+               $shareTmpl['server2serversharing'] = $this->federatedShareProvider->isOutgoingServer2serverShareEnabled();
+               $shareTmpl['protected'] = $share->getPassword() !== null ? 'true' : 'false';
+               $shareTmpl['dir'] = '';
+               $shareTmpl['nonHumanFileSize'] = $shareNode->getSize();
+               $shareTmpl['fileSize'] = Util::humanFileSize($shareNode->getSize());
+               $shareTmpl['hideDownload'] = $share->getHideDownload();
+
+               $hideFileList = false;
+
+               if ($shareNode instanceof Folder) {
+                       $shareIsFolder = true;
+
+                       $folderNode = $shareNode->get($path);
+                       $shareTmpl['dir'] = $shareNode->getRelativePath($folderNode->getPath());
+
+                       /*
+                        * The OC_Util methods require a view. This just uses the node API
+                        */
+                       $freeSpace = $share->getNode()->getStorage()->free_space($share->getNode()->getInternalPath());
+                       if ($freeSpace < FileInfo::SPACE_UNLIMITED) {
+                               $freeSpace = (int)max($freeSpace, 0);
+                       } else {
+                               $freeSpace = (int)((INF > 0) ? INF: PHP_INT_MAX); // work around https://bugs.php.net/bug.php?id=69188
+                       }
+
+                       $hideFileList = !($share->getPermissions() & Constants::PERMISSION_READ);
+                       $maxUploadFilesize = $freeSpace;
+
+                       $folder = new Template('files', 'list', '');
+
+                       $folder->assign('dir', $shareNode->getRelativePath($folderNode->getPath()));
+                       $folder->assign('dirToken', $token);
+                       $folder->assign('permissions', Constants::PERMISSION_READ);
+                       $folder->assign('isPublic', true);
+                       $folder->assign('hideFileList', $hideFileList);
+                       $folder->assign('publicUploadEnabled', 'no');
+                       // default to list view
+                       $folder->assign('showgridview', false);
+                       $folder->assign('uploadMaxFilesize', $maxUploadFilesize);
+                       $folder->assign('uploadMaxHumanFilesize', Util::humanFileSize($maxUploadFilesize));
+                       $folder->assign('freeSpace', $freeSpace);
+                       $folder->assign('usedSpacePercent', 0);
+                       $folder->assign('trash', false);
+                       $shareTmpl['folder'] = $folder->fetchPage();
+               } else {
+                       $shareIsFolder = false;
+               }
+
+               // default to list view
+               $shareTmpl['showgridview'] = false;
+
+               $shareTmpl['hideFileList'] = $hideFileList;
+               $shareTmpl['downloadURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.downloadShare', [
+                       'token' => $token,
+                       'filename' => $shareIsFolder ? null : $shareNode->getName()
+               ]);
+               $shareTmpl['shareUrl'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $token]);
+               $shareTmpl['maxSizeAnimateGif'] = $this->config->getSystemValue('max_filesize_animated_gifs_public_sharing', 10);
+               $shareTmpl['previewEnabled'] = $this->config->getSystemValue('enable_previews', true);
+               $shareTmpl['previewMaxX'] = $this->config->getSystemValue('preview_max_x', 1024);
+               $shareTmpl['previewMaxY'] = $this->config->getSystemValue('preview_max_y', 1024);
+               $shareTmpl['disclaimer'] = $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', '');
+               $shareTmpl['previewURL'] = $shareTmpl['downloadURL'];
+
+               if ($shareTmpl['previewSupported']) {
+                       $shareTmpl['previewImage'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview',
+                               ['x' => 200, 'y' => 200, 'file' => $shareTmpl['directory_path'], 'token' => $shareTmpl['dirToken']]);
+                       $ogPreview = $shareTmpl['previewImage'];
+
+                       // We just have direct previews for image files
+                       if ($shareNode->getMimePart() === 'image') {
+                               $shareTmpl['previewURL'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.publicpreview.directLink', ['token' => $token]);
+
+                               $ogPreview = $shareTmpl['previewURL'];
+
+                               //Whatapp is kind of picky about their size requirements
+                               if ($this->request->isUserAgent(['/^WhatsApp/'])) {
+                                       $ogPreview = $this->urlGenerator->linkToRouteAbsolute('files_sharing.PublicPreview.getPreview', [
+                                               'token' => $token,
+                                               'x' => 256,
+                                               'y' => 256,
+                                               'a' => true,
+                                       ]);
+                               }
+                       }
+               } else {
+                       $shareTmpl['previewImage'] = $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('core', 'favicon-fb.png'));
+                       $ogPreview = $shareTmpl['previewImage'];
+               }
+
+               // Load files we need
+               Util::addScript('files', 'semaphore');
+               Util::addScript('files', 'file-upload');
+               Util::addStyle('files_sharing', 'publicView');
+               Util::addScript('files_sharing', 'public');
+               Util::addScript('files_sharing', 'templates');
+               Util::addScript('files', 'fileactions');
+               Util::addScript('files', 'fileactionsmenu');
+               Util::addScript('files', 'jquery.fileupload');
+               Util::addScript('files_sharing', 'files_drop');
+
+               if (isset($shareTmpl['folder'])) {
+                       // JS required for folders
+                       Util::addStyle('files', 'merged');
+                       Util::addScript('files', 'filesummary');
+                       Util::addScript('files', 'templates');
+                       Util::addScript('files', 'breadcrumb');
+                       Util::addScript('files', 'fileinfomodel');
+                       Util::addScript('files', 'newfilemenu');
+                       Util::addScript('files', 'files');
+                       Util::addScript('files', 'filemultiselectmenu');
+                       Util::addScript('files', 'filelist');
+                       Util::addScript('files', 'keyboardshortcuts');
+                       Util::addScript('files', 'operationprogressbar');
+               }
+
+               // Load Viewer scripts
+               if (class_exists(LoadViewer::class)) {
+                       $this->eventDispatcher->dispatchTyped(new LoadViewer());
+               }
+               // OpenGraph Support: http://ogp.me/
+               Util::addHeader('meta', ['property' => "og:title", 'content' => $shareTmpl['filename']]);
+               Util::addHeader('meta', ['property' => "og:description", 'content' => $this->defaults->getName() . ($this->defaults->getSlogan() !== '' ? ' - ' . $this->defaults->getSlogan() : '')]);
+               Util::addHeader('meta', ['property' => "og:site_name", 'content' => $this->defaults->getName()]);
+               Util::addHeader('meta', ['property' => "og:url", 'content' => $shareTmpl['shareUrl']]);
+               Util::addHeader('meta', ['property' => "og:type", 'content' => "object"]);
+               Util::addHeader('meta', ['property' => "og:image", 'content' => $ogPreview]);
+
+               $this->eventDispatcher->dispatchTyped(new BeforeTemplateRenderedEvent($share));
+
+               $csp = new ContentSecurityPolicy();
+               $csp->addAllowedFrameDomain('\'self\'');
+
+               $response = new PublicTemplateResponse(Application::APP_ID, 'public', $shareTmpl);
+               $response->setHeaderTitle($shareTmpl['filename']);
+               if ($shareTmpl['shareOwner'] !== '') {
+                       $response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['shareOwner']]));
+               }
+
+               $isNoneFileDropFolder = $shareIsFolder === false || $share->getPermissions() !== Constants::PERMISSION_CREATE;
+
+               if ($isNoneFileDropFolder && !$share->getHideDownload()) {
+                       Util::addScript('files_sharing', 'public_note');
+
+                       $downloadWhite = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $shareTmpl['downloadURL'], 0);
+                       $downloadAllWhite = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download-white', $shareTmpl['downloadURL'], 0);
+                       $download = new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']);
+                       $downloadAll = new SimpleMenuAction('download', $this->l10n->t('Download all files'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']);
+                       $directLink = new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $shareTmpl['previewURL']);
+                       // TRANSLATORS The placeholder refers to the software product name as in 'Add to your Nextcloud'
+                       $externalShare = new ExternalShareMenuAction($this->l10n->t('Add to your %s', [$this->defaults->getProductName()]), 'icon-external', $shareTmpl['owner'], $shareTmpl['shareOwner'], $shareTmpl['filename']);
+
+                       $responseComposer = [];
+
+                       if ($shareIsFolder) {
+                               $responseComposer[] = $downloadAllWhite;
+                               $responseComposer[] = $downloadAll;
+                       } else {
+                               $responseComposer[] = $downloadWhite;
+                               $responseComposer[] = $download;
+                       }
+                       $responseComposer[] = $directLink;
+                       if ($this->federatedShareProvider->isOutgoingServer2serverShareEnabled()) {
+                               $responseComposer[] = $externalShare;
+                       }
+
+                       $response->setHeaderActions($responseComposer);
+               }
+
+               $response->setContentSecurityPolicy($csp);
+               return $response;
+       }
+}
index ad83732cc2851f8dd48d4f552289365797598abe..abb3b195bc60b8e331679c260eb5501c59d5c67a 100644 (file)
@@ -115,7 +115,7 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
                        <div id="drop-upload-done-indicator" style="padding-top: 25px;" class="hidden"><?php p($l->t('Uploaded files:')) ?></div>
                        <ul id="drop-uploaded-files"></ul>
 
-                       <?php if (!empty($_['disclaimer'])) { ?>
+                       <?php if ($_['disclaimer'] !== '') { ?>
                                <div>
                                        <?php
                                                echo $l->t('By uploading files, you agree to the %1$sterms of service%2$s.', [
index 781372b889e3b219b092103b05b7d5450c443321..7445fa1d7ab37dc819e6f07884546c56e663b646 100644 (file)
@@ -69,6 +69,8 @@ use OCP\Activity\IManager;
 use OCP\Files\IRootFolder;
 use OCP\Defaults;
 use OC\Share20\Manager;
+use OCA\Files_Sharing\DefaultPublicShareTemplateProvider;
+use OCP\Share\IPublicShareTemplateFactory;
 
 /**
  * @group DB
@@ -110,6 +112,8 @@ class ShareControllerTest extends \Test\TestCase {
        private $secureRandom;
        /** @var Defaults|MockObject */
        private $defaults;
+       /** @var IPublicShareTemplateFactory|MockObject */
+       private $publicShareTemplateFactory;
 
        protected function setUp(): void {
                parent::setUp();
@@ -131,6 +135,24 @@ class ShareControllerTest extends \Test\TestCase {
                $this->l10n = $this->createMock(IL10N::class);
                $this->secureRandom = $this->createMock(ISecureRandom::class);
                $this->defaults = $this->createMock(Defaults::class);
+               $this->publicShareTemplateFactory = $this->createMock(IPublicShareTemplateFactory::class);
+               $this->publicShareTemplateFactory
+                       ->expects($this->any())
+                       ->method('getProvider')
+                       ->willReturn(
+                               new DefaultPublicShareTemplateProvider(
+                                       $this->userManager,
+                                       $this->accountManager,
+                                       $this->previewManager,
+                                       $this->federatedShareProvider,
+                                       $this->urlGenerator,
+                                       $this->eventDispatcher,
+                                       $this->l10n,
+                                       $this->defaults,
+                                       $this->config,
+                                       $this->createMock(IRequest::class),
+                               )
+                       );
 
                $this->shareController = new \OCA\Files_Sharing\Controller\ShareController(
                        $this->appName,
@@ -149,7 +171,8 @@ class ShareControllerTest extends \Test\TestCase {
                        $this->eventDispatcher,
                        $this->l10n,
                        $this->secureRandom,
-                       $this->defaults
+                       $this->defaults,
+                       $this->publicShareTemplateFactory,
                );
 
 
index 3968834c11bc56b6e5f5ebe288097accb3624b46..b58b675cf9d06f69608ce806062060a26628537f 100644 (file)
@@ -557,6 +557,8 @@ return array(
     'OCP\\Share\\IAttributes' => $baseDir . '/lib/public/Share/IAttributes.php',
     'OCP\\Share\\IManager' => $baseDir . '/lib/public/Share/IManager.php',
     'OCP\\Share\\IProviderFactory' => $baseDir . '/lib/public/Share/IProviderFactory.php',
+    'OCP\\Share\\IPublicShareTemplateFactory' => $baseDir . '/lib/public/Share/IPublicShareTemplateFactory.php',
+    'OCP\\Share\\IPublicShareTemplateProvider' => $baseDir . '/lib/public/Share/IPublicShareTemplateProvider.php',
     'OCP\\Share\\IShare' => $baseDir . '/lib/public/Share/IShare.php',
     'OCP\\Share\\IShareHelper' => $baseDir . '/lib/public/Share/IShareHelper.php',
     'OCP\\Share\\IShareProvider' => $baseDir . '/lib/public/Share/IShareProvider.php',
@@ -1557,6 +1559,7 @@ return array(
     'OC\\Share20\\LegacyHooks' => $baseDir . '/lib/private/Share20/LegacyHooks.php',
     'OC\\Share20\\Manager' => $baseDir . '/lib/private/Share20/Manager.php',
     'OC\\Share20\\ProviderFactory' => $baseDir . '/lib/private/Share20/ProviderFactory.php',
+    'OC\\Share20\\PublicShareTemplateFactory' => $baseDir . '/lib/private/Share20/PublicShareTemplateFactory.php',
     'OC\\Share20\\Share' => $baseDir . '/lib/private/Share20/Share.php',
     'OC\\Share20\\ShareAttributes' => $baseDir . '/lib/private/Share20/ShareAttributes.php',
     'OC\\Share20\\ShareHelper' => $baseDir . '/lib/private/Share20/ShareHelper.php',
index fea7903e58c8b51a7b6905999d08a6209ca1b865..50f520205ce01f1fd2de6ff7510adc8bdaa65f89 100644 (file)
@@ -590,6 +590,8 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
         'OCP\\Share\\IAttributes' => __DIR__ . '/../../..' . '/lib/public/Share/IAttributes.php',
         'OCP\\Share\\IManager' => __DIR__ . '/../../..' . '/lib/public/Share/IManager.php',
         'OCP\\Share\\IProviderFactory' => __DIR__ . '/../../..' . '/lib/public/Share/IProviderFactory.php',
+        'OCP\\Share\\IPublicShareTemplateFactory' => __DIR__ . '/../../..' . '/lib/public/Share/IPublicShareTemplateFactory.php',
+        'OCP\\Share\\IPublicShareTemplateProvider' => __DIR__ . '/../../..' . '/lib/public/Share/IPublicShareTemplateProvider.php',
         'OCP\\Share\\IShare' => __DIR__ . '/../../..' . '/lib/public/Share/IShare.php',
         'OCP\\Share\\IShareHelper' => __DIR__ . '/../../..' . '/lib/public/Share/IShareHelper.php',
         'OCP\\Share\\IShareProvider' => __DIR__ . '/../../..' . '/lib/public/Share/IShareProvider.php',
@@ -1590,6 +1592,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
         'OC\\Share20\\LegacyHooks' => __DIR__ . '/../../..' . '/lib/private/Share20/LegacyHooks.php',
         'OC\\Share20\\Manager' => __DIR__ . '/../../..' . '/lib/private/Share20/Manager.php',
         'OC\\Share20\\ProviderFactory' => __DIR__ . '/../../..' . '/lib/private/Share20/ProviderFactory.php',
+        'OC\\Share20\\PublicShareTemplateFactory' => __DIR__ . '/../../..' . '/lib/private/Share20/PublicShareTemplateFactory.php',
         'OC\\Share20\\Share' => __DIR__ . '/../../..' . '/lib/private/Share20/Share.php',
         'OC\\Share20\\ShareAttributes' => __DIR__ . '/../../..' . '/lib/private/Share20/ShareAttributes.php',
         'OC\\Share20\\ShareHelper' => __DIR__ . '/../../..' . '/lib/private/Share20/ShareHelper.php',
index 236aa106d023d34fba42b03201746b705f6cb456..a78a895d0292dde829f4187f6090fdbfc0b61e6a 100644 (file)
@@ -52,6 +52,7 @@ use OCP\Http\WellKnown\IHandler;
 use OCP\Notification\INotifier;
 use OCP\Profile\ILinkAction;
 use OCP\Search\IProvider;
+use OCP\Share\IPublicShareTemplateProvider;
 use OCP\Support\CrashReport\IReporter;
 use OCP\UserMigration\IMigrator as IUserMigrator;
 use Psr\Log\LoggerInterface;
@@ -127,6 +128,9 @@ class RegistrationContext {
        /** @var ParameterRegistration[] */
        private $sensitiveMethods = [];
 
+       /** @var ServiceRegistration<IPublicShareTemplateProvider>[] */
+       private $publicShareTemplateProviders = [];
+
        /** @var LoggerInterface */
        private $logger;
 
@@ -326,6 +330,13 @@ class RegistrationContext {
                                        $methods
                                );
                        }
+
+                       public function registerPublicShareTemplateProvider(string $class): void {
+                               $this->context->registerPublicShareTemplateProvider(
+                                       $this->appId,
+                                       $class
+                               );
+                       }
                };
        }
 
@@ -461,6 +472,10 @@ class RegistrationContext {
                $this->sensitiveMethods[] = new ParameterRegistration($appId, $class, $methods);
        }
 
+       public function registerPublicShareTemplateProvider(string $appId, string $class): void {
+               $this->publicShareTemplateProviders[] = new ServiceRegistration($appId, $class);
+       }
+
        /**
         * @param App[] $apps
         */
@@ -738,4 +753,11 @@ class RegistrationContext {
        public function getSensitiveMethods(): array {
                return $this->sensitiveMethods;
        }
+
+       /**
+        * @return ServiceRegistration<IPublicShareTemplateProvider>[]
+        */
+       public function getPublicShareTemplateProviders(): array {
+               return $this->publicShareTemplateProviders;
+       }
 }
index d8857b4efc6c13141cf5d6a1acefc5cce21be2bf..bd33cdf58bd804ac3735a31b7f8401e45421c74b 100644 (file)
@@ -1451,6 +1451,8 @@ class Server extends ServerContainer implements IServerContainer {
 
                $this->registerAlias(IBinaryFinder::class, BinaryFinder::class);
 
+               $this->registerAlias(\OCP\Share\IPublicShareTemplateFactory::class, \OC\Share20\PublicShareTemplateFactory::class);
+
                $this->connectDispatcher();
        }
 
diff --git a/lib/private/Share20/PublicShareTemplateFactory.php b/lib/private/Share20/PublicShareTemplateFactory.php
new file mode 100644 (file)
index 0000000..222f327
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2023 Louis Chemineau <louis@chmn.me>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OC\Share20;
+
+use Exception;
+use OC\AppFramework\Bootstrap\Coordinator;
+use OCA\Files_Sharing\DefaultPublicShareTemplateProvider;
+use OCP\Server;
+use OCP\Share\IShare;
+use OCP\Share\IPublicShareTemplateFactory;
+use OCP\Share\IPublicShareTemplateProvider;
+
+class PublicShareTemplateFactory implements IPublicShareTemplateFactory {
+       public function __construct(
+               private Coordinator $coordinator,
+               private DefaultPublicShareTemplateProvider $defaultProvider,
+       ) {
+       }
+
+       public function getProvider(IShare $share): IPublicShareTemplateProvider {
+               $context = $this->coordinator->getRegistrationContext();
+               if ($context === null) {
+                       throw new Exception("Can't retrieve public share template providers as context is not defined");
+               }
+
+               $providers = array_map(
+                       fn ($registration) => Server::get($registration->getService()),
+                       $context->getPublicShareTemplateProviders()
+               );
+
+               $filteredProviders = array_filter(
+                       $providers,
+                       fn (IPublicShareTemplateProvider $provider) => $provider->shouldRespond($share)
+               );
+
+               if (count($filteredProviders) === 0) {
+                       return $this->defaultProvider;
+               } else {
+                       return array_shift($filteredProviders);
+               }
+       }
+}
index 3748714bb79ae17af3dc94ca5af7298ee17dea37..6350169510fd4a01d7e46aa204ebcce09678b4b7 100644 (file)
@@ -328,4 +328,14 @@ interface IRegistrationContext {
         * @since 25.0.0
         */
        public function registerSensitiveMethods(string $class, array $methods): void;
+
+       /**
+        * Register an implementation of IPublicShareTemplateProvider.
+        *
+        * @param string $class
+        * @psalm-param class-string<\OCP\Share\IPublicShareTemplateProvider> $class
+        * @return void
+        * @since 26.0.0
+        */
+       public function registerPublicShareTemplateProvider(string $class): void;
 }
diff --git a/lib/public/Share/IPublicShareTemplateFactory.php b/lib/public/Share/IPublicShareTemplateFactory.php
new file mode 100644 (file)
index 0000000..248473c
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2023 Louis Chemineau <louis@chmn.me>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Share;
+
+/**
+ * @since 26.0.0
+ */
+interface IPublicShareTemplateFactory {
+       /**
+        * Returns a provider that is willing to respond for given share.
+        * @since 26.0.0
+        */
+       public function getProvider(IShare $share): IPublicShareTemplateProvider;
+}
diff --git a/lib/public/Share/IPublicShareTemplateProvider.php b/lib/public/Share/IPublicShareTemplateProvider.php
new file mode 100644 (file)
index 0000000..5ef5ada
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2023 Louis Chemineau <louis@chmn.me>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Share;
+
+use OCP\AppFramework\Http\TemplateResponse;
+
+/**
+ * @since 26.0.0
+ */
+interface IPublicShareTemplateProvider {
+       /**
+        * Returns whether the provider can respond for the given share.
+        * @since 26.0.0
+        */
+       public function shouldRespond(IShare $share): bool;
+       /**
+        * Returns the a template for a given share.
+        * @since 26.0.0
+        */
+       public function renderPage(IShare $share, string $token, string $path): TemplateResponse;
+}