joplin 0.1.5 → 0.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: b66ce0b7ce1af8d1d0aa9d3d0a2a58f542a73a18945565b5ca1aa07bf44089ba
4
- data.tar.gz: 136bcec0934e2595f894d5c91485970b5329aefd01b8ecef1f0faf9058bfdcd1
3
+ metadata.gz: c47aee19cc5f53aea14432231fb49276a97b22a8c9c076fb333adc14ca5c5103
4
+ data.tar.gz: ade107e1875175fb080eaa33a6b69752eade65e97d51ab21d1fd9f5e496eb779
5
5
  SHA512:
6
- metadata.gz: a7dec3214bc22a44456ebfe16972fb8f7e26b20aeadef967d758c27177d2e002119346792b230e218ae2cdc284a52c30969b556291217ef8123df727968c3b4d
7
- data.tar.gz: 2cac9116cd1b872f240c816f59d69ff8a0501d36fd0b53b84b8790349406cb919aee408d749ff19cb0d2c46d0141e922b99040526dbacff1d3311bcea2449db1
6
+ metadata.gz: 03ab75b8e2704463fcdaf5ca91d94bb01ee0a84be655c81b73e139dba299d0368a3c0d878287c00f1f029df2e657fd7cf5b1d4fd36e864a4f493094e6d4b6ed8
7
+ data.tar.gz: 8175d47bac51209a1e04727daa32b7f43368d8d8c7506c5aadac7811b2046cb5910e391bca72302cd76b76e6d3db727a13a1e06fd75b5bef4ac102a3874517ce
data/README.md CHANGED
@@ -24,3 +24,12 @@ updating a note
24
24
  note.save!
25
25
  end
26
26
  ```
27
+
28
+
29
+ ## CLI
30
+
31
+ ### joplin nb2n --token <yourtoken> 'notebook name'
32
+
33
+ Will take a notebook and concatenate all notes into one for easy export to PDF
34
+
35
+
data/bin/joplin CHANGED
@@ -28,6 +28,28 @@ class MyCLI < Thor
28
28
  def version
29
29
  puts Joplin::VERSION
30
30
  end
31
+
32
+ desc :nb2n, "concate all notes in a notebook to one note. Possible PDF export"
33
+ option :token, :required => true
34
+ option :type, :type => :string
35
+ def nb2n(query)
36
+ Joplin::token = options[:token]
37
+ results = Joplin.search(query, { type: 'folder' })
38
+ nb = results[0];
39
+ if not (nb and nb['title'] == query)
40
+ abort "notebook #{query} not found"
41
+ end
42
+
43
+ notebook = Joplin::Notebook.new nb['id']
44
+ notes = notebook.notes
45
+ new_note = Joplin::Note.new
46
+ new_note.title = query
47
+ divider = %Q(<svg height="8" width="100%"><g fill="none" stroke="black" stroke-width="4"><path stroke-dasharray="20,10,5,5,5,10" d="M0 4 l415 0" /></g></svg>)
48
+
49
+ new_note.body = notes.map { |n| "\# #{n.title}\n\n#{n.body}" }.join("\n#{divider}\n")
50
+ new_note.save!
51
+ puts "Saved: #{new_note.title} with id: #{new_note.id}"
52
+ end
31
53
  end
32
54
 
33
55
  MyCLI.start(ARGV)
@@ -10,6 +10,13 @@ module Joplin
10
10
  @@token = token
11
11
  end
12
12
 
13
+ def self.search(query, opts = {})
14
+ url = "#{Joplin::uri}/search/?query=#{query}&token=#{Joplin::token}&type=#{opts[:type]}"
15
+ res = Faraday.get url
16
+ parsed = JSON.parse res.body
17
+ return parsed
18
+ end
19
+
13
20
  def self.token
14
21
  @@token
15
22
  end
@@ -136,4 +143,23 @@ body: #{self.body}"""
136
143
  @id = note["id"]
137
144
  end
138
145
  end
146
+
147
+ class Notebook
148
+ def initialize(id=nil)
149
+
150
+ @id = id
151
+ if id
152
+ url = "#{Joplin::uri}/folders/#{id}?token=#{Joplin::token}"
153
+ res = Faraday.get url
154
+ parsed = JSON.parse res.body
155
+ end
156
+ end
157
+
158
+ def notes
159
+ url = "#{Joplin::uri}/folders/#{@id}/notes?token=#{Joplin::token}"
160
+ res = Faraday.get url
161
+ notes = JSON.parse res.body
162
+ notes.map! { |n| Joplin::Note.new n['id'] }
163
+ end
164
+ end
139
165
  end
@@ -1,3 +1,3 @@
1
1
  module Joplin
2
- VERSION = "0.1.5"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Bretoi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-04 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -110,7 +110,7 @@ metadata:
110
110
  homepage_uri: http://github.com/danielb2/joplin
111
111
  source_code_uri: http://github.com/danielb2/joplin
112
112
  changelog_uri: http://github.com/danielb2/joplin
113
- post_install_message:
113
+ post_install_message:
114
114
  rdoc_options: []
115
115
  require_paths:
116
116
  - lib
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubygems_version: 3.0.3
129
- signing_key:
129
+ signing_key:
130
130
  specification_version: 4
131
131
  summary: joplin API
132
132
  test_files: []