mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
download fixes for the sub-domain web deployment
This commit is contained in:
parent
a16aaf7a81
commit
cfb850acb2
@ -74,7 +74,7 @@ $form.on('submit', () => {
|
|||||||
function exportBranch(branchId, type, format, version) {
|
function exportBranch(branchId, type, format, version) {
|
||||||
taskId = utils.randomString(10);
|
taskId = utils.randomString(10);
|
||||||
|
|
||||||
const url = utils.getHost() + `/api/notes/${branchId}/export/${type}/${format}/${version}/${taskId}`;
|
const url = utils.getUrlForDownload(`api/notes/${branchId}/export/${type}/${format}/${version}/${taskId}`);
|
||||||
|
|
||||||
utils.download(url);
|
utils.download(url);
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,9 @@ async function setContentPane() {
|
|||||||
const $downloadButton = $('<button class="btn btn-sm btn-primary" type="button">Download</button>');
|
const $downloadButton = $('<button class="btn btn-sm btn-primary" type="button">Download</button>');
|
||||||
|
|
||||||
$downloadButton.on('click', () => {
|
$downloadButton.on('click', () => {
|
||||||
utils.download(utils.getHost() + `/api/notes/${revisionItem.noteId}/revisions/${revisionItem.noteRevisionId}/download`);
|
const url = utils.getUrlForDownload(`api/notes/${revisionItem.noteId}/revisions/${revisionItem.noteRevisionId}/download`);
|
||||||
|
|
||||||
|
utils.download(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
$titleButtons.append($downloadButton);
|
$titleButtons.append($downloadButton);
|
||||||
|
@ -185,8 +185,7 @@ class NoteDetailBook {
|
|||||||
}
|
}
|
||||||
else if (type === 'file') {
|
else if (type === 'file') {
|
||||||
function getFileUrl() {
|
function getFileUrl() {
|
||||||
// electron needs absolute URL so we extract current host, port, protocol
|
return utils.getUrlForDownload("api/notes/" + note.noteId + "/download");
|
||||||
return utils.getHost() + "/api/notes/" + note.noteId + "/download";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const $downloadButton = $('<button class="file-download btn btn-primary" type="button">Download</button>');
|
const $downloadButton = $('<button class="file-download btn btn-primary" type="button">Download</button>');
|
||||||
|
@ -87,8 +87,7 @@ class NoteDetailFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFileUrl() {
|
getFileUrl() {
|
||||||
// electron needs absolute URL so we extract current host, port, protocol
|
return utils.getUrlForDownload("api/notes/" + this.ctx.note.noteId + "/download");
|
||||||
return utils.getHost() + "/api/notes/" + this.ctx.note.noteId + "/download";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {}
|
show() {}
|
||||||
|
@ -98,8 +98,7 @@ class NoteDetailImage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getFileUrl() {
|
getFileUrl() {
|
||||||
// electron needs absolute URL so we extract current host, port, protocol
|
return utils.getUrlForDownload(`api/notes/${this.ctx.note.noteId}/download`);
|
||||||
return utils.getHost() + `/api/notes/${this.ctx.note.noteId}/download`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
show() {}
|
show() {}
|
||||||
|
@ -214,6 +214,20 @@ async function clearBrowserCache() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param url - should be without initial slash!!!
|
||||||
|
*/
|
||||||
|
function getUrlForDownload(url) {
|
||||||
|
if (isElectron()) {
|
||||||
|
// electron needs absolute URL so we extract current host, port, protocol
|
||||||
|
return getHost() + '/' + url;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// web server can be deployed on subdomain so we need to use relative path
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
reloadApp,
|
reloadApp,
|
||||||
parseDate,
|
parseDate,
|
||||||
@ -230,7 +244,6 @@ export default {
|
|||||||
escapeHtml,
|
escapeHtml,
|
||||||
stopWatch,
|
stopWatch,
|
||||||
formatLabel,
|
formatLabel,
|
||||||
getHost,
|
|
||||||
download,
|
download,
|
||||||
toObject,
|
toObject,
|
||||||
randomString,
|
randomString,
|
||||||
@ -245,5 +258,6 @@ export default {
|
|||||||
getMimeTypeClass,
|
getMimeTypeClass,
|
||||||
closeActiveDialog,
|
closeActiveDialog,
|
||||||
isHtmlEmpty,
|
isHtmlEmpty,
|
||||||
clearBrowserCache
|
clearBrowserCache,
|
||||||
|
getUrlForDownload
|
||||||
};
|
};
|
Loading…
x
Reference in New Issue
Block a user