notion_orbit 0.0.2 → 0.0.6
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.lock +27 -17
- data/README.md +15 -0
- data/lib/notion_orbit/interactions/note.rb +1 -1
- data/lib/notion_orbit/notion.rb +1 -1
- data/lib/notion_orbit/notion_objects/block.rb +6 -5
- data/lib/notion_orbit/notion_objects/blocks.rb +3 -2
- data/lib/notion_orbit/services/notion.rb +14 -8
- data/lib/notion_orbit/version.rb +1 -1
- data/notion_orbit.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b13f8e03cabd299637f51b37a16591c103c1cdcaf40eb8f257bb667f212e496d
|
|
4
|
+
data.tar.gz: 661f5550a59ea88b6c2a2ea78f812408f3731ef938af6b3323a3c510db9a9c5b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b5773cdef03ac5bee9c17f2687d2a1bdf8dc53de47367cc0688363dd55ae17f310b86c87e7edbcc4c016bfbafa69fc9725486f40fd1c6c3cd4915aa96e7dc0d8
|
|
7
|
+
data.tar.gz: 7acb70be2a090b3b586130f1a4c597c998a82da8a48deb5762494a6009d986469486aab60288e532ee413199dbfe226fc740e40d892683d2e08e171ffd473552
|
data/Gemfile.lock
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
notion_orbit (0.0.
|
|
4
|
+
notion_orbit (0.0.5)
|
|
5
5
|
dotenv
|
|
6
6
|
http (~> 4.4)
|
|
7
7
|
json (~> 2.5)
|
|
8
|
-
notion-ruby-client
|
|
8
|
+
notion-ruby-client (~> 0.0.8)
|
|
9
9
|
thor (~> 1.1)
|
|
10
10
|
zeitwerk (~> 2.4)
|
|
11
11
|
|
|
12
12
|
GEM
|
|
13
13
|
remote: https://rubygems.org/
|
|
14
14
|
specs:
|
|
15
|
-
addressable (2.
|
|
15
|
+
addressable (2.8.0)
|
|
16
16
|
public_suffix (>= 2.0.2, < 5.0)
|
|
17
17
|
ast (2.4.2)
|
|
18
18
|
byebug (11.1.3)
|
|
@@ -22,18 +22,28 @@ GEM
|
|
|
22
22
|
domain_name (0.5.20190701)
|
|
23
23
|
unf (>= 0.0.5, < 1.0.0)
|
|
24
24
|
dotenv (2.7.6)
|
|
25
|
-
faraday (1.
|
|
25
|
+
faraday (1.7.0)
|
|
26
|
+
faraday-em_http (~> 1.0)
|
|
27
|
+
faraday-em_synchrony (~> 1.0)
|
|
26
28
|
faraday-excon (~> 1.1)
|
|
29
|
+
faraday-httpclient (~> 1.0.1)
|
|
27
30
|
faraday-net_http (~> 1.0)
|
|
28
31
|
faraday-net_http_persistent (~> 1.1)
|
|
32
|
+
faraday-patron (~> 1.0)
|
|
33
|
+
faraday-rack (~> 1.0)
|
|
29
34
|
multipart-post (>= 1.2, < 3)
|
|
30
35
|
ruby2_keywords (>= 0.0.4)
|
|
36
|
+
faraday-em_http (1.0.0)
|
|
37
|
+
faraday-em_synchrony (1.0.0)
|
|
31
38
|
faraday-excon (1.1.0)
|
|
39
|
+
faraday-httpclient (1.0.1)
|
|
32
40
|
faraday-net_http (1.0.1)
|
|
33
|
-
faraday-net_http_persistent (1.
|
|
34
|
-
|
|
41
|
+
faraday-net_http_persistent (1.2.0)
|
|
42
|
+
faraday-patron (1.0.0)
|
|
43
|
+
faraday-rack (1.0.0)
|
|
44
|
+
faraday_middleware (1.1.0)
|
|
35
45
|
faraday (~> 1.0)
|
|
36
|
-
ffi (1.15.
|
|
46
|
+
ffi (1.15.3)
|
|
37
47
|
ffi-compiler (1.0.1)
|
|
38
48
|
ffi (>= 1.0.0)
|
|
39
49
|
rake
|
|
@@ -44,23 +54,23 @@ GEM
|
|
|
44
54
|
http-cookie (~> 1.0)
|
|
45
55
|
http-form_data (~> 2.2)
|
|
46
56
|
http-parser (~> 1.2.0)
|
|
47
|
-
http-cookie (1.0.
|
|
57
|
+
http-cookie (1.0.4)
|
|
48
58
|
domain_name (~> 0.5)
|
|
49
59
|
http-form_data (2.3.0)
|
|
50
60
|
http-parser (1.2.3)
|
|
51
61
|
ffi-compiler (>= 1.0, < 2.0)
|
|
52
62
|
json (2.5.1)
|
|
53
63
|
multipart-post (2.1.1)
|
|
54
|
-
notion-ruby-client (0.0.
|
|
64
|
+
notion-ruby-client (0.0.8)
|
|
55
65
|
faraday (>= 1.0)
|
|
56
66
|
faraday_middleware
|
|
57
67
|
hashie
|
|
58
68
|
parallel (1.20.1)
|
|
59
|
-
parser (3.0.
|
|
69
|
+
parser (3.0.2.0)
|
|
60
70
|
ast (~> 2.4.1)
|
|
61
71
|
public_suffix (4.0.6)
|
|
62
72
|
rainbow (3.0.0)
|
|
63
|
-
rake (13.0.
|
|
73
|
+
rake (13.0.6)
|
|
64
74
|
regexp_parser (2.1.1)
|
|
65
75
|
rexml (3.2.5)
|
|
66
76
|
rspec (3.10.0)
|
|
@@ -76,26 +86,26 @@ GEM
|
|
|
76
86
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
77
87
|
rspec-support (~> 3.10.0)
|
|
78
88
|
rspec-support (3.10.2)
|
|
79
|
-
rubocop (1.
|
|
89
|
+
rubocop (1.19.0)
|
|
80
90
|
parallel (~> 1.10)
|
|
81
91
|
parser (>= 3.0.0.0)
|
|
82
92
|
rainbow (>= 2.2.2, < 4.0)
|
|
83
93
|
regexp_parser (>= 1.8, < 3.0)
|
|
84
94
|
rexml
|
|
85
|
-
rubocop-ast (>= 1.
|
|
95
|
+
rubocop-ast (>= 1.9.1, < 2.0)
|
|
86
96
|
ruby-progressbar (~> 1.7)
|
|
87
97
|
unicode-display_width (>= 1.4.0, < 3.0)
|
|
88
|
-
rubocop-ast (1.
|
|
98
|
+
rubocop-ast (1.10.0)
|
|
89
99
|
parser (>= 3.0.1.1)
|
|
90
100
|
ruby-progressbar (1.11.0)
|
|
91
|
-
ruby2_keywords (0.0.
|
|
101
|
+
ruby2_keywords (0.0.5)
|
|
92
102
|
thor (1.1.0)
|
|
93
103
|
unf (0.1.4)
|
|
94
104
|
unf_ext
|
|
95
105
|
unf_ext (0.0.7.7)
|
|
96
106
|
unicode-display_width (2.0.0)
|
|
97
|
-
webmock (3.
|
|
98
|
-
addressable (>= 2.
|
|
107
|
+
webmock (3.14.0)
|
|
108
|
+
addressable (>= 2.8.0)
|
|
99
109
|
crack (>= 0.3.2)
|
|
100
110
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
101
111
|
zeitwerk (2.4.2)
|
data/README.md
CHANGED
|
@@ -79,6 +79,21 @@ Then, once those fields are set up, the method can be called as follows:
|
|
|
79
79
|
client.notes
|
|
80
80
|
```
|
|
81
81
|
|
|
82
|
+
#### Supported Notion Content Blocks and Types
|
|
83
|
+
|
|
84
|
+
This integration has built-in support to convert the following Notion content block and types into markdown and rendered in Orbit:
|
|
85
|
+
|
|
86
|
+
* Heading Level 1
|
|
87
|
+
* Heading Level 2
|
|
88
|
+
* Heading Level 3
|
|
89
|
+
* Numbered List
|
|
90
|
+
* Bulleted List
|
|
91
|
+
* Paragraph Block
|
|
92
|
+
* To-Do List
|
|
93
|
+
* Bold Font
|
|
94
|
+
* Italic Font
|
|
95
|
+
* Code Blocks
|
|
96
|
+
|
|
82
97
|
## CLI Usage
|
|
83
98
|
|
|
84
99
|
You can also use this package with the included CLI. To use the CLI pass in the required environment variables on the command line before invoking the CLI.
|
|
@@ -16,7 +16,7 @@ module NotionOrbit
|
|
|
16
16
|
|
|
17
17
|
def after_initialize!
|
|
18
18
|
orbit_service = NotionOrbit::Services::Orbit.new(orbit_workspace: @orbit_workspace, orbit_api_key: @orbit_api_key)
|
|
19
|
-
notion_service = NotionOrbit::Services::Notion.new(
|
|
19
|
+
notion_service = NotionOrbit::Services::Notion.new(notion_api_key: @notion_api_key)
|
|
20
20
|
|
|
21
21
|
orbit_service.send_note(
|
|
22
22
|
member_slug: @note[:member_slug],
|
data/lib/notion_orbit/notion.rb
CHANGED
|
@@ -11,7 +11,7 @@ module NotionOrbit
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def process_notes
|
|
14
|
-
notion_service = NotionOrbit::Services::Notion.new(
|
|
14
|
+
notion_service = NotionOrbit::Services::Notion.new(notion_api_key: @notion_api_key)
|
|
15
15
|
orbit_service = NotionOrbit::Services::Orbit.new(orbit_workspace: @orbit_workspace, orbit_api_key: @orbit_api_key)
|
|
16
16
|
|
|
17
17
|
notes = notion_service.notes(database_id: @notion_database_id)
|
|
@@ -2,7 +2,7 @@ module NotionOrbit
|
|
|
2
2
|
module NotionObjects
|
|
3
3
|
class Block
|
|
4
4
|
class << self
|
|
5
|
-
def new_from_raw_block(raw_block, indentation: 0)
|
|
5
|
+
def new_from_raw_block(raw_block, notion_api_key, indentation: 0)
|
|
6
6
|
klass = case raw_block.type
|
|
7
7
|
when 'bulleted_list_item'
|
|
8
8
|
NotionOrbit::NotionObjects::BlockTypes::BulletedListItem
|
|
@@ -21,16 +21,17 @@ module NotionOrbit
|
|
|
21
21
|
else
|
|
22
22
|
NotionOrbit::NotionObjects::BlockTypes::Unsupported
|
|
23
23
|
end
|
|
24
|
-
klass.new(raw_block, indentation)
|
|
24
|
+
klass.new(raw_block, notion_api_key, indentation)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def initialize(raw_block, indentation)
|
|
28
|
+
def initialize(raw_block, notion_api_key, indentation)
|
|
29
29
|
@raw_block = raw_block
|
|
30
30
|
@id = raw_block.id
|
|
31
31
|
@type = raw_block.type
|
|
32
32
|
@has_children = raw_block.has_children
|
|
33
33
|
@indentation = indentation
|
|
34
|
+
@notion_api_key = notion_api_key
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def to_markdown
|
|
@@ -41,7 +42,7 @@ module NotionOrbit
|
|
|
41
42
|
if @has_children
|
|
42
43
|
raw_children = notion_service.client.block_children(id: @id).results
|
|
43
44
|
children_indentation = indent_children? ? @indentation + 2 : @indentation
|
|
44
|
-
children_blocks = Blocks.new(raw_children, indentation: children_indentation)
|
|
45
|
+
children_blocks = Blocks.new(raw_children, @notion_api_key, indentation: children_indentation)
|
|
45
46
|
markdown += "\n\n" + children_blocks.to_markdown
|
|
46
47
|
end
|
|
47
48
|
|
|
@@ -53,7 +54,7 @@ module NotionOrbit
|
|
|
53
54
|
end
|
|
54
55
|
|
|
55
56
|
def notion_service
|
|
56
|
-
@notion_service ||= NotionOrbit::Services::Notion.new
|
|
57
|
+
@notion_service ||= NotionOrbit::Services::Notion.new(notion_api_key: @notion_api_key)
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
end
|
|
@@ -5,8 +5,9 @@ module NotionOrbit
|
|
|
5
5
|
|
|
6
6
|
attr_accessor :blocks
|
|
7
7
|
|
|
8
|
-
def initialize(raw_blocks, indentation: 0)
|
|
9
|
-
@blocks = raw_blocks.map{ |raw_block| Block.new_from_raw_block(raw_block, indentation: indentation) }
|
|
8
|
+
def initialize(raw_blocks, notion_api_key, indentation: 0)
|
|
9
|
+
@blocks = raw_blocks.map{ |raw_block| Block.new_from_raw_block(raw_block, notion_api_key, indentation: indentation) }
|
|
10
|
+
@notion_api_key = notion_api_key
|
|
10
11
|
@indentation = indentation
|
|
11
12
|
end
|
|
12
13
|
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
module NotionOrbit
|
|
2
2
|
module Services
|
|
3
3
|
class Notion
|
|
4
|
-
attr_reader :client, :
|
|
4
|
+
attr_reader :client, :notion_api_key
|
|
5
5
|
|
|
6
6
|
def initialize(params = {})
|
|
7
|
-
@client = ::Notion::Client.new(token: params
|
|
7
|
+
@client = ::Notion::Client.new(token: params[:notion_api_key])
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def notes(database_id:)
|
|
11
11
|
pages = @client.database_query(id: database_id).results
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
# only process pages that opt-in to sending the note to Orbit
|
|
14
|
-
pages = pages.filter { |page| page.properties['Send to Orbit'].checkbox }
|
|
14
|
+
pages = pages.filter { |page| page.properties['Send to Orbit'].checkbox && page[:properties]['Member Email'].email }
|
|
15
|
+
|
|
16
|
+
pages = pages.filter { |page| page.properties['Orbit Status'].rich_text[0] == nil }
|
|
15
17
|
puts pages
|
|
16
18
|
|
|
17
19
|
notes = []
|
|
@@ -43,14 +45,18 @@ module NotionOrbit
|
|
|
43
45
|
|
|
44
46
|
def page_content(page)
|
|
45
47
|
raw_blocks = @client.block_children(id: page.id).results
|
|
46
|
-
blocks = NotionOrbit::NotionObjects::Blocks.new(raw_blocks)
|
|
48
|
+
blocks = NotionOrbit::NotionObjects::Blocks.new(raw_blocks, @client.token)
|
|
47
49
|
content = blocks.to_markdown
|
|
50
|
+
note_title = page[:properties]["Name"]["title"][0]["text"]["content"] || "Untitled Note"
|
|
48
51
|
content += "\\n\\n"
|
|
49
|
-
content += "[Open in Notion](#{page_url(page[:id])})"
|
|
52
|
+
content += "[Open in Notion](#{page_url(page[:id], note_title)})"
|
|
50
53
|
end
|
|
51
54
|
|
|
52
|
-
def page_url(page_id)
|
|
53
|
-
|
|
55
|
+
def page_url(page_id, page_title)
|
|
56
|
+
page_title&.strip.gsub!(" ", "-")
|
|
57
|
+
page_id&.gsub!("-", "")
|
|
58
|
+
|
|
59
|
+
"https://notion.so/#{ENV['NOTION_WORKSPACE_SLUG']}/#{page_title}-#{page_id}"
|
|
54
60
|
end
|
|
55
61
|
end
|
|
56
62
|
end
|
data/lib/notion_orbit/version.rb
CHANGED
data/notion_orbit.gemspec
CHANGED
|
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
|
32
32
|
spec.add_dependency "http", "~> 4.4"
|
|
33
33
|
spec.add_dependency "json", "~> 2.5"
|
|
34
34
|
spec.add_dependency "zeitwerk", "~> 2.4"
|
|
35
|
-
spec.add_dependency "notion-ruby-client"
|
|
35
|
+
spec.add_dependency "notion-ruby-client", "~> 0.0.8"
|
|
36
36
|
spec.add_dependency "thor", "~> 1.1"
|
|
37
37
|
spec.add_dependency "dotenv"
|
|
38
38
|
spec.add_development_dependency "rspec", "~> 3.4"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: notion_orbit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Orbit DevRel
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2021-
|
|
13
|
+
date: 2021-08-16 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: http
|
|
@@ -58,16 +58,16 @@ dependencies:
|
|
|
58
58
|
name: notion-ruby-client
|
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
|
60
60
|
requirements:
|
|
61
|
-
- - "
|
|
61
|
+
- - "~>"
|
|
62
62
|
- !ruby/object:Gem::Version
|
|
63
|
-
version:
|
|
63
|
+
version: 0.0.8
|
|
64
64
|
type: :runtime
|
|
65
65
|
prerelease: false
|
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
|
67
67
|
requirements:
|
|
68
|
-
- - "
|
|
68
|
+
- - "~>"
|
|
69
69
|
- !ruby/object:Gem::Version
|
|
70
|
-
version:
|
|
70
|
+
version: 0.0.8
|
|
71
71
|
- !ruby/object:Gem::Dependency
|
|
72
72
|
name: thor
|
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|