diff options
author | Vincent Petry <vincent@nextcloud.com> | 2022-08-26 09:04:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-26 09:04:18 +0200 |
commit | 264a0bb17d62dafd0a2dee050110c454f30d1636 (patch) | |
tree | cb1184c905e756a6c6fcd040d48cf89980f854e0 /apps | |
parent | e69ad6fe2dd75476fcef864aee258191b29ebb8d (diff) | |
parent | b67aaf7ab0fb2e2b7c727290e6b1321557126380 (diff) | |
download | nextcloud-server-264a0bb17d62dafd0a2dee050110c454f30d1636.tar.gz nextcloud-server-264a0bb17d62dafd0a2dee050110c454f30d1636.zip |
Merge pull request #33347 from nextcloud/feature/use-viewer-for-singe-file-shares
feature: use the viewer to render single file shares
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files_sharing/css/mobile.css | 1 | ||||
-rw-r--r-- | apps/files_sharing/css/mobile.css.map | 2 | ||||
-rw-r--r-- | apps/files_sharing/css/mobile.scss | 1 | ||||
-rw-r--r-- | apps/files_sharing/css/public.css | 14 | ||||
-rw-r--r-- | apps/files_sharing/css/public.css.map | 2 | ||||
-rw-r--r-- | apps/files_sharing/css/public.scss | 13 | ||||
-rw-r--r-- | apps/files_sharing/css/publicView.css | 15 | ||||
-rw-r--r-- | apps/files_sharing/css/publicView.css.map | 2 | ||||
-rw-r--r-- | apps/files_sharing/js/public.js | 15 | ||||
-rw-r--r-- | apps/files_sharing/lib/Controller/ShareController.php | 9 | ||||
-rw-r--r-- | apps/files_sharing/templates/public.php | 38 |
11 files changed, 67 insertions, 45 deletions
diff --git a/apps/files_sharing/css/mobile.css b/apps/files_sharing/css/mobile.css index 114949d8c48..96b9736b6ac 100644 --- a/apps/files_sharing/css/mobile.css +++ b/apps/files_sharing/css/mobile.css @@ -43,7 +43,6 @@ table td.date { #imgframe { width: 100%; padding: 0; - margin-bottom: 35px; } /* some margin for the file type icon */ diff --git a/apps/files_sharing/css/mobile.css.map b/apps/files_sharing/css/mobile.css.map index 36f4289e94a..ab822b947db 100644 --- a/apps/files_sharing/css/mobile.css.map +++ b/apps/files_sharing/css/mobile.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../../../core/css/variables.scss","mobile.scss"],"names":[],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACEA;AAEA;EACA;IACC;;;AAGD;EACA;AAAA;AAAA;AAAA;IAIC;;;AAGD;EACA;IACC;;;AAGD;EACA;IACC;IACA;IACA;;;AAED;EACA;IACC;;;AAGD;EACA;IACC;;;AAED;EACA;IACC;;;AAGD;EACA;IACC;IACA;IACA;IACA;;;EAGD;IACI;IACA;;;EAEJ;IACC;;;EAGD;IACC","file":"mobile.css"}
\ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../../../core/css/variables.scss","mobile.scss"],"names":[],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACEA;AAEA;EACA;IACC;;;AAGD;EACA;AAAA;AAAA;AAAA;IAIC;;;AAGD;EACA;IACC;;;AAGD;EACA;IACC;IACA;;;AAED;EACA;IACC;;;AAGD;EACA;IACC;;;AAED;EACA;IACC;;;AAGD;EACA;IACC;IACA;IACA;IACA;;;EAGD;IACI;IACA;;;EAEJ;IACC;;;EAGD;IACC","file":"mobile.css"}
\ No newline at end of file diff --git a/apps/files_sharing/css/mobile.scss b/apps/files_sharing/css/mobile.scss index d058ad2a30e..5800bf6755f 100644 --- a/apps/files_sharing/css/mobile.scss +++ b/apps/files_sharing/css/mobile.scss @@ -24,7 +24,6 @@ table td.filename .nametext { #imgframe { width: 100%; padding: 0; - margin-bottom: 35px; } /* some margin for the file type icon */ #imgframe .publicpreview { diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index a07b00b7b3d..ad80b871454 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -41,6 +41,11 @@ margin: 0 auto; } +#imgframe #viewer { + height: 100%; + width: 100%; +} + #imgframe img { max-height: 100% !important; max-width: 100% !important; @@ -67,6 +72,15 @@ font-size: 1.2em; } +#imgframe .viewer__file { + height: 100%; + width: 100%; +} + +#imgframe .plyr { + max-height: 100%; +} + /* fix multiselect bar offset on shared page */ thead { left: 0 !important; diff --git a/apps/files_sharing/css/public.css.map b/apps/files_sharing/css/public.css.map index c100a63b6d8..685bc56dd9e 100644 --- a/apps/files_sharing/css/public.css.map +++ b/apps/files_sharing/css/public.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../../../core/css/variables.scss","public.scss"],"names":[],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACEA;EACC;;;AAGD;EACC;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;;;AAID;EACC;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AACA;EACC;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AACA;EACC;;;AAED;AAAA;AAAA;EAGC;EACA;;;AAED;AAAA;AAAA;AAGC;EACA;;;AAGD;EACC;;;AAIA;EACC;;;AAIF;EACC;;;AAGD;EACC;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AAAA;EAEC;EACA;EACA;;;AAGD;EACC;EACA;EACA;;AACA;EACC;EACA;;;AAIF;EACC;EACA;;;AAKD;EAII;IACC;;;AAQL;EAGG;IACC","file":"public.css"}
\ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../../../core/css/variables.scss","public.scss"],"names":[],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACEA;EACC;;;AAGD;EACC;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;EACC;EACA;;;AAGD;EACC;;;AAGD;AACA;EACC;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AACA;EACC;;;AAED;AAAA;AAAA;EAGC;EACA;;;AAED;AAAA;AAAA;AAGC;EACA;;;AAGD;EACC;;;AAIA;EACC;;;AAIF;EACC;;;AAGD;EACC;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AAAA;EAEC;EACA;EACA;;;AAGD;EACC;EACA;EACA;;AACA;EACC;EACA;;;AAIF;EACC;EACA;;;AAKD;EAII;IACC;;;AAQL;EAGG;IACC","file":"public.css"}
\ No newline at end of file diff --git a/apps/files_sharing/css/public.scss b/apps/files_sharing/css/public.scss index 4b3ea818be8..588a11d30a7 100644 --- a/apps/files_sharing/css/public.scss +++ b/apps/files_sharing/css/public.scss @@ -21,6 +21,10 @@ margin:0 auto; } +#imgframe #viewer { + height: 100%; + width: 100%; +} #imgframe img { max-height: 100% !important; @@ -48,6 +52,15 @@ font-size: 1.2em; } +#imgframe .viewer__file { + height: 100%; + width: 100%; +} + +#imgframe .plyr { + max-height: 100%; +} + /* fix multiselect bar offset on shared page */ thead { left: 0 !important; diff --git a/apps/files_sharing/css/publicView.css b/apps/files_sharing/css/publicView.css index 91429ffbdab..d37218f76aa 100644 --- a/apps/files_sharing/css/publicView.css +++ b/apps/files_sharing/css/publicView.css @@ -41,6 +41,11 @@ margin: 0 auto; } +#imgframe #viewer { + height: 100%; + width: 100%; +} + #imgframe img { max-height: 100% !important; max-width: 100% !important; @@ -67,6 +72,15 @@ font-size: 1.2em; } +#imgframe .viewer__file { + height: 100%; + width: 100%; +} + +#imgframe .plyr { + max-height: 100%; +} + /* fix multiselect bar offset on shared page */ thead { left: 0 !important; @@ -277,7 +291,6 @@ table td.date { #imgframe { width: 100%; padding: 0; - margin-bottom: 35px; } /* some margin for the file type icon */ diff --git a/apps/files_sharing/css/publicView.css.map b/apps/files_sharing/css/publicView.css.map index e49de3e17ba..5ece94c690a 100644 --- a/apps/files_sharing/css/publicView.css.map +++ b/apps/files_sharing/css/publicView.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../../../core/css/variables.scss","public.scss","mobile.scss"],"names":[],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACEA;EACC;;;AAGD;EACC;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;;;AAID;EACC;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AACA;EACC;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AACA;EACC;;;AAED;AAAA;AAAA;EAGC;EACA;;;AAED;AAAA;AAAA;AAGC;EACA;;;AAGD;EACC;;;AAIA;EACC;;;AAIF;EACC;;;AAGD;EACC;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AAAA;EAEC;EACA;EACA;;;AAGD;EACC;EACA;EACA;;AACA;EACC;EACA;;;AAIF;EACC;EACA;;;AAKD;EAII;IACC;;;AAQL;EAGG;IACC;;;ADjOJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AEEA;AAEA;EACA;IACC;;;AAGD;EACA;AAAA;AAAA;AAAA;IAIC;;;AAGD;EACA;IACC;;;AAGD;EACA;IACC;IACA;IACA;;;AAED;EACA;IACC;;;AAGD;EACA;IACC;;;AAED;EACA;IACC;;;AAGD;EACA;IACC;IACA;IACA;IACA;;;EAGD;IACI;IACA;;;EAEJ;IACC;;;EAGD;IACC","file":"publicView.css"}
\ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../../../core/css/variables.scss","public.scss","mobile.scss"],"names":[],"mappings":";AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACEA;EACC;;;AAGD;EACC;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;EACC;EACA;;;AAGD;EACC;;;AAGD;AACA;EACC;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;AACA;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AACA;EACC;;;AAED;AAAA;AAAA;EAGC;EACA;;;AAED;AAAA;AAAA;AAGC;EACA;;;AAGD;EACC;;;AAIA;EACC;;;AAIF;EACC;;;AAGD;EACC;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;EACA;EACA;;;AAGD;EACC;EACA;EACA;;;AAGD;EACC;EACA;;;AAGD;EACC;EACA;EACA;EACA;EACA;;;AAGD;EACC;;;AAGD;AAAA;EAEC;EACA;EACA;;;AAGD;EACC;EACA;EACA;;AACA;EACC;EACA;;;AAIF;EACC;EACA;;;AAKD;EAII;IACC;;;AAQL;EAGG;IACC;;;AD9OJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AEEA;AAEA;EACA;IACC;;;AAGD;EACA;AAAA;AAAA;AAAA;IAIC;;;AAGD;EACA;IACC;;;AAGD;EACA;IACC;IACA;;;AAED;EACA;IACC;;;AAGD;EACA;IACC;;;AAED;EACA;IACC;;;AAGD;EACA;IACC;IACA;IACA;IACA;;;EAGD;IACI;IACA;;;EAEJ;IACC;;;EAGD;IACC","file":"publicView.css"}
\ No newline at end of file diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index 64bd98ab8d8..a0a57c41e9d 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -129,7 +129,6 @@ OCA.Sharing.PublicApp = { } } - // dynamically load image previews var bottomMargin = 350; var previewWidth = $(window).width(); @@ -153,13 +152,10 @@ OCA.Sharing.PublicApp = { 'max-height': previewHeight }); - var fileSize = parseInt($('#filesize').val(), 10); - var maxGifSize = parseInt($('#maxSizeAnimateGif').val(), 10); - - if (mimetype === 'image/gif' && - (maxGifSize === -1 || fileSize <= (maxGifSize * 1024 * 1024))) { - img.attr('src', $('#downloadURL').val()); - imgcontainer.appendTo('#imgframe'); + if (OCA.Viewer && OCA.Viewer.mimetypes.includes(mimetype) + && (mimetype.startsWith('image/') || mimetype.startsWith('video/'))) { + OCA.Viewer.setRootElement('#imgframe') + OCA.Viewer.open({ path: '/' }) } else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text' && window.btoa) { if (OC.appswebroots['files_texteditor'] !== undefined || OC.appswebroots['text'] !== undefined) { @@ -189,8 +185,7 @@ OCA.Sharing.PublicApp = { // the icon should appear before, so the container should be // prepended to the frame. imgcontainer.prependTo('#imgframe'); - } - else if (previewSupported === 'true') { + } else if (previewSupported === 'true') { $('#imgframe > video').attr('poster', OC.generateUrl('/apps/files_sharing/publicpreview/' + token + '?' + OC.buildQueryString(params))); } diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index a12878e6de2..87f143facd0 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -523,13 +523,12 @@ class ShareController extends AuthPublicShareController { \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()); - } } + // 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() : '')]); diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 7e6289784ae..13e4366c1c1 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -60,31 +60,21 @@ $maxUploadFilesize = min($upload_max_filesize, $post_max_size); <?php if (isset($_['folder'])): ?> <?php print_unescaped($_['folder']); ?> <?php else: ?> - <?php if ($_['previewEnabled'] && substr($_['mimetype'], 0, strpos($_['mimetype'], '/')) == 'audio'): ?> - <div id="imgframe"> - <audio tabindex="0" controls="" preload="none" style="width: 100%; max-width: <?php p($_['previewMaxX']); ?>px; max-height: <?php p($_['previewMaxY']); ?>px" - <?php // See https://github.com/nextcloud/server/pull/27674?> - <?php if ($_['hideDownload']) { ?>controlsList="nodownload" <?php } ?>> - <source src="<?php p($_['downloadURL']); ?>" type="<?php p($_['mimetype']); ?>" /> - </audio> - </div> - <?php else: ?> - <!-- Preview frame is filled via JS to support SVG images for modern browsers --> - <div id="imgframe"></div> - <?php if (isset($_['mimetype']) && strpos($_['mimetype'], 'image') === 0) { ?> - <div class="directDownload"> - <div> - <?php p($_['filename'])?> (<?php p($_['fileSize']) ?>) - </div> - <?php if (!$_['hideDownload']) { ?> - <a href="<?php p($_['downloadURL']); ?>" id="downloadFile" class="button"> - <span class="icon icon-download"></span> - <?php p($l->t('Download'))?> - </a> - <?php } ?> - </div> + <!-- preview frame to open file in with viewer --> + <div id="imgframe"></div> + <?php if (isset($_['mimetype']) && strpos($_['mimetype'], 'image') === 0) { ?> + <div class="directDownload"> + <div> + <?php p($_['filename'])?> (<?php p($_['fileSize']) ?>) + </div> + <?php if (!$_['hideDownload']) { ?> + <a href="<?php p($_['downloadURL']); ?>" id="downloadFile" class="button"> + <span class="icon icon-download"></span> + <?php p($l->t('Download'))?> + </a> <?php } ?> - <?php endif; ?> + </div> + <?php } ?> <?php if ($_['previewURL'] === $_['downloadURL'] && !$_['hideDownload']): ?> <div class="directDownload"> <div> |