From 8a13851da8906a4eed3c7b59d01f5a172c90371c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 25 Jan 2018 18:53:09 +0100 Subject: [PATCH] Use PublicTemplateResponse for files_sharing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../composer/composer/autoload_classmap.php | 2 + .../composer/composer/autoload_static.php | 2 + apps/files_sharing/css/public.scss | 8 -- .../lib/Controller/ShareController.php | 16 ++- .../lib/Template/ExternalShareMenuAction.php | 54 ++++++++ .../lib/Template/LinkMenuAction.php | 47 +++++++ apps/files_sharing/templates/public.php | 131 +++++------------- 7 files changed, 158 insertions(+), 102 deletions(-) create mode 100644 apps/files_sharing/lib/Template/ExternalShareMenuAction.php create mode 100644 apps/files_sharing/lib/Template/LinkMenuAction.php diff --git a/apps/files_sharing/composer/composer/autoload_classmap.php b/apps/files_sharing/composer/composer/autoload_classmap.php index a68db3421b..0388c7990e 100644 --- a/apps/files_sharing/composer/composer/autoload_classmap.php +++ b/apps/files_sharing/composer/composer/autoload_classmap.php @@ -53,5 +53,7 @@ return array( 'OCA\\Files_Sharing\\ShareBackend\\Folder' => $baseDir . '/../lib/ShareBackend/Folder.php', 'OCA\\Files_Sharing\\SharedMount' => $baseDir . '/../lib/SharedMount.php', 'OCA\\Files_Sharing\\SharedStorage' => $baseDir . '/../lib/SharedStorage.php', + 'OCA\\Files_Sharing\\Template\\ExternalShareMenuAction' => $baseDir . '/../lib/Template/ExternalShareMenuAction.php', + 'OCA\\Files_Sharing\\Template\\LinkMenuAction' => $baseDir . '/../lib/Template/LinkMenuAction.php', 'OCA\\Files_Sharing\\Updater' => $baseDir . '/../lib/Updater.php', ); diff --git a/apps/files_sharing/composer/composer/autoload_static.php b/apps/files_sharing/composer/composer/autoload_static.php index 328d6aca01..dd75dbaa18 100644 --- a/apps/files_sharing/composer/composer/autoload_static.php +++ b/apps/files_sharing/composer/composer/autoload_static.php @@ -68,6 +68,8 @@ class ComposerStaticInitFiles_Sharing 'OCA\\Files_Sharing\\ShareBackend\\Folder' => __DIR__ . '/..' . '/../lib/ShareBackend/Folder.php', 'OCA\\Files_Sharing\\SharedMount' => __DIR__ . '/..' . '/../lib/SharedMount.php', 'OCA\\Files_Sharing\\SharedStorage' => __DIR__ . '/..' . '/../lib/SharedStorage.php', + 'OCA\\Files_Sharing\\Template\\ExternalShareMenuAction' => __DIR__ . '/..' . '/../lib/Template/ExternalShareMenuAction.php', + 'OCA\\Files_Sharing\\Template\\LinkMenuAction' => __DIR__ . '/..' . '/../lib/Template/LinkMenuAction.php', 'OCA\\Files_Sharing\\Updater' => __DIR__ . '/..' . '/../lib/Updater.php', ); diff --git a/apps/files_sharing/css/public.scss b/apps/files_sharing/css/public.scss index 5edc3f7eb9..1e9dec87fa 100644 --- a/apps/files_sharing/css/public.scss +++ b/apps/files_sharing/css/public.scss @@ -3,14 +3,6 @@ min-height: calc(100vh - 160px); } -#header .menutoggle { - padding: 14px; - padding-right: 40px; - background-position: right 15px center; - color: $color-primary-text; - cursor: pointer; -} - /* force layout to make sure the content element's height matches its contents' height */ .ie #content { display: inline-block; diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 795d069c1b..0b0c551a15 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -38,6 +38,10 @@ namespace OCA\Files_Sharing\Controller; use OC_Files; use OC_Util; use OCA\FederatedFileSharing\FederatedShareProvider; +use OCA\Files_Sharing\Template\ExternalShareMenuAction; +use OCA\Files_Sharing\Template\LinkMenuAction; +use OCP\AppFramework\Http\Template\SimpleMenuAction; +use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\Defaults; use OCP\IL10N; use OCP\Template; @@ -435,7 +439,17 @@ class ShareController extends Controller { $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); - $response = new TemplateResponse($this->appName, 'public', $shareTmpl, 'base'); + + $response = new PublicTemplateResponse($this->appName, 'public', $shareTmpl); + $response->setHeaderTitle($share->getNode()->getName()); + $response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['displayName']])); + $response->setHeaderActions([ + new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $shareTmpl['downloadURL'], 0), + new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']), + new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $shareTmpl['previewURL']), + new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $shareTmpl['owner'], $shareTmpl['displayName'], $shareTmpl['filename']), + ]); + $response->setContentSecurityPolicy($csp); $this->emitAccessShareHook($share); diff --git a/apps/files_sharing/lib/Template/ExternalShareMenuAction.php b/apps/files_sharing/lib/Template/ExternalShareMenuAction.php new file mode 100644 index 0000000000..a81712cb59 --- /dev/null +++ b/apps/files_sharing/lib/Template/ExternalShareMenuAction.php @@ -0,0 +1,54 @@ + + * + * @author Julius Härtl + * + * @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 . + * + */ + +namespace OCA\Files_Sharing\Template; + +use OCP\AppFramework\Http\Template\SimpleMenuAction; +use OCP\Util; + +class ExternalShareMenuAction extends SimpleMenuAction { + + private $owner; + private $displayname; + private $shareName; + + public function __construct($label, $icon, $owner, $displayname, $shareName) { + parent::__construct('save', $label, $icon); + $this->owner = $owner; + $this->displayname = $displayname; + $this->shareName = $shareName; + } + + public function render(): string { + return '
  • ' . + '' . + '' . + '' . Util::sanitizeHTML($this->getLabel()) . '' . + '' . + '' . + '
  • '; + } +} \ No newline at end of file diff --git a/apps/files_sharing/lib/Template/LinkMenuAction.php b/apps/files_sharing/lib/Template/LinkMenuAction.php new file mode 100644 index 0000000000..af5fda9445 --- /dev/null +++ b/apps/files_sharing/lib/Template/LinkMenuAction.php @@ -0,0 +1,47 @@ + + * + * @author Julius Härtl + * + * @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 . + * + */ + +namespace OCA\Files_Sharing\Template; + +use OCP\AppFramework\Http\Template\SimpleMenuAction; + +class LinkMenuAction extends SimpleMenuAction { + + public function __construct($label, $icon, $link) { + parent::__construct('directLink-container', $label, $icon, $link); + } + + /** + * @since 14.0.0 + * @return string + */ + public function render(): string { + return '
  • ' . + '' . + '' . + '' . + '' . + '' . + '
  • '; + } +} \ No newline at end of file diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 3c2bbe5fb5..698febd4c1 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -7,10 +7,6 @@ -
    - -
    - @@ -33,61 +29,9 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); - - -
    -
    - +
    -
    +
    @@ -102,46 +46,47 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
    - +
    -
    - - -
    -
    -
    -

    t('Upload files to %s', [$_['shareOwner']])) ?>

    -

    - -

    - - +
    + + +
    +
    +
    +

    t('Upload files to %s', [$_['shareOwner']])) ?>

    +

    + +

    + + + + t('Select or drop files')) ?> + + +
      +
    +
    +
    + - t('Select or drop files')) ?> - - -
      -
    -
    -
    -
    - +
    - -
    -

    - getLongFooter()); ?> -

    -
    -
    + + +