From 1d35087f29d5d5c1f4ab5cc1d0d99bf4b15b5f7b Mon Sep 17 00:00:00 2001 From: Devin Weaver Date: Thu, 4 Feb 2016 18:31:24 -0500 Subject: [PATCH 1/3] Add additional fields support for evernote plugin Relates to Issue #2268 Add the additional field defined in the XML as properties to the result. This also appears to capture the 'author' field. --- plugins/tiddlywiki/evernote/modules/enex-deserializer.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js index ce880fdf9..698d532f8 100644 --- a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js +++ b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js @@ -34,11 +34,15 @@ exports["application/enex+xml"] = function(text,fields) { // Get all the "note" nodes var noteNodes = doc.querySelectorAll("note"); $tw.utils.each(noteNodes,function(noteNode) { - results.push({ + var result = { title: noteNode.querySelector("title").textContent, type: "text/html", text: noteNode.querySelector("content").textContent + }; + $tw.utils.each(noteNodes.querySelector("note-attributes").childNodes,function(attrNode) { + result[attrNode.tagName] = attrNode.textContent; }); + results.push(result); }); // Return the output tiddlers return results; From 4b70257aca4c54ccb43f588ffc8e293a663d97b5 Mon Sep 17 00:00:00 2001 From: Devin Weaver Date: Thu, 4 Feb 2016 18:37:45 -0500 Subject: [PATCH 2/3] Add evernote's additional resources as tiddlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relates to Issue #2268 Based in the [example XML][1] attachments are listed in the node. Since in TiddlyWiki these would be media tiddlers I add then one by one as separate tiddlers. There are some things that still need to happen. There should be a mime type check so we don't attempt to import media tha TiddlyWiki doesn't support. Also the example suggests the data is base64 encoded so I blindly use that for the text attribute. Should there be a `data:mediatyp;base64,…` prefix? [1]: https://gist.github.com/evernotegists/6116886 --- plugins/tiddlywiki/evernote/modules/enex-deserializer.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js index 698d532f8..6293905a1 100644 --- a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js +++ b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js @@ -43,6 +43,15 @@ exports["application/enex+xml"] = function(text,fields) { result[attrNode.tagName] = attrNode.textContent; }); results.push(result); + $tw.utils.each(noteNode.querySelectorAll("resources"),function(resourceNode) { + results.push({ + title: resourceNode.querySelector("resource-attributes>file-name").textContent, + type: resourceNode.querySelector("mime").textContent, + width: resourceNode.querySelector("width").textContent, + height: resourceNode.querySelector("height").textContent, + text: resourceNode.querySelector("data").textContent + }); + }); }); // Return the output tiddlers return results; From 4525a3d631ff187cee0cb2e8e3ffb19be4d50e59 Mon Sep 17 00:00:00 2001 From: Devin Weaver Date: Thu, 4 Feb 2016 19:24:46 -0500 Subject: [PATCH 3/3] Add tags support to evernote plugin Relates to Issue #2268 I tried to map over the list of tags but NodeLists are not arrays and so need to be converted. This looks ugly and probably should be abstracted to a function. Come to think of it should we have a `$tw.utils.map()` function? --- plugins/tiddlywiki/evernote/modules/enex-deserializer.js | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js index 6293905a1..494bbecb4 100644 --- a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js +++ b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js @@ -37,6 +37,7 @@ exports["application/enex+xml"] = function(text,fields) { var result = { title: noteNode.querySelector("title").textContent, type: "text/html", + tags: Array.prototype.slice.call(noteNode.querySelectorAll("tag")).map(function(tag) { return tag.textContent; }).join(","), text: noteNode.querySelector("content").textContent }; $tw.utils.each(noteNodes.querySelector("note-attributes").childNodes,function(attrNode) {