joplin 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/bin/joplin +22 -0
- data/lib/joplin.rb +26 -0
- data/lib/joplin/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c47aee19cc5f53aea14432231fb49276a97b22a8c9c076fb333adc14ca5c5103
|
4
|
+
data.tar.gz: ade107e1875175fb080eaa33a6b69752eade65e97d51ab21d1fd9f5e496eb779
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03ab75b8e2704463fcdaf5ca91d94bb01ee0a84be655c81b73e139dba299d0368a3c0d878287c00f1f029df2e657fd7cf5b1d4fd36e864a4f493094e6d4b6ed8
|
7
|
+
data.tar.gz: 8175d47bac51209a1e04727daa32b7f43368d8d8c7506c5aadac7811b2046cb5910e391bca72302cd76b76e6d3db727a13a1e06fd75b5bef4ac102a3874517ce
|
data/README.md
CHANGED
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)
|
data/lib/joplin.rb
CHANGED
@@ -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
|
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.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-
|
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: []
|