summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-04-20 17:44:41 +0200
committerOlivier Paroz <github@oparoz.com>2015-04-23 18:19:29 +0200
commit58a87d0babcb91aab75b45e630d2fc2fee15691e (patch)
treed71d4a5c0a73c9ebb0161130be6787a25abca178
parenta968877a8b0454861dc27b763023ce52429a39dc (diff)
downloadnextcloud-server-58a87d0babcb91aab75b45e630d2fc2fee15691e.tar.gz
nextcloud-server-58a87d0babcb91aab75b45e630d2fc2fee15691e.zip
Use authorization headers for better compatibility
+ add ellipsis + fix OC.generateUrl calls
-rw-r--r--apps/files_sharing/js/public.js47
1 files changed, 25 insertions, 22 deletions
diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js
index c08b7c7859c..cf049411c9b 100644
--- a/apps/files_sharing/js/public.js
+++ b/apps/files_sharing/js/public.js
@@ -112,26 +112,15 @@ OCA.Sharing.PublicApp = {
img.appendTo('#imgframe');
} else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text') {
// Undocumented Url to public WebDAV endpoint
- var url = parent.location.protocol + '//' +
- token + '@' + location.host + OC.linkTo('', 'public.php/webdav');
+ var url = parent.location.protocol + '//' + location.host + OC.linkTo('', 'public.php/webdav');
$.ajax({
url: url,
- headers: {Range: "bytes=0-1000"}
- }).then(function (data) {
- var textDiv = $('<div/>').addClass('text-preview');
- textDiv.text(data);
- textDiv.appendTo('#imgframe');
- var divHeight = textDiv.height();
- if (data.length > 999) {
- textDiv.append('</br></br><strong>(...)</strong>');
- divHeight += 50;
- }
- if (divHeight > previewHeight) {
- textDiv.height(previewHeight);
+ headers: {
+ Authorization: 'Basic ' + btoa(token + ':'),
+ Range: 'bytes=0-1000'
}
- var watermark = $('<div/>').addClass('watermark');
- watermark.text('SAMPLE');
- watermark.appendTo('#imgframe');
+ }).then(function (data) {
+ self._showTextPreview(data, previewHeight);
});
} else if (previewSupported === 'true' ||
mimetype.substr(0, mimetype.indexOf('/')) === 'image' &&
@@ -155,7 +144,7 @@ OCA.Sharing.PublicApp = {
path: path,
files: filename
};
- return OC.generateUrl('/s/' + token + '/download') + '?' + OC.buildQueryString(params);
+ return OC.generateUrl('/s/' + token + '/download', params);
};
this.fileList.getAjaxUrl = function (action, params) {
@@ -165,10 +154,7 @@ OCA.Sharing.PublicApp = {
};
this.fileList.linkTo = function (dir) {
- var params = {
- dir: dir
- };
- return OC.generateUrl('/s/' + token + '') + '?' + OC.buildQueryString(params);
+ return OC.generateUrl('/s/' + token + '', {dir: dir});
};
this.fileList.generatePreviewUrl = function (urlSpec) {
@@ -240,6 +226,23 @@ OCA.Sharing.PublicApp = {
window.FileList = this.fileList;
},
+ _showTextPreview: function (data, previewHeight) {
+ var textDiv = $('<div/>').addClass('text-preview');
+ textDiv.text(data);
+ textDiv.appendTo('#imgframe');
+ var divHeight = textDiv.height();
+ if (data.length > 999) {
+ textDiv.append('</br></br><strong>(&#133;)</strong>');
+ divHeight += 50;
+ }
+ if (divHeight > previewHeight) {
+ textDiv.height(previewHeight);
+ }
+ var watermark = $('<div/>').addClass('watermark');
+ watermark.text('SAMPLE');
+ watermark.appendTo('#imgframe');
+ },
+
_onDirectoryChanged: function (e) {
OC.Util.History.pushState({
// arghhhh, why is this not called "dir" !?