Use authorization headers for better compatibility
+ add ellipsis + fix OC.generateUrl calls
This commit is contained in:
parent
a968877a8b
commit
58a87d0bab
|
@ -112,26 +112,15 @@ OCA.Sharing.PublicApp = {
|
||||||
img.appendTo('#imgframe');
|
img.appendTo('#imgframe');
|
||||||
} else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text') {
|
} else if (mimetype.substr(0, mimetype.indexOf('/')) === 'text') {
|
||||||
// Undocumented Url to public WebDAV endpoint
|
// Undocumented Url to public WebDAV endpoint
|
||||||
var url = parent.location.protocol + '//' +
|
var url = parent.location.protocol + '//' + location.host + OC.linkTo('', 'public.php/webdav');
|
||||||
token + '@' + location.host + OC.linkTo('', 'public.php/webdav');
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: url,
|
url: url,
|
||||||
headers: {Range: "bytes=0-1000"}
|
headers: {
|
||||||
|
Authorization: 'Basic ' + btoa(token + ':'),
|
||||||
|
Range: 'bytes=0-1000'
|
||||||
|
}
|
||||||
}).then(function (data) {
|
}).then(function (data) {
|
||||||
var textDiv = $('<div/>').addClass('text-preview');
|
self._showTextPreview(data, previewHeight);
|
||||||
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);
|
|
||||||
}
|
|
||||||
var watermark = $('<div/>').addClass('watermark');
|
|
||||||
watermark.text('SAMPLE');
|
|
||||||
watermark.appendTo('#imgframe');
|
|
||||||
});
|
});
|
||||||
} else if (previewSupported === 'true' ||
|
} else if (previewSupported === 'true' ||
|
||||||
mimetype.substr(0, mimetype.indexOf('/')) === 'image' &&
|
mimetype.substr(0, mimetype.indexOf('/')) === 'image' &&
|
||||||
|
@ -155,7 +144,7 @@ OCA.Sharing.PublicApp = {
|
||||||
path: path,
|
path: path,
|
||||||
files: filename
|
files: filename
|
||||||
};
|
};
|
||||||
return OC.generateUrl('/s/' + token + '/download') + '?' + OC.buildQueryString(params);
|
return OC.generateUrl('/s/' + token + '/download', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fileList.getAjaxUrl = function (action, params) {
|
this.fileList.getAjaxUrl = function (action, params) {
|
||||||
|
@ -165,10 +154,7 @@ OCA.Sharing.PublicApp = {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fileList.linkTo = function (dir) {
|
this.fileList.linkTo = function (dir) {
|
||||||
var params = {
|
return OC.generateUrl('/s/' + token + '', {dir: dir});
|
||||||
dir: dir
|
|
||||||
};
|
|
||||||
return OC.generateUrl('/s/' + token + '') + '?' + OC.buildQueryString(params);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.fileList.generatePreviewUrl = function (urlSpec) {
|
this.fileList.generatePreviewUrl = function (urlSpec) {
|
||||||
|
@ -240,6 +226,23 @@ OCA.Sharing.PublicApp = {
|
||||||
window.FileList = this.fileList;
|
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>(…)</strong>');
|
||||||
|
divHeight += 50;
|
||||||
|
}
|
||||||
|
if (divHeight > previewHeight) {
|
||||||
|
textDiv.height(previewHeight);
|
||||||
|
}
|
||||||
|
var watermark = $('<div/>').addClass('watermark');
|
||||||
|
watermark.text('SAMPLE');
|
||||||
|
watermark.appendTo('#imgframe');
|
||||||
|
},
|
||||||
|
|
||||||
_onDirectoryChanged: function (e) {
|
_onDirectoryChanged: function (e) {
|
||||||
OC.Util.History.pushState({
|
OC.Util.History.pushState({
|
||||||
// arghhhh, why is this not called "dir" !?
|
// arghhhh, why is this not called "dir" !?
|
||||||
|
|
Loading…
Reference in New Issue