joplin 0.2.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +3 -1
- data/Makefile +4 -1
- data/README.md +12 -2
- data/bin/joplin +48 -14
- data/lib/joplin.rb +3 -1
- data/lib/joplin/token.rb +14 -0
- data/lib/joplin/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fada7c3ac2927ba5715b67437eac2fa1df0a33a24596e7a8619beadcabe27d2
|
4
|
+
data.tar.gz: 694472244aad50df5c84395b647b40840e8aff6eafe76903ccd667806aeed50e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d006b40cf72590d3c193cd71bf918044f06d4c379447d492c869b3c6533aaa0835196e7219d5ca9e483707206e7c739849d39a925d06542b2ced1dfdb742d77
|
7
|
+
data.tar.gz: ffd27223a512c4538bb5e9156ad1ef1825a5f0123afc45907c2eeba4be719cd7ae0a596b2c638147cec3e76fe1a7cba0390321bcaeb93e5da3b07bade3bdf2a3
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
joplin (0.
|
4
|
+
joplin (0.2.2)
|
5
5
|
faraday (~> 1.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -25,6 +25,7 @@ GEM
|
|
25
25
|
diff-lcs (>= 1.2.0, < 2.0)
|
26
26
|
rspec-support (~> 3.9.0)
|
27
27
|
rspec-support (3.9.3)
|
28
|
+
sqlite3 (1.4.2)
|
28
29
|
thor (1.0.1)
|
29
30
|
|
30
31
|
PLATFORMS
|
@@ -36,6 +37,7 @@ DEPENDENCIES
|
|
36
37
|
joplin!
|
37
38
|
rake (~> 13.0)
|
38
39
|
rspec (~> 3.0)
|
40
|
+
sqlite3 (~> 1.4)
|
39
41
|
thor (~> 1.0)
|
40
42
|
|
41
43
|
BUNDLED WITH
|
data/Makefile
CHANGED
data/README.md
CHANGED
@@ -22,9 +22,19 @@ updating a note
|
|
22
22
|
note = Joplin::Notes.new "6e3811c7a73148a" # note id can be found in the information of any note
|
23
23
|
note.title = "a new note title"
|
24
24
|
note.save!
|
25
|
-
end
|
26
25
|
```
|
27
26
|
|
27
|
+
### A note on the token
|
28
|
+
|
29
|
+
If you've got joplin installed, you can do:
|
30
|
+
|
31
|
+
``` ruby
|
32
|
+
require "joplin/token"
|
33
|
+
token = Joplin::Token.get
|
34
|
+
```
|
35
|
+
|
36
|
+
to get the token programatically. It reads from the sqlite database located in `~/.config/joplin-desktop`
|
37
|
+
|
28
38
|
|
29
39
|
## CLI
|
30
40
|
|
@@ -32,4 +42,4 @@ end
|
|
32
42
|
|
33
43
|
Will take a notebook and concatenate all notes into one for easy export to PDF
|
34
44
|
|
35
|
-
|
45
|
+
The token argument is optional and if you have it installed locally it will find the token
|
data/bin/joplin
CHANGED
@@ -4,6 +4,18 @@ $:.unshift File.expand_path("../../lib", __FILE__)
|
|
4
4
|
|
5
5
|
require "joplin"
|
6
6
|
require 'thor'
|
7
|
+
require "joplin/token"
|
8
|
+
|
9
|
+
DIVIDER = %Q(
|
10
|
+
|
11
|
+
<svg height="50" width="460">
|
12
|
+
<style> .line { stroke-width: 1px; fill: black; stroke: black; } </style>
|
13
|
+
<g id="triangle"><path d="M0 30 L200 30 Q 220 25 200 35 Z" class="line" /></g>
|
14
|
+
<use xlink:href="#triangle" transform="scale(-1 1) translate(-450 0)"/>
|
15
|
+
<circle cx="225" cy="32" r="7" class="line"/>
|
16
|
+
</svg>
|
17
|
+
|
18
|
+
)
|
7
19
|
|
8
20
|
|
9
21
|
class MyCLI < Thor
|
@@ -12,14 +24,16 @@ class MyCLI < Thor
|
|
12
24
|
class_option :version, :type => :boolean
|
13
25
|
map ["-v", "--version"] => :version
|
14
26
|
map ["-h", "--help"] => :help
|
15
|
-
option :token
|
27
|
+
option :token
|
16
28
|
option :'dry-run', desc: "dry-run", aliases: '-n'
|
17
29
|
desc :clean, "clean unused resources"
|
18
30
|
def clean
|
19
|
-
Joplin::token = options[:token]
|
31
|
+
Joplin::token = options[:token] || Joplin::Token.get
|
32
|
+
puts "Please wait, this can take while."
|
20
33
|
Joplin::Resource.orphaned.map { |r|
|
21
34
|
r.delete if not options['dry-run']
|
22
|
-
|
35
|
+
would = "would have " if options['dry-run']
|
36
|
+
puts "#{would}deleted #{r.id}"
|
23
37
|
}
|
24
38
|
end
|
25
39
|
|
@@ -30,10 +44,11 @@ class MyCLI < Thor
|
|
30
44
|
end
|
31
45
|
|
32
46
|
desc :nb2n, "concate all notes in a notebook to one note. Possible PDF export"
|
33
|
-
|
47
|
+
long_desc "The idea is to make a big note from all the notes in a notebook. PDF export or whatever export can happen from that. The notes are concatenated with a separator."
|
48
|
+
option :token
|
34
49
|
option :type, :type => :string
|
35
50
|
def nb2n(query)
|
36
|
-
Joplin::token = options[:token]
|
51
|
+
Joplin::token = options[:token] || Joplin::Token.get
|
37
52
|
results = Joplin.search(query, { type: 'folder' })
|
38
53
|
nb = results[0];
|
39
54
|
if not (nb and nb['title'] == query)
|
@@ -44,21 +59,40 @@ class MyCLI < Thor
|
|
44
59
|
notes = notebook.notes
|
45
60
|
new_note = Joplin::Note.new
|
46
61
|
new_note.title = query
|
47
|
-
|
62
|
+
new_note.body = notes.map { |n| "\# #{n.title}\n\n#{n.body}" }.join(DIVIDER)
|
63
|
+
new_note.save!
|
64
|
+
puts "Saved: #{new_note.title} with id: #{new_note.id}"
|
65
|
+
end
|
48
66
|
|
49
|
-
|
50
|
-
<style> .line { stroke-width: 1px; fill: black; stroke: black; } </style>
|
51
|
-
<g id="triangle"><path d="M0 30 L200 30 Q 220 25 200 35 Z" class="line" /></g>
|
52
|
-
<use xlink:href="#triangle" transform="scale(-1 1) translate(-450 0)"/>
|
53
|
-
<circle cx="225" cy="32" r="7" class="line"/>
|
54
|
-
</svg>
|
67
|
+
desc :build, "build a note from a note containing references"
|
55
68
|
|
56
|
-
|
69
|
+
long_desc %Q(Takes a note and looks up all the referenced notes and makes a new
|
70
|
+
note from those. The notes are concatenated with a separator.\n\nIf you have a
|
71
|
+
line with 'title: a title' then it will be used for the title of the built
|
72
|
+
email.)
|
57
73
|
|
58
|
-
|
74
|
+
def build(id)
|
75
|
+
token
|
76
|
+
note = Joplin::Note.new id
|
77
|
+
notes = []
|
78
|
+
title = nil
|
79
|
+
note.body.each_line { |line|
|
80
|
+
title = $1 if line =~ /title: (.*)$/
|
81
|
+
line =~ /\(:\/([^)]+)\)/
|
82
|
+
notes.push Joplin::Note.new $1 if $1
|
83
|
+
}
|
84
|
+
new_note = Joplin::Note.new
|
85
|
+
new_note.title = title || "built: #{note.title}"
|
86
|
+
new_note.body = notes.map { |n| "\# #{n.title}\n\n#{n.body}" }.join(DIVIDER)
|
59
87
|
new_note.save!
|
60
88
|
puts "Saved: #{new_note.title} with id: #{new_note.id}"
|
61
89
|
end
|
90
|
+
|
91
|
+
private
|
92
|
+
def token()
|
93
|
+
Joplin::token = options[:token] || Joplin::Token.get
|
94
|
+
raise "Couldn't find token in local database and it wasn't passed as an option. You better check yourself!" if not Joplin::token
|
95
|
+
end
|
62
96
|
end
|
63
97
|
|
64
98
|
MyCLI.start(ARGV)
|
data/lib/joplin.rb
CHANGED
@@ -133,7 +133,9 @@ body: #{self.body}"""
|
|
133
133
|
|
134
134
|
private
|
135
135
|
def parse response
|
136
|
-
|
136
|
+
if response.body.empty?
|
137
|
+
raise "No note found with id #{@id}"
|
138
|
+
end
|
137
139
|
note = JSON.parse response.body
|
138
140
|
if response.status != 200
|
139
141
|
raise Error.new note["error"]
|
data/lib/joplin/token.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "sqlite3"
|
2
|
+
module Joplin
|
3
|
+
module Token
|
4
|
+
def self.get
|
5
|
+
begin
|
6
|
+
db = SQLite3::Database.new "#{ENV['HOME']}/.config/joplin-desktop/database.sqlite"
|
7
|
+
rows = db.execute("select value from settings where key='api.token';")
|
8
|
+
return rows.flatten.first
|
9
|
+
rescue
|
10
|
+
return nil
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/joplin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joplin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Bretoi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -102,6 +102,7 @@ files:
|
|
102
102
|
- bin/setup
|
103
103
|
- joplin.gemspec
|
104
104
|
- lib/joplin.rb
|
105
|
+
- lib/joplin/token.rb
|
105
106
|
- lib/joplin/version.rb
|
106
107
|
homepage: http://github.com/danielb2/joplin
|
107
108
|
licenses:
|