joplin 1.0.2 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09242aa0b4f46f7d69424cb3267766eff3178e5a1ab3bc229c2e47b496427db3'
4
- data.tar.gz: bea1752fa435abab2cb0477bc4565795343cdd50f962128439dee822ac5c29a2
3
+ metadata.gz: 473edf7525029f8e4dc7a27448d9759f62666e27de6b9aef66cf472b3400b8c0
4
+ data.tar.gz: b4a6869f141a74bd6a3133a74aa7788c451500152ef84c31c418159faffb9d02
5
5
  SHA512:
6
- metadata.gz: 72044c7c29a87bb27257c2cfcb4b04e5f9c06ed6679475b0e305bdba635176535fefcbdf3f27151c3d1498f7762700f0e8e9a3a1263731868963db1879047721
7
- data.tar.gz: e127bfaf4d7ffc2fb5c20a2d085a5d9eb21921f678976a853f9fcdb3e408696c3f4f29c0cc4db3427720d1d1f5b79d8fdb6be6667db4338fb150c12344d30c90
6
+ metadata.gz: 37ac89db9443e9b413495b059b8eafaf30672e4254932d912fa86822eace0a24cb5b08bdc977922872c840d6e0959427d907d5005d7988959500121fd9380d8a
7
+ data.tar.gz: f7574b5afa1f55f7d06e565eb3145d9804c0c1ea9e3ca6e039f69688c72963ae2cf1389e31ebab846978f870a3e16833793774f7131a82794887522139db1391
data/Gemfile.lock CHANGED
@@ -1,37 +1,42 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- joplin (1.0.1)
5
- http (~> 5.1.1)
6
- sqlite3 (~> 1.6.3)
7
- thor (~> 1.2.2)
4
+ joplin (1.2.0)
5
+ amazing_print
6
+ colorize (~> 1.1.0)
7
+ http (~> 6.0.3)
8
+ minitest (~> 6.0.0)
9
+ sqlite3 (~> 2.9.4)
10
+ thor (~> 1.5.0)
11
+ tty-markdown (~> 0.7.2)
8
12
 
9
13
  GEM
10
14
  remote: https://rubygems.org/
11
15
  specs:
12
- addressable (2.8.4)
13
- public_suffix (>= 2.0.2, < 6.0)
16
+ amazing_print (2.0.0)
17
+ colorize (1.1.0)
14
18
  diff-lcs (1.5.0)
15
19
  domain_name (0.5.20190701)
16
20
  unf (>= 0.0.5, < 1.0.0)
17
- ffi (1.15.5)
18
- ffi-compiler (1.0.1)
19
- ffi (>= 1.0.0)
20
- rake
21
- http (5.1.1)
22
- addressable (~> 2.8)
21
+ drb (2.2.3)
22
+ http (6.0.3)
23
23
  http-cookie (~> 1.0)
24
- http-form_data (~> 2.2)
25
- llhttp-ffi (~> 0.4.0)
24
+ llhttp (~> 0.6.1)
26
25
  http-cookie (1.0.5)
27
26
  domain_name (~> 0.5)
28
- http-form_data (2.3.0)
29
- llhttp-ffi (0.4.0)
30
- ffi-compiler (~> 1.0)
31
- rake (~> 13.0)
27
+ kramdown (2.5.2)
28
+ rexml (>= 3.4.4)
29
+ llhttp (0.6.1)
30
+ minitest (6.0.6)
31
+ drb (~> 2.0)
32
+ prism (~> 1.5)
32
33
  pandoc_binary (3.1.1)
33
- public_suffix (5.0.1)
34
+ pastel (0.8.0)
35
+ tty-color (~> 0.5)
36
+ prism (1.9.0)
34
37
  rake (13.0.6)
38
+ rexml (3.4.4)
39
+ rouge (4.7.0)
35
40
  rspec (3.12.0)
36
41
  rspec-core (~> 3.12.0)
37
42
  rspec-expectations (~> 3.12.0)
@@ -45,14 +50,31 @@ GEM
45
50
  diff-lcs (>= 1.2.0, < 2.0)
46
51
  rspec-support (~> 3.12.0)
47
52
  rspec-support (3.12.1)
48
- sqlite3 (1.6.3-arm64-darwin)
49
- thor (1.2.2)
53
+ sqlite3 (2.9.4-arm64-darwin)
54
+ strings (0.2.1)
55
+ strings-ansi (~> 0.2)
56
+ unicode-display_width (>= 1.5, < 3.0)
57
+ unicode_utils (~> 1.4)
58
+ strings-ansi (0.2.0)
59
+ thor (1.5.0)
60
+ tty-color (0.6.0)
61
+ tty-markdown (0.7.2)
62
+ kramdown (>= 1.16.2, < 3.0)
63
+ pastel (~> 0.8)
64
+ rouge (>= 3.14, < 5.0)
65
+ strings (~> 0.2.0)
66
+ tty-color (~> 0.5)
67
+ tty-screen (~> 0.8)
68
+ tty-screen (0.8.2)
50
69
  unf (0.1.4)
