Skip to content

Commit

Permalink
Added Readme & License
Browse files Browse the repository at this point in the history
Some minor code cleanup
  • Loading branch information
mgmart committed Mar 3, 2017
1 parent 4bc4790 commit a13e078
Show file tree
Hide file tree
Showing 7 changed files with 792 additions and 41 deletions.
675 changes: 675 additions & 0 deletions License.md

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions Readme.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
* EverOrg

[[./docs/images/Unicorn.png]]

** Objective
*** Migrate all content from Evernote to Org mode

Due to the limited mobile support of Org mode, I've constantly switched
between Org mode and a Evernote/Remember the Milk combination. As this
changes now due to the initiative of [[https://github.com/MobileOrg/mobileorg.next][MobileOrg v2]], it's time to migrate my
stuff fully over to Org mode.

One of the reasons of using Evernote was the possibility to export all
of my content into XML. This EverOrg uses the Evernote
backup-files to generate Org mode files.

** Features
EverOrg reads an [[http://xml.evernote.com/pub/evernote-export3.dtd][ENEX]] document and converts it's markup to Org mode
syntax. This could be done by using tools like [[http://pandoc.org][pandoc]]. But then all
the attachments like images, voice-memos, scanned documents and so
on would be missing from within org mode.

EverOrg reads in the file which is given as a parameter and
creates an Org file with the same name in the same location as the
source file. In this location also an directory with the same name
is created where all the attachments are stored.

[[./docs/images/directorypath.png]]

Every stored attachment is referenced from within the Org document,
either as an image which could be viewed inline or as an link so
that the attachment could be opened easily within n external application.

** Platform

The first version of EverOrg was developed in Swift on MacOS. The aim is
that EverOrg is platform in dependable so that Windows users would have had
at least the possibility to use it in a VM under Linux. Unfortunately Swift
under Linux does not work straightforward. I was not able to compile EverOrg
on Linux without strange errors. Due to that I decided to write it again
using Go which has extraordinary cross-compile possibilities.

** Status

*** Known Issues
- Web clips are not nicely displayed in Org
- tables have still some linebreaks in table cells
- Illegal characters in tags (for Org) are not filtered
- Reminders are not processed (Those are still in RTM for me)
- Note content is not formatted for the use within Org
mode. =fill-paragraph= (=M-q=) should do the job whilst
accessing the note in Org mode.

** Discussion

*** Properties
I do not know if there are already any existing keywords used for
the properties I've been using for EverOrg. But if there are,
those could be easily adopted.

** License

EverOrg is distributed under the GNU Public License
version 3. See [[https://github.com/mgmart/EverOrg/blob/master/License.md][License.md]] for more info

** Credits

Unicorn picture courtesy of [[https://pixabay.com/de/users/Lohrelei-1422286/][Lohrelei]]
12 changes: 8 additions & 4 deletions Resources/EverNoteExportTestData.enex
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
y<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE en-export SYSTEM "http://xml.evernote.com/pub/evernote-export3.dtd">
<en-export export-date="20170210T144250Z" application="Evernote" version="Evernote Mac 6.10 (454269)">
<en-export export-date="20170301T200032Z" application="Evernote" version="Evernote Mac 6.10 (454269)">
<note><title>Another Note</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note><div><i>Some</i> <u>text</u> …<span style="background-color: rgb(255, 250, 165);-evernote-highlight:true-evernote-highlight:true"> and marked text</span> and <b>more</b> text </div><div><hr/></div><div>What <i>shall <b>we</b> do</i> <i><u>with</u></i> the <b><u>drunken</u></b> sailor?</div><div><span style=""><en-todo checked="false"/>Shave his belly</span><br/></div><div><en-todo checked="true"/>Put him in a long boat<br/></div><div><en-todo checked="false"/>Stick him in a scupper<br/></div><div><en-todo checked="false"/>Put him in the bed<br/></div><div><hr/><br/></div><div><span style="">Nice image following:</span></div><div><span style=""><span style="font: 12.0px Helvetica"><en-media hash="8159e44d383f41a74e151cd4e60a5d8c" type="image/png"/><br/></span><br/></span><br/></div><div><br/></div></en-note>
]]></content><created>20170205T095851Z</created><updated>20170209T090230Z</updated><tag>tags</tag><tag>for</tag><tag>whimps</tag><tag>are</tag><note-attributes><latitude>50.6819156432199</latitude><longitude>7.145653387058315</longitude><altitude>91.68743133544922</altitude><author>Mario Martelli</author><source>desktop.mac</source><reminder-order>0</reminder-order></note-attributes><resource><data encoding="base64">iVBORw0KGgoAAAANSUhEUgAABTAAAAIiCAYAAAD/1Od8AAAAAXNSR0IArs4c6QAAAAlwSFlzAAAWJQAA
]]></content><created>20170205T095851Z</created><updated>20170209T090230Z</updated><tag>are</tag><tag>tags</tag><tag>for</tag><tag>whimps</tag><note-attributes><latitude>50.6819156432199</latitude><longitude>7.145653387058315</longitude><altitude>91.68743133544922</altitude><author>Mario Martelli</author><source>desktop.mac</source><reminder-order>0</reminder-order></note-attributes><resource><data encoding="base64">iVBORw0KGgoAAAANSUhEUgAABTAAAAIiCAYAAAD/1Od8AAAAAXNSR0IArs4c6QAAAAlwSFlzAAAWJQAA
FiUBSVIk8AAAQABJREFUeAHsnQlcVsX6x3+vIqCACyigqIC5ACoKLologvuSWLlUZqW2XK2/pjclb1pX
y3ZLb3brpqVmarlkarlkuaa4hiIq4gYqKiCoICjLq+9/zn7Ou8C7AGI8xw++c2Z7Zr4zZ845z3lmRtcq
qJkBZo6Eo0dxO3k5hk1ezYcO/WgpXmhb2yhmHta8+hQWpTjBf9j7+GpsCAYOfMwoDhAcPRS92vujVg0u
Expand Down Expand Up @@ -8067,7 +8067,7 @@ FXs3ppceGRl5j2GYbyiKGpvvQE+aaBdLIu4suEzuiUX/AG3EJVuesFjhAAAAAElFTkSuQmCC</data><
<note><title>iPad memo</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note><div><en-media style="width: 160px; height: 120px;width: 160px; height: 120px;" hash="06822ba542d99ea1b84650fb2386dc15" type="audio/x-m4a" title="Attachment"/></div><div><font style="font-size: 24px;" color="#ff00ff">Violets are violet</font></div><div><font style="font-size: 24px;" color="#ff00ff"><br/></font></div><div><br/></div></en-note>
]]></content><created>20170205T103241Z</created><updated>20170205T103706Z</updated><tag>Moving Needles</tag><note-attributes><latitude>50.81677829046718</latitude><longitude>-0.1368387520087787</longitude><altitude>0</altitude><source>mobile.ipad</source><reminder-order>1486291079000</reminder-order><reminder-done-time>20170205T103809Z</reminder-done-time><application-data key="rememberthemilkinc">task_id=536153741</application-data></note-attributes><resource><data encoding="base64">AAAAHGZ0eXBNNEEgAAAAAE00QSBtcDQyaXNvbQAABtFtb292AAAAbG12aGQAAAAA1Lyv1NS8r9QAAKxE
]]></content><created>20170205T103241Z</created><updated>20170217T051026Z</updated><tag>Moving Needles</tag><note-attributes><latitude>50.81677829046718</latitude><longitude>-0.1368387520087787</longitude><altitude>0</altitude><source>mobile.ipad</source><reminder-order>1486291079000</reminder-order><reminder-done-time>20170205T103809Z</reminder-done-time><application-data key="rememberthemilkinc">task_id=536153741</application-data></note-attributes><resource><data encoding="base64">AAAAHGZ0eXBNNEEgAAAAAE00QSBtcDQyaXNvbQAABtFtb292AAAAbG12aGQAAAAA1Lyv1NS8r9QAAKxE
AARsAAABAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAGXXRyYWsAAABcdGtoZAAAAAHUvK/U1Lyv1AAAAAEAAAAA
AARsAAAAAAAAAAAAAAAAAAEAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAEAAAAAAAAAA
Expand Down Expand Up @@ -210647,4 +210647,8 @@ NTI2CiUlRU9GCg==</data><mime>application/pdf</mime><width>0</width><height>0</he
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note><div>This is a table</div><div><br/></div><div/><div><table style="width: 100%; border-collapse: collapse; table-layout: fixed;"><tbody><tr><td style="width: 33.333333333333336%; border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px; background-color: rgb(100, 178, 223);"><div><br/></div></td><td style="width: 33.333333333333336%; border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px; background-color: rgb(100, 178, 223);"><div>Evernote</div></td><td style="width: 33.333333333333336%; border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px; background-color: rgb(100, 178, 223);"><div>Org mode</div></td></tr><tr><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px; background-color: rgb(255, 179, 0);">Images</td><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px;"><div>Inline</div></td><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px;"><div>Inline</div></td></tr><tr><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px; background-color: rgb(255, 179, 0);"><div>Attachments</div></td><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px;"><div>Inline</div></td><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px;">attached</td></tr><tr><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px; background-color: rgb(255, 179, 0);">HTML</td><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px;"><div>Inline</div></td><td style="border: 1px solid rgb(219, 219, 219); padding: 10px; margin: 0px;"><div>as export properties</div></td></tr></tbody></table></div><div><br/></div><div>Now some more text</div><div><br/></div></en-note>
]]></content><created>20170210T143701Z</created><updated>20170210T144224Z</updated><note-attributes><latitude>50.68191920285813</latitude><longitude>7.145656853476992</longitude><altitude>91.58805084228516</altitude><author>Mario Martelli</author><source>desktop.mac</source><reminder-order>0</reminder-order></note-attributes></note>
<note><title>Lists</title><content><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE en-note SYSTEM "http://xml.evernote.com/pub/enml2.dtd">
<en-note><div>Ordered List</div><div><br/></div><div><ul><li>First Item,</li><ul><li>subitem</li><ul><li>subsubitem</li></ul></ul><li>Second Item</li><ol><li>Numbers Sub</li><li>Numgered Sub</li></ol><li>Third Item</li></ul><div><br/></div></div><div>Numbered List</div><div><br/></div><div/><div><ol><li style="">First Item,</li><ul><li style="">subitem</li><li style="">subitem</li></ul><li style="">Second Item</li><ol><li style="">Numbered Sub</li><li style="">Numbered Sub</li></ol><li style="">Third Item</li></ol><div><br/></div></div><div><br/></div><div><br/></div></en-note>
]]></content><created>20170301T185453Z</created><updated>20170301T200012Z</updated><note-attributes><latitude>50.68192057737947</latitude><longitude>7.145666413541147</longitude><altitude>91.40106964111328</altitude><author>Mario Martelli</author><source>desktop.mac</source><reminder-order>0</reminder-order></note-attributes></note>
</en-export>
Binary file added docs/images/Unicorn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/directorypath.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 13 additions & 1 deletion evernote.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,23 @@

