mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	Merge branch 'stable'
This commit is contained in:
		| @@ -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 | ||||||
| }; | }; | ||||||
| @@ -76,12 +76,12 @@ function SetupModel() { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             // not using server.js because it loads too many dependencies |             // not using server.js because it loads too many dependencies | ||||||
|             $.post('/api/setup/new-document', { |             $.post('api/setup/new-document', { | ||||||
|                 username: username, |                 username: username, | ||||||
|                 password: password1, |                 password: password1, | ||||||
|                 theme: theme |                 theme: theme | ||||||
|             }).then(() => { |             }).then(() => { | ||||||
|                 window.location.replace("/"); |                 window.location.replace("./"); | ||||||
|             }); |             }); | ||||||
|         } |         } | ||||||
|         else if (this.setupType() === 'sync-from-server') { |         else if (this.setupType() === 'sync-from-server') { | ||||||
| @@ -128,10 +128,10 @@ function SetupModel() { | |||||||
| } | } | ||||||
|  |  | ||||||
| async function checkOutstandingSyncs() { | async function checkOutstandingSyncs() { | ||||||
|     const { stats, initialized } = await $.get('/api/sync/stats'); |     const { stats, initialized } = await $.get('api/sync/stats'); | ||||||
|  |  | ||||||
|     if (initialized) { |     if (initialized) { | ||||||
|         window.location.replace("/"); |         window.location.replace("./"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const totalOutstandingSyncs = stats.outstandingPushes + stats.outstandingPulls; |     const totalOutstandingSyncs = stats.outstandingPushes + stats.outstandingPulls; | ||||||
|   | |||||||
| @@ -138,7 +138,6 @@ | |||||||
| </div> | </div> | ||||||
|  |  | ||||||
| <script type="text/javascript"> | <script type="text/javascript"> | ||||||
|     const baseApiUrl = 'api/'; |  | ||||||
|     const glob = { |     const glob = { | ||||||
|         sourceId: '' |         sourceId: '' | ||||||
|     }; |     }; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user