mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	generating simple frame based index page in html export
This commit is contained in:
		| @@ -281,7 +281,7 @@ ${content} | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     function saveNavigation(rootMeta) { |     function saveNavigation(rootMeta, navigationMeta) { | ||||||
|         function saveNavigationInner(meta) { |         function saveNavigationInner(meta) { | ||||||
|             let html = '<li>'; |             let html = '<li>'; | ||||||
|  |  | ||||||
| @@ -290,7 +290,7 @@ ${content} | |||||||
|             if (meta.dataFileName) { |             if (meta.dataFileName) { | ||||||
|                 const targetUrl = getTargetUrl(meta.noteId, rootMeta); |                 const targetUrl = getTargetUrl(meta.noteId, rootMeta); | ||||||
|  |  | ||||||
|                 html += `<a href="${targetUrl}">${escapedTitle}</a>`; |                 html += `<a href="${targetUrl}" target="detail">${escapedTitle}</a>`; | ||||||
|             } |             } | ||||||
|             else { |             else { | ||||||
|                 html += escapedTitle; |                 html += escapedTitle; | ||||||
| @@ -315,22 +315,64 @@ ${content} | |||||||
|         pack.entry({name: navigationMeta.dataFileName, size: prettyHtml.length}, prettyHtml); |         pack.entry({name: navigationMeta.dataFileName, size: prettyHtml.length}, prettyHtml); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     const rootMeta = await getNoteMeta(branch, { notePath: [] }, ['navigation']); |     function saveIndex(rootMeta, indexMeta) { | ||||||
|  |         let firstNonEmptyNote; | ||||||
|  |         let curMeta = rootMeta; | ||||||
|  |  | ||||||
|     const navigationMeta = { |         while (!firstNonEmptyNote) { | ||||||
|         noImport: true, |             if (curMeta.dataFileName) { | ||||||
|         dataFileName: "navigation." + (format === 'html' ? 'html' : 'md') |                 firstNonEmptyNote = getTargetUrl(curMeta.noteId, rootMeta); | ||||||
|     }; |             } | ||||||
|  |  | ||||||
|  |             if (curMeta.children && curMeta.children.length > 0) { | ||||||
|  |                 curMeta = curMeta.children[0]; | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 break; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         const fullHtml = `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||||||
|  | <html> | ||||||
|  | <head> | ||||||
|  |     <meta charset="utf-8"> | ||||||
|  | </head> | ||||||
|  | <frameset cols="25%,75%"> | ||||||
|  |     <frame name="navigation" src="navigation.html"> | ||||||
|  |     <frame name="detail" src="${firstNonEmptyNote}"> | ||||||
|  | </frameset> | ||||||
|  | </html>`; | ||||||
|  |  | ||||||
|  |         pack.entry({name: indexMeta.dataFileName, size: fullHtml.length}, fullHtml); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     const existingFileNames = format === 'html' ? ['navigation', 'index'] : []; | ||||||
|  |     const rootMeta = await getNoteMeta(branch, { notePath: [] }, existingFileNames); | ||||||
|  |  | ||||||
|     const metaFile = { |     const metaFile = { | ||||||
|         formatVersion: 1, |         formatVersion: 1, | ||||||
|         appVersion: packageInfo.version, |         appVersion: packageInfo.version, | ||||||
|         files: [ |         files: [ rootMeta ] | ||||||
|             rootMeta, |  | ||||||
|             navigationMeta |  | ||||||
|         ] |  | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  |     let navigationMeta, indexMeta; | ||||||
|  |  | ||||||
|  |     if (format === 'html') { | ||||||
|  |         navigationMeta = { | ||||||
|  |             noImport: true, | ||||||
|  |             dataFileName: "navigation.html" | ||||||
|  |         }; | ||||||
|  |  | ||||||
|  |         metaFile.files.push(navigationMeta); | ||||||
|  |  | ||||||
|  |         indexMeta = { | ||||||
|  |             noImport: true, | ||||||
|  |             dataFileName: "index.html" | ||||||
|  |         }; | ||||||
|  |  | ||||||
|  |         metaFile.files.push(indexMeta); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     for (const noteMeta of Object.values(noteIdToMeta)) { |     for (const noteMeta of Object.values(noteIdToMeta)) { | ||||||
|         // filter out relations which are not inside this export |         // filter out relations which are not inside this export | ||||||
|         noteMeta.attributes = noteMeta.attributes.filter(attr => attr.type !== 'relation' || attr.value in noteIdToMeta); |         noteMeta.attributes = noteMeta.attributes.filter(attr => attr.type !== 'relation' || attr.value in noteIdToMeta); | ||||||
| @@ -347,7 +389,10 @@ ${content} | |||||||
|  |  | ||||||
|     await saveNote(rootMeta, ''); |     await saveNote(rootMeta, ''); | ||||||
|  |  | ||||||
|     await saveNavigation(rootMeta, navigationMeta); |     if (format === 'html') { | ||||||
|  |         saveNavigation(rootMeta, navigationMeta); | ||||||
|  |         saveIndex(rootMeta, indexMeta); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     pack.finalize(); |     pack.finalize(); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -233,6 +233,10 @@ async function importTar(taskContext, fileBuffer, importRootNote) { | |||||||
|     async function saveNote(filePath, content) { |     async function saveNote(filePath, content) { | ||||||
|         const {parentNoteMeta, noteMeta} = getMeta(filePath); |         const {parentNoteMeta, noteMeta} = getMeta(filePath); | ||||||
|  |  | ||||||
|  |         if (noteMeta && noteMeta.noImport) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         const noteId = getNoteId(noteMeta, filePath); |         const noteId = getNoteId(noteMeta, filePath); | ||||||
|         const parentNoteId = await getParentNoteId(filePath, parentNoteMeta); |         const parentNoteId = await getParentNoteId(filePath, parentNoteMeta); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user