51
70
  unf_ext
52
71
  unf_ext (0.0.8.2)
72
+ unicode-display_width (2.6.0)
73
+ unicode_utils (1.4.0)
53
74
 
54
75
  PLATFORMS
55
76
  arm64-darwin-22
77
+ arm64-darwin-25
56
78
 
57
79
  DEPENDENCIES
58
80
  bundler (~> 2.0)
data/bin/joplin CHANGED
@@ -1,10 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ # REF: https://joplinapp.org/help/api/references/rest_api/
4
+
3
5
  $:.unshift File.expand_path('../lib', __dir__)
4
6
 
5
7
  require 'joplin'
6
8
  require 'thor'
7
9
  require 'yaml'
10
+ require 'amazing_print'
8
11
 
9
12
  DIVIDER = %(
10
13
 
@@ -49,6 +52,37 @@ class MyCLI < Thor
49
52
  note.write
50
53
  end
51
54
 
55
+ desc :resource, 'get resource for note'
56
+ long_desc 'get all the resources for note with id'
57
+ option :token
58
+ def resource(id)
59
+ begin
60
+ note = Joplin::Note.new(id:)
61
+ note.resources.each do |resource|
62
+ ap resource.parsed
63
+ end
64
+ rescue Joplin::Note::NotFound => e
65
+ puts e.message
66
+ end
67
+ end
68
+
69
+ desc :stats, 'statistics on joplin data'
70
+ long_desc 'Get some statistics on the joplin instance, the number of notebooks, notes'
71
+ option :token
72
+ def stats
73
+ notes_total = 0
74
+ notebooks = Joplin::Notebook.all
75
+ notebooks.each do |notebook|
76
+ notes_count = notebook.notes.size # Get the count of notes in the notebook
77
+ notes_total += notebook.notes.size
78
+ end
79
+ puts <<~HEREDOC
80
+ Token: #{token}
81
+ Notebooks: #{notebooks.size}
82
+ Notes: #{notes_total}
83
+ HEREDOC
84
+ end
85
+
52
86
  desc :nb2n, 'concate all notes in a notebook to one note. Possible PDF export'
53
87
  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.'
54
88
  option :token
@@ -96,7 +130,7 @@ class MyCLI < Thor
96
130
  `pandoc '#{note.title}.md' -o '../#{note.title}.epub' -t epub3 -f markdown+smart --title '#{note.title}' --toc --toc-depth=3 --metadata title='#{note.title}'`
97
131
  note.delete!
98
132
  FileUtils.cd '..'
99
- FileUtils.rm_rf note.title
133
+ # FileUtils.rm_rf note.title
100
134
  abort 'Omg. pandoc failed!' if $?.exitstatus != 0
101
135
  puts "OK. Done. Your book is #{note.title}.epub"
102
136
  end
@@ -125,7 +159,7 @@ class MyCLI < Thor
125
159
  end
126
160
  yml = extract_yaml_header_for_epub(note)
127
161
  new_note = Joplin::Note.new parent_id: note.parent_id
128
- new_note.title = yml ? yml['title'] : "built: #{note.title}"
162
+ new_note.title = yml ? title_from_yml(yml) : "built: #{note.title}"
129
163
  new_note.body = "#{Psych.dump yml}...\n" if yml
130
164
  new_note.body += notes.map { |n| "\# #{n.title}\n\n#{n.body}" }.join
131
165
  new_note.save!
@@ -134,6 +168,18 @@ class MyCLI < Thor
134
168
 
135
169
  private
136
170
 
171
+ # if using subtitle with pandoc it has a different format
172
+ # https://pandoc.org/MANUAL.html#epubs
173
+ def title_from_yml(yml)
174
+ if yml['title'].is_a? Array
175
+ yml['title'].each do |title|
176
+ return title['text'] if title['type'] == 'main'
177
+ end
178
+ end
179
+
180
+ yml['title']
181
+ end
182
+
137
183
  def extract_yaml_header_for_epub(note)
138
184
  yml = Psych.load note.body
139
185
  return nil unless yml.is_a? Hash
@@ -143,7 +189,7 @@ class MyCLI < Thor
143
189
 
144
190
  def token
145
191
  Joplin.token = Joplin.get_token || options[:token]
146
- return if Joplin.token
192
+ return Joplin.token if Joplin.token
147
193
 
148
194
  raise "Couldn't find token in local database and it wasn't passed as an option. You better check yourself!"
149
195
  end