diff --git a/db/migrations/0120__migrate_hideInAutocomplete_to_archived.sql b/db/migrations/0120__migrate_hideInAutocomplete_to_archived.sql new file mode 100644 index 000000000..f47c89b2a --- /dev/null +++ b/db/migrations/0120__migrate_hideInAutocomplete_to_archived.sql @@ -0,0 +1 @@ +UPDATE attributes SET name = 'archived' where name = 'hideInAutocomplete'; \ No newline at end of file diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 9f4586cd5..37f5737be 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -694,4 +694,8 @@ div[data-notify="container"] { #export-form .format-choice { padding-left: 40px; display: none; +} + +#export-form .form-check-label { + padding: 2px; } \ No newline at end of file diff --git a/src/services/app_info.js b/src/services/app_info.js index a39c27300..a238a1645 100644 --- a/src/services/app_info.js +++ b/src/services/app_info.js @@ -3,7 +3,7 @@ const build = require('./build'); const packageJson = require('../../package'); -const APP_DB_VERSION = 119; +const APP_DB_VERSION = 120; const SYNC_VERSION = 2; module.exports = { diff --git a/src/services/export/tar.js b/src/services/export/tar.js index 04ecae729..bba875b63 100644 --- a/src/services/export/tar.js +++ b/src/services/export/tar.js @@ -12,17 +12,24 @@ const TurndownService = require('turndown'); async function exportToTar(branch, format, res) { const turndownService = new TurndownService(); + // path -> number of occurences + const existingPaths = {}; + const pack = tar.pack(); const exportedNoteIds = []; const name = await exportNoteInner(branch, ''); - async function exportNoteInner(branch, directory) { + function getUniqueFilename(fileName) { + + } + + async function exportNoteInner(branch, directory, existingNames) { const note = await branch.getNote(); - const childFileName = directory + sanitize(note.title); + const baseFileName = directory + sanitize(note.title); if (exportedNoteIds.includes(note.noteId)) { - saveMetadataFile(childFileName, { + saveMetadataFile(baseFileName, { version: 1, clone: true, noteId: note.noteId, @@ -67,26 +74,27 @@ async function exportToTar(branch, format, res) { return; } - saveMetadataFile(childFileName, metadata); - saveDataFile(childFileName, note); + saveMetadataFile(baseFileName, metadata); + saveDataFile(baseFileName, note); exportedNoteIds.push(note.noteId); const childBranches = await note.getChildBranches(); if (childBranches.length > 0) { - saveDirectory(childFileName); + saveDirectory(baseFileName); } for (const childBranch of childBranches) { - await exportNoteInner(await childBranch.getNote(), childBranch, childFileName + "/"); + await exportNoteInner(childBranch, baseFileName + "/"); } - return childFileName; + return baseFileName; } function saveDataFile(childFileName, note) { let content = note.content; + let extension; if (note.type === 'text') { if (format === 'html') { @@ -94,15 +102,18 @@ async function exportToTar(branch, format, res) { } else if (format === 'markdown') { content = turndownService.turndown(note.content); + extension = 'md'; } else { throw new Error("Unknown format: " + format); } } - const extension = mimeTypes.extension(note.mime) - || getExceptionalExtension(note.mime) - || "dat"; + if (!extension) { + extension = mimeTypes.extension(note.mime) + || getExceptionalExtension(note.mime) + || "dat"; + } if (!childFileName.toLowerCase().endsWith(extension)) { childFileName += "." + extension; @@ -117,14 +128,14 @@ async function exportToTar(branch, format, res) { } } - function saveMetadataFile(childFileName, metadata) { + function saveMetadataFile(baseFileName, metadata) { const metadataJson = JSON.stringify(metadata, null, '\t'); - pack.entry({name: childFileName + ".meta", size: metadataJson.length}, metadataJson); + pack.entry({name: getUniqueFilename(baseFileName + ".meta"), size: metadataJson.length}, metadataJson); } - function saveDirectory(childFileName) { - pack.entry({name: childFileName, type: 'directory'}); + function saveDirectory(baseFileName) { + pack.entry({name: baseFileName, type: 'directory'}); } pack.finalize(); diff --git a/src/views/index.ejs b/src/views/index.ejs index c817f5c1d..3328e4e32 100644 --- a/src/views/index.ejs +++ b/src/views/index.ejs @@ -53,7 +53,7 @@ - +