package main

import "golang.org/x/net/html"

//
// Data Structures
//

type Query struct {
Notes []Note `xml:"note"`
}

type Node struct {
Token html.Token
Text string
}

type Nodes []Node

type Note struct {
Title string `xml:"title"`
Content string `xml:"content"`
Expand All @@ -48,7 +61,6 @@ type Note struct {
Encoding string `xml:"encoding,attr"`
} `xml:"data"`
} `xml:"resource"`
// Keywords map[string]bool
}

type Content struct {
Expand Down
64 changes: 28 additions & 36 deletions everorg.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,12 @@ import (
"golang.org/x/net/html"
)

// Globals for filehandling
var readFile = ""
var attFolderExt = "-Attachments"
var attachmentPath = ""

func (s Note) String() string {
return fmt.Sprintf("-> %s - %f\n", s.Title, s.Attributes.Latitude)
}

type Node struct {
Token html.Token
Text string
}

type Nodes []Node

// Get Attributes for html tag
func getAttr(attribute string, token html.Token) string {
for _, attr := range token.Attr {
if attr.Key == attribute {
Expand All @@ -65,6 +56,23 @@ func getAttr(attribute string, token html.Token) string {
return ""
}

func mimeFiles(token html.Token) (string, string) {

mimeType := getAttr("type", token)
ext, err := mime.ExtensionsByType(mimeType)
if err == nil {
fileExt := ""
if len(ext) > 0 {
fileExt = ext[0]
} else {
fileExt = ".unknwn"
}
return filepath.Base(attachmentPath), getAttr("hash", token) + fileExt
}
return "", ""
}

// Org mode represantation of Node
func (nodes Nodes) orgFormat() string {

value := ""
Expand All @@ -79,18 +87,10 @@ func (nodes Nodes) orgFormat() string {
case html.SelfClosingTagToken:
switch node.Token.Data {
case "en-media":
mimeType := getAttr("type", node.Token)
ext, err := mime.ExtensionsByType(mimeType)
if err == nil {
fileExt := ""
if len(ext) > 0 {
fileExt = ext[0]
} else {
fileExt = ".unknwn"
}
value += "[[./" + filepath.Base(attachmentPath) + "/"
value += getAttr("hash", node.Token) + fileExt + "]]"
}
base, file := mimeFiles(node.Token)
value += "[[./" + base + "/"
value += file + "]]"

case "en-todo":

switch getAttr("checked", node.Token) {
Expand All @@ -104,6 +104,7 @@ func (nodes Nodes) orgFormat() string {
switch node.Token.Data {

case "a":
// We do not want links in the header
if header == 0 {
value += "[[" + getAttr("href", node.Token) + "]["
}
Expand Down Expand Up @@ -136,6 +137,7 @@ func (nodes Nodes) orgFormat() string {
value += "\n******* "
header += 1

// These tags are ignored
case "div", "span", "tr", "tbody", "abbr", "th", "thead", "ins", "img":
break
case "sup", "small", "br", "dl", "dd", "dt", "font", "colgroup", "cite":
Expand All @@ -146,19 +148,9 @@ func (nodes Nodes) orgFormat() string {
case "hr":
value += "\n------\n"
case "en-media":
mimeType := getAttr("type", node.Token)
ext, err := mime.ExtensionsByType(mimeType)
if err == nil {
fileExt := ""
if len(ext) > 0 {
fileExt = ext[0]
} else {
fileExt = ".unknwn"
}
value += ("[[./" + filepath.Base(attachmentPath) + "/")
value += (getAttr("hash", node.Token) + fileExt + "]]")
}

base, file := mimeFiles(node.Token)
value += "[[./" + base + "/"
value += file + "]]"
case "table":
table += 1
case "td":
Expand Down

0 comments on commit a13e078

Please sign in to comment.