mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	Merge branch 'stable'
This commit is contained in:
		| @@ -74,7 +74,7 @@ $form.on('submit', () => { | ||||
| function exportBranch(branchId, type, format, version) { | ||||
|     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); | ||||
| } | ||||
|   | ||||
| @@ -102,7 +102,9 @@ async function setContentPane() { | ||||
|     const $downloadButton = $('<button class="btn btn-sm btn-primary" type="button">Download</button>'); | ||||
|  | ||||
|     $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); | ||||
|   | ||||
| @@ -185,8 +185,7 @@ class NoteDetailBook { | ||||
|         } | ||||
|         else if (type === 'file') { | ||||
|             function getFileUrl() { | ||||
|                 // electron needs absolute URL so we extract current host, port, protocol | ||||
|                 return utils.getHost() + "/api/notes/" + note.noteId + "/download"; | ||||
|                 return utils.getUrlForDownload("api/notes/" + note.noteId + "/download"); | ||||
|             } | ||||
|  | ||||
|             const $downloadButton = $('<button class="file-download btn btn-primary" type="button">Download</button>'); | ||||
|   | ||||
| @@ -87,8 +87,7 @@ class NoteDetailFile { | ||||
|     } | ||||
|  | ||||
|     getFileUrl() { | ||||
|         // electron needs absolute URL so we extract current host, port, protocol | ||||
|         return utils.getHost() + "/api/notes/" + this.ctx.note.noteId + "/download"; | ||||
|         return utils.getUrlForDownload("api/notes/" + this.ctx.note.noteId + "/download"); | ||||
|     } | ||||
|  | ||||
|     show() {} | ||||
|   | ||||
| @@ -98,8 +98,7 @@ class NoteDetailImage { | ||||
|     } | ||||
|  | ||||
|     getFileUrl() { | ||||
|         // electron needs absolute URL so we extract current host, port, protocol | ||||
|         return utils.getHost() + `/api/notes/${this.ctx.note.noteId}/download`; | ||||
|         return utils.getUrlForDownload(`api/notes/${this.ctx.note.noteId}/download`); | ||||
|     } | ||||
|  | ||||
|     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 { | ||||
|     reloadApp, | ||||
|     parseDate, | ||||
| @@ -230,7 +244,6 @@ export default { | ||||
|     escapeHtml, | ||||
|     stopWatch, | ||||
|     formatLabel, | ||||
|     getHost, | ||||
|     download, | ||||
|     toObject, | ||||
|     randomString, | ||||
| @@ -245,5 +258,6 @@ export default { | ||||
|     getMimeTypeClass, | ||||
|     closeActiveDialog, | ||||
|     isHtmlEmpty, | ||||
|     clearBrowserCache | ||||
|     clearBrowserCache, | ||||
|     getUrlForDownload | ||||
| }; | ||||
| @@ -76,12 +76,12 @@ function SetupModel() { | ||||
|             } | ||||
|  | ||||
|             // not using server.js because it loads too many dependencies | ||||
|             $.post('/api/setup/new-document', { | ||||
|             $.post('api/setup/new-document', { | ||||
|                 username: username, | ||||
|                 password: password1, | ||||
|                 theme: theme | ||||
|             }).then(() => { | ||||
|                 window.location.replace("/"); | ||||
|                 window.location.replace("./"); | ||||
|             }); | ||||
|         } | ||||
|         else if (this.setupType() === 'sync-from-server') { | ||||
| @@ -128,10 +128,10 @@ function SetupModel() { | ||||
| } | ||||
|  | ||||
| async function checkOutstandingSyncs() { | ||||
|     const { stats, initialized } = await $.get('/api/sync/stats'); | ||||
|     const { stats, initialized } = await $.get('api/sync/stats'); | ||||
|  | ||||
|     if (initialized) { | ||||
|         window.location.replace("/"); | ||||
|         window.location.replace("./"); | ||||
|     } | ||||
|  | ||||
|     const totalOutstandingSyncs = stats.outstandingPushes + stats.outstandingPulls; | ||||
|   | ||||
| @@ -138,7 +138,6 @@ | ||||
| </div> | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|     const baseApiUrl = 'api/'; | ||||
|     const glob = { | ||||
|         sourceId: '' | ||||
|     }; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user