From 8904a6dba6ead2cb93d3517b25c757f3ba7cdea8 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 4 Feb 2016 10:13:08 +0000 Subject: [PATCH] First commit of Evernote migration plugin Starts to address #2268 --- boot/boot.js | 1 + editions/tw5.com/tiddlywiki.info | 3 +- plugins/tiddlywiki/evernote/docs.tid | 4 ++ .../evernote/modules/enex-deserializer.js | 47 +++++++++++++++++++ plugins/tiddlywiki/evernote/plugin.info | 7 +++ plugins/tiddlywiki/evernote/readme.tid | 11 +++++ 6 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 plugins/tiddlywiki/evernote/docs.tid create mode 100644 plugins/tiddlywiki/evernote/modules/enex-deserializer.js create mode 100644 plugins/tiddlywiki/evernote/plugin.info create mode 100644 plugins/tiddlywiki/evernote/readme.tid diff --git a/boot/boot.js b/boot/boot.js index 9d47c9ba8..62b85cffc 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1835,6 +1835,7 @@ $tw.boot.startup = function(options) { $tw.utils.registerFileType("audio/mp3","base64",".mp3"); $tw.utils.registerFileType("audio/mp4","base64",[".mp4",".m4a"]); $tw.utils.registerFileType("text/x-markdown","utf8",[".md",".markdown"]); + $tw.utils.registerFileType("application/enex+xml","utf8",".enex"); // Create the wiki store for the app $tw.wiki = new $tw.Wiki(); // Install built in tiddler fields modules diff --git a/editions/tw5.com/tiddlywiki.info b/editions/tw5.com/tiddlywiki.info index 703bec3b9..1d6574311 100644 --- a/editions/tw5.com/tiddlywiki.info +++ b/editions/tw5.com/tiddlywiki.info @@ -4,7 +4,8 @@ "tiddlywiki/googleanalytics", "tiddlywiki/nodewebkitsaver", "tiddlywiki/browser-sniff", - "tiddlywiki/railroad" + "tiddlywiki/railroad", + "tiddlywiki/evernote" ], "themes": [ "tiddlywiki/vanilla", diff --git a/plugins/tiddlywiki/evernote/docs.tid b/plugins/tiddlywiki/evernote/docs.tid new file mode 100644 index 000000000..d3fd38334 --- /dev/null +++ b/plugins/tiddlywiki/evernote/docs.tid @@ -0,0 +1,4 @@ +title: $:/plugins/tiddlywiki/evernote/docs + +! Introduction + diff --git a/plugins/tiddlywiki/evernote/modules/enex-deserializer.js b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js new file mode 100644 index 000000000..ce880fdf9 --- /dev/null +++ b/plugins/tiddlywiki/evernote/modules/enex-deserializer.js @@ -0,0 +1,47 @@ +/*\ +title: $:/plugins/tiddlywiki/evernote/modules/enex-deserializer.js +type: application/javascript +module-type: tiddlerdeserializer + +ENEX file deserializer + +For details see: https://blog.evernote.com/tech/2013/08/08/evernote-export-format-enex/ + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +// DOMParser = require("$:/plugins/tiddlywiki/xmldom/dom-parser").DOMParser; + +/* +Parse an ENEX file into tiddlers +*/ +exports["application/enex+xml"] = function(text,fields) { + // Collect output tiddlers in an array + var results = []; + // Parse the XML document + var parser = new DOMParser(), + doc = parser.parseFromString(text,"application/xml"); + // Output a report tiddler with information about the import + var enex = doc.querySelector("en-export"); + results.push({ + title: "Evernote Import Report", + text: "Evernote file imported on " + enex.getAttribute("export-date") + " from " + enex.getAttribute("application") + " (" + enex.getAttribute("version") + ")" + }) + // Get all the "note" nodes + var noteNodes = doc.querySelectorAll("note"); + $tw.utils.each(noteNodes,function(noteNode) { + results.push({ + title: noteNode.querySelector("title").textContent, + type: "text/html", + text: noteNode.querySelector("content").textContent + }); + }); + // Return the output tiddlers + return results; +}; + +})(); diff --git a/plugins/tiddlywiki/evernote/plugin.info b/plugins/tiddlywiki/evernote/plugin.info new file mode 100644 index 000000000..baf35156e --- /dev/null +++ b/plugins/tiddlywiki/evernote/plugin.info @@ -0,0 +1,7 @@ +{ + "title": "$:/plugins/tiddlywiki/evernote", + "description": "Evernote migration tools", + "author": "JeremyRuston", + "core-version": ">=5.0.0", + "list": "readme docs" +} diff --git a/plugins/tiddlywiki/evernote/readme.tid b/plugins/tiddlywiki/evernote/readme.tid new file mode 100644 index 000000000..fd946fd52 --- /dev/null +++ b/plugins/tiddlywiki/evernote/readme.tid @@ -0,0 +1,11 @@ +title: $:/plugins/tiddlywiki/evernote/readme + +This plugin contains tool to assist migration of content from Evernote ENEX files. + +!! Instructions + +# Download or save your ENEX file from Evernote +# Rename the file to have an `.enex` extension +# Drag the file into the TiddlyWiki browser window +## Alternatively, click the "Import" button in the "Tools" sidebar tab +# Review and accept the converted tiddlers