summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMax <max@nextcloud.com>2022-08-01 12:02:12 +0200
committerVincent Petry (Rebase PR Action) <PVince81@users.noreply.github.com>2022-08-25 21:59:20 +0000
commit8c9470320aa153980cd2c95687a721eb9655c60a (patch)
tree6ea2bf398a72337ae6607782b01fd54f29af8037 /apps
parent99aa938452a089e66fe993c98a4292fcfa9caa15 (diff)
downloadnextcloud-server-8c9470320aa153980cd2c95687a721eb9655c60a.tar.gz
nextcloud-server-8c9470320aa153980cd2c95687a721eb9655c60a.zip
fix: only use viewer when mimetype is supported
Also bring back the text fallback Signed-off-by: Max <max@nextcloud.com>
Diffstat (limited to 'apps')
-rw-r--r--apps/files_sharing/js/public.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index cbb218ca3a2..5ae62939dc1 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -129,11 +129,22 @@ OCA.Sharing.PublicApp = {
}
}
- var bottomMargin = 350;
- var previewWidth = $(window).width();
- var previewHeight = $(window).height() - bottomMargin;
- OCA.Viewer.setRootElement('#imgframe')
- OCA.Viewer.open({ path: '/' })
+ if (OCA.Viewer.mimetypes.includes(mimetype)) {
+ OCA.Viewer.setRootElement('#imgframe')
+ OCA.Viewer.open({ path: '/' })
+ } else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text' && window.btoa) {
+ // Undocumented Url to public WebDAV endpoint
+ var url = parent.location.protocol + '//' + location.host + OC.linkTo('', 'public.php/webdav');
+ $.ajax({
+ url: url,
+ headers: {
+ Authorization: 'Basic ' + btoa(token + ':'),
+ Range: 'bytes=0-10000'
+ }
+ }).then(function (data) {
+ self._showTextPreview(data, previewHeight);
+ });
+ }
if (this.fileList) {
// TODO: move this to a separate PublicFileList class that extends OCA.Files.FileList (+ unit tests)