-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 838c6b7
Showing
4 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
notes.json | ||
standardified-notes.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright 2020 JamesGecko | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Simple to Standard | ||
|
||
Import your SimpleNote data into Standard Notes. | ||
|
||
The normal Standard Notes import process from SimpleNote has some issues. The title is duplicated in the first line of every imported note, directly under the title field. It doesn't convert tags but includes them inline at the bottom of each note. It also drops creation and modification dates. Here's a quick attempt at throwing together a better version. | ||
|
||
> ⚠ A word of caution: I don't know how to bulk delete notes short of deleting your account. You may want to try this out on an empty, unsynced account and make sure it's doing what you want if you're already an avid Standard Note user. | ||
> | ||
> It should go without saying that there's no warranty on this thing. Use at your own risk. I am not responsible for data loss. | ||
# How to | ||
0. Install Ruby. | ||
1. Open app.simplenote.com and sign in. | ||
2. Click the hamburger button in the top left corner of the site | ||
3. Click `Settings` at the bottom. | ||
4. Click the `Tools` tab. | ||
5. Click `Export Notes` and save `notes.zip`. | ||
6. Open `notes.zip`. Within the archive is a folder named `source` containing `notes.json`. | ||
7. Put `notes.json` in the same directory as this script. | ||
8. Open a terminal and `cd` to the script directory. | ||
9. Run `ruby simple-to-standard.rb` | ||
10. The script will generate `standardified-notes.json`. | ||
11. Open app.standardnotes.org. | ||
12. Click `Account` in the bottom left corner. | ||
12. Click the `Decrypted` radio button. | ||
13. Click `Import Backup`. | ||
14. Be patient. Standard Notes may be unresponsive for a few dozen seconds if you've imported a decade worth of notes. | ||
15. Enjoy! | ||
|
||
The import does not include trashed notes. It will also totally import empty notes, so don't freak out if you see that. 😊 | ||
|
||
My personal instance of Standard Notes currently shows a count of 1087 next to "All notes", 1088 next to the "2020-09-22-import" tag this script generates, and 1106/1106 next to "notes and tags encrypted," so that's another thing to watch out for. Counting is hard. Maybe it's fine! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
require 'securerandom' | ||
require 'json' | ||
require 'date' | ||
|
||
class Note | ||
attr_reader :uuid, :tags | ||
|
||
def initialize(note_json) | ||
# puts note_json["id"] # Uncomment to see what note we fail on. | ||
@uuid = SecureRandom.uuid | ||
@title, @body = split_title(note_json['content']) | ||
@tags = note_json["tags"] || [] | ||
@created_at = note_json["creationDate"] | ||
@updated_at = note_json["lastModified"] | ||
end | ||
|
||
def as_json | ||
{ | ||
created_at: @created_at, | ||
updated_at: @updated_at, | ||
uuid: @uuid, | ||
content_type: "Note", | ||
content: { | ||
title: @title, | ||
text: @body, | ||
references: [], | ||
appData: { | ||
'org.standardnotes.sn' => { | ||
client_updated_at: @updated_at | ||
} | ||
} | ||
} | ||
} | ||
end | ||
|
||
private | ||
|
||
def split_title(content) | ||
split = content.index("\r\n") | ||
if split | ||
title = content[0...split] | ||
body_split = if content[split...split + 4] == "\r\n\r\n" | ||
split + 4 | ||
else | ||
split + 2 | ||
end | ||
body = content[body_split..-1] | ||
return [title, body] | ||
else | ||
[content, ''] | ||
end | ||
end | ||
end | ||
|
||
class Tag | ||
attr_reader :uuid | ||
|
||
def initialize(name) | ||
@uuid = SecureRandom.uuid | ||
@name = name | ||
@references = [] | ||
end | ||
|
||
def add_reference(note_uuid) | ||
@references << note_uuid | ||
end | ||
|
||
def as_json | ||
{ | ||
uuid: @uuid, | ||
content_type: 'Tag', | ||
content: { | ||
title: @name, | ||
references: @references.map do |ref| | ||
{ | ||
content_type: 'Note', | ||
uuid: ref | ||
} | ||
end | ||
} | ||
} | ||
end | ||
end | ||
|
||
class Tags | ||
def initialize | ||
@tags = {} | ||
import_tag_name = "#{Date.today.to_s}-import" | ||
@import_tag = Tag.new(import_tag_name) | ||
@tags[import_tag_name] = @import_tag | ||
end | ||
|
||
def from_note(note) | ||
@import_tag.add_reference(note.uuid) | ||
note.tags.each do |tag_name| | ||
@tags[tag_name] = Tag.new(tag_name) unless @tags[tag_name] | ||
@tags[tag_name].add_reference(note.uuid) | ||
end | ||
end | ||
|
||
def as_json | ||
@tags.values.map(&:as_json) | ||
end | ||
end | ||
|
||
def main | ||
tags = Tags.new | ||
notes = [] | ||
trashed_notes = [] | ||
|
||
import_json = JSON.parse(File.read('notes.json', encoding: 'UTF-8')) | ||
import_json["activeNotes"].each do |note_json| | ||
note = Note.new(note_json) | ||
tags.from_note(note) | ||
notes << note.as_json | ||
end | ||
# If you'd like to import deleted notes, take a look at export_json["trashedNotes"] | ||
|
||
output_json = JSON.pretty_generate({ | ||
items: tags.as_json + notes + trashed_notes | ||
}) | ||
File.write('standardified-notes.json', output_json, encoding: 'UTF-8') | ||
puts | ||
puts "standardified-notes.json generated with #{notes.count} notes." | ||
end | ||
|
||
main() if __FILE__ == $0 |