bridgetown_notion 0.1.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 +7 -0
- data/.gitignore +39 -0
- data/.rubocop.yml +22 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +11 -0
- data/bridgetown.automation.rb +44 -0
- data/bridgetown_notion.gemspec +26 -0
- data/lib/bridgetown_notion/builder.rb +79 -0
- data/lib/bridgetown_notion/version.rb +5 -0
- data/lib/bridgetown_notion.rb +5 -0
- metadata +136 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2e86e10243ccaea80727bc54084c1c071d407c49d4a7fac41a4c9aa5983321b7
|
4
|
+
data.tar.gz: 61973da5ac8daf87996a88d826d03be727255431c2e4ed8a5304047186ed5f92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6bb6f9beecc295140d9bc4edda7019891aeb50b77c151d7be34075adec1a36fd3b92924ae70f94bb1640eb81c4141397217d29e19e0768468ceb3c35686a3abe
|
7
|
+
data.tar.gz: e2416855fad78e9f31d437fa539ca9ac1e447cf89906147a773d5d5ba231b7ed56cbef71285a2f4404e6934a7021d6ca8b87a55dcda392366a537d62ed799a83
|
data/.gitignore
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
/vendor
|
2
|
+
/.bundle/
|
3
|
+
/.yardoc
|
4
|
+
/Gemfile.lock
|
5
|
+
/_yardoc/
|
6
|
+
/coverage/
|
7
|
+
/doc/
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/tmp/
|
11
|
+
*.bundle
|
12
|
+
*.so
|
13
|
+
*.o
|
14
|
+
*.a
|
15
|
+
mkmf.log
|
16
|
+
*.gem
|
17
|
+
Gemfile.lock
|
18
|
+
.bundle
|
19
|
+
.ruby-version
|
20
|
+
.tool-versions
|
21
|
+
|
22
|
+
# Node
|
23
|
+
node_modules
|
24
|
+
.npm
|
25
|
+
.node_repl_history
|
26
|
+
|
27
|
+
# Yarn
|
28
|
+
yarn-error.log
|
29
|
+
yarn-debug.log*
|
30
|
+
.pnp/
|
31
|
+
.pnp.js
|
32
|
+
|
33
|
+
# Yarn Integrity file
|
34
|
+
.yarn-integrity
|
35
|
+
|
36
|
+
test/dest
|
37
|
+
.bridgetown-metadata
|
38
|
+
.bridgetown-cache
|
39
|
+
.bridgetown-webpack
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require: rubocop-bridgetown
|
2
|
+
|
3
|
+
inherit_gem:
|
4
|
+
rubocop-bridgetown: .rubocop.yml
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
TargetRubyVersion: 2.5
|
8
|
+
|
9
|
+
Exclude:
|
10
|
+
- .gitignore
|
11
|
+
- .rubocop.yml
|
12
|
+
- "*.gemspec"
|
13
|
+
|
14
|
+
- Gemfile.lock
|
15
|
+
- CHANGELOG.md
|
16
|
+
- LICENSE.txt
|
17
|
+
- README.md
|
18
|
+
- Rakefile
|
19
|
+
- bridgetown.automation.rb
|
20
|
+
|
21
|
+
- script/**/*
|
22
|
+
- vendor/**/*
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Changelog for bridgetown_notion
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
-
|
11
|
+
|
12
|
+
## [0.1.0] - 2023-02-04
|
13
|
+
|
14
|
+
### Added
|
15
|
+
|
16
|
+
- Retrieved basic frontmatter from Notion.
|
17
|
+
- Retrieve headings, paragraphs and bullet list content from Notion.
|
18
|
+
- Created post resources based on the retrieved data.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020-present
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# Sample plugin for Bridgetown
|
2
|
+
|
3
|
+
_NOTE: This isn't a real plugin! Copy this sample code and use it to create your own Ruby gem! [Help guide here…](https://www.bridgetownrb.com/docs/plugins)_ 😃
|
4
|
+
|
5
|
+
_You can run_ `bridgetown plugins new` _to easily set up a customized verison of this starter repo._
|
6
|
+
|
7
|
+
A Bridgetown plugin to [fill in the blank]…
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Run this command to add this plugin to your site's Gemfile:
|
12
|
+
|
13
|
+
```shell
|
14
|
+
$ bundle add my-awesome-plugin -g bridgetown_plugins
|
15
|
+
```
|
16
|
+
|
17
|
+
Or if there's a `bridgetown.automation.rb` automation script, you can run that instead for guided setup:
|
18
|
+
|
19
|
+
```shell
|
20
|
+
$ bin/bridgetown apply https://github.com/username/my-awesome-plugin
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
The plugin will…
|
26
|
+
|
27
|
+
### Optional configuration options
|
28
|
+
|
29
|
+
The plugin will automatically use any of the following metadata variables if they are present in your site's `_data/site_metadata.yml` file.
|
30
|
+
|
31
|
+
…
|
32
|
+
|
33
|
+
## Testing
|
34
|
+
|
35
|
+
* Run `bundle exec rake test` to run the test suite
|
36
|
+
* Or run `script/cibuild` to validate with Rubocop and Minitest together.
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it (https://github.com/username/my-awesome-plugin/fork)
|
41
|
+
2. Clone the fork using `git clone` to your local development machine.
|
42
|
+
3. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
6. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# If your plugin requires a lot of steps to get set up, consider writing an automation to help guide users.
|
2
|
+
# You could set up and configure all sorts of things, for example:
|
3
|
+
#
|
4
|
+
# add_bridgetown_plugin("my-plugin")
|
5
|
+
#
|
6
|
+
# add_yarn_for_gem("my-plugin")
|
7
|
+
#
|
8
|
+
# create_builder "my_nifty_builder.rb" do
|
9
|
+
# <<~RUBY
|
10
|
+
# class MyNeatBuilder < SiteBuilder
|
11
|
+
# def build
|
12
|
+
# puts MyPlugin.hello
|
13
|
+
# end
|
14
|
+
# end
|
15
|
+
# RUBY
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# javascript_import do
|
19
|
+
# <<~JS
|
20
|
+
# import { MyPlugin } from "my-plugin"
|
21
|
+
# JS
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# javascript_import 'import "my-plugin.css"'
|
25
|
+
#
|
26
|
+
# create_file "src/_data/plugin_data.yml" do
|
27
|
+
# <<~YAML
|
28
|
+
# data:
|
29
|
+
# goes:
|
30
|
+
# here
|
31
|
+
# YAML
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
# color = ask("What's your favorite color?")
|
35
|
+
#
|
36
|
+
# append_to_file "bridgetown.config.yml" do
|
37
|
+
# <<~YAML
|
38
|
+
#
|
39
|
+
# my_plugin:
|
40
|
+
# favorite_color: #{color}
|
41
|
+
# YAML
|
42
|
+
# end
|
43
|
+
#
|
44
|
+
# Read the Automations documentation: https://www.bridgetownrb.com/docs/automations
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/bridgetown_notion/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bridgetown_notion"
|
7
|
+
spec.version = BridgetownNotion::VERSION
|
8
|
+
spec.author = "Francois Buys"
|
9
|
+
spec.email = "buys.fran@gmail.com"
|
10
|
+
spec.summary = "Integrates with Notion so we can use notion like a CMS"
|
11
|
+
spec.homepage = "https://github.com/fbuys/bridgetown_notion"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
|
15
|
+
spec.test_files = spec.files.grep(%r!^test/!)
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.required_ruby_version = ">= 2.7.0"
|
19
|
+
|
20
|
+
spec.add_dependency "bridgetown", ">= 1.0", "< 2.0"
|
21
|
+
spec.add_dependency "notion-ruby-client", ">= 1.0", "< 2.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler"
|
24
|
+
spec.add_development_dependency "rake", ">= 13.0"
|
25
|
+
spec.add_development_dependency "rubocop-bridgetown", "~> 0.3"
|
26
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module BridgetownNotion
|
4
|
+
class Builder < Bridgetown::Builder
|
5
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/MethodLength
|
6
|
+
def build
|
7
|
+
Notion.configure do |config|
|
8
|
+
config.token = ENV.fetch("NOTION_KEY")
|
9
|
+
end
|
10
|
+
|
11
|
+
client = Notion::Client.new
|
12
|
+
|
13
|
+
client.database_query(database_id: ENV.fetch("NOTION_DB_ID")) do |posts_page|
|
14
|
+
posts_page.results.each do |post|
|
15
|
+
title = post.dig("properties", "title", "title", 0, "text", "content")
|
16
|
+
categories = (post.dig("properties", "categories", "multi_select") || [])
|
17
|
+
.map { |c| c["name"] }.join(" ")
|
18
|
+
tags = (post.dig("properties", "tags", "multi_select") || [])
|
19
|
+
.map { |t| t["name"] }.join(" ")
|
20
|
+
is_published = post["properties"]["published"]["checkbox"]
|
21
|
+
published_at = post.dig("properties", "published_at", "date", "start")
|
22
|
+
content = ""
|
23
|
+
|
24
|
+
next if published_at.nil? || title.nil?
|
25
|
+
|
26
|
+
client.block_children(block_id: post.id) do |blocks_page|
|
27
|
+
blocks_page.results.each do |block|
|
28
|
+
content += extract_content(block)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
add_resource :posts, "#{published_at}-#{title}.md" do
|
33
|
+
categories categories
|
34
|
+
content content
|
35
|
+
layout :post
|
36
|
+
published is_published
|
37
|
+
tags tags
|
38
|
+
title title
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/AbcSize, Metrics/PerceivedComplexity, Metrics/MethodLength
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
48
|
+
def extract_content(block)
|
49
|
+
result = block.dig("heading_1", "rich_text", 0, "text", "content")
|
50
|
+
return "# #{result}\n" if result
|
51
|
+
|
52
|
+
result = block.dig("heading_2", "rich_text", 0, "text", "content")
|
53
|
+
return "## #{result}\n" if result
|
54
|
+
|
55
|
+
result = block.dig("heading_3", "rich_text", 0, "text", "content")
|
56
|
+
return "### #{result}\n" if result
|
57
|
+
|
58
|
+
result = block.dig("heading_4", "rich_text", 0, "text", "content")
|
59
|
+
return "#### #{result}\n" if result
|
60
|
+
|
61
|
+
result = block.dig("heading_5", "rich_text", 0, "text", "content")
|
62
|
+
return "##### #{result}\n" if result
|
63
|
+
|
64
|
+
result = block.dig("heading_6", "rich_text", 0, "text", "content")
|
65
|
+
return "###### #{result}\n" if result
|
66
|
+
|
67
|
+
result = block.dig("paragraph", "rich_text", 0, "text", "content")
|
68
|
+
return "#{result}\n" if result
|
69
|
+
|
70
|
+
result = block.dig("bulleted_list_item", "rich_text", 0, "text", "content")
|
71
|
+
return "- #{result}\n" if result
|
72
|
+
|
73
|
+
"\n"
|
74
|
+
end
|
75
|
+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
BridgetownNotion::Builder.register
|
metadata
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bridgetown_notion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Francois Buys
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-02-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bridgetown
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: notion-ruby-client
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.0'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2.0'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.0'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '2.0'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '13.0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '13.0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rubocop-bridgetown
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.3'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0.3'
|
95
|
+
description:
|
96
|
+
email: buys.fran@gmail.com
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- ".gitignore"
|
102
|
+
- ".rubocop.yml"
|
103
|
+
- CHANGELOG.md
|
104
|
+
- Gemfile
|
105
|
+
- LICENSE.txt
|
106
|
+
- README.md
|
107
|
+
- Rakefile
|
108
|
+
- bridgetown.automation.rb
|
109
|
+
- bridgetown_notion.gemspec
|
110
|
+
- lib/bridgetown_notion.rb
|
111
|
+
- lib/bridgetown_notion/builder.rb
|
112
|
+
- lib/bridgetown_notion/version.rb
|
113
|
+
homepage: https://github.com/fbuys/bridgetown_notion
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
metadata: {}
|
117
|
+
post_install_message:
|
118
|
+
rdoc_options: []
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 2.7.0
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
requirements: []
|
132
|
+
rubygems_version: 3.3.7
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: Integrates with Notion so we can use notion like a CMS
|
136
|
+
test_files: []
|