cloudcannon-jekyll 2.2.0 → 2.3.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 +4 -4
- data/HISTORY.md +12 -0
- data/README.md +7 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/info-2.x.json +2 -7
- data/lib/cloudcannon-jekyll/_cloudcannon/info-3.0-4.x.json +2 -6
- data/lib/cloudcannon-jekyll/_cloudcannon/info.json +4 -7
- data/lib/cloudcannon-jekyll/generator.rb +114 -25
- data/lib/cloudcannon-jekyll/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a8badc065e548c467c7c794747e3f7147eeb8b200f19fe73aef583a026ab657
|
4
|
+
data.tar.gz: e6fa47b31b8801e4f6b106574cf15584a56299be5dff80128a2c12b325d6d77e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60a58b7deaeaff3265a13ad0b14b1fe68229b53f1b413a08d7859167c3acc3da2ecef016372b08f630705edd14040167be6e9b15323344948e6856f4666c3bf6
|
7
|
+
data.tar.gz: 5c3d1b8402f2178eea44a03743d9d3985a19984795ff320dc9e34e106c3d19e0d34782e34f8d6905d039b36917a87bfe57dfe88f4288b4bf2575fe3fddc13acf
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# 2.3.0
|
2
|
+
|
3
|
+
* Fix output for drafts collection config
|
4
|
+
* Update schema version
|
5
|
+
* fix parsing for category folders
|
6
|
+
* Add logging
|
7
|
+
|
8
|
+
# 2.2.0
|
9
|
+
|
10
|
+
* Move data logic out of template
|
11
|
+
* Auto-populate categories and tags in data
|
12
|
+
|
1
13
|
# 2.1.0
|
2
14
|
|
3
15
|
* Add `_instance_values` to global scope
|
data/README.md
CHANGED
@@ -26,6 +26,13 @@ plugins:
|
|
26
26
|
4. Build new gem with `gem build cloudcannon-jekyll.gemspec`
|
27
27
|
5. Push new version to rubygems.org with `gem push cloudcannon-jekyll-{{ VERSION HERE }}.gem`
|
28
28
|
|
29
|
+
OR:
|
30
|
+
|
31
|
+
1. Increase version in lib/cloudcannon-jekyll/version.rb
|
32
|
+
2. Update HISTORY.md
|
33
|
+
3. Run `./scripts/release`
|
34
|
+
3. Create a release in GitHub
|
35
|
+
|
29
36
|
|
30
37
|
## Testing
|
31
38
|
|
@@ -19,13 +19,9 @@
|
|
19
19
|
{% endif %}
|
20
20
|
"collections-config": {{ collections_config | cc_jsonify }},
|
21
21
|
"collections": {
|
22
|
-
"
|
23
|
-
"posts": {{ site.posts | reverse | cc_jsonify }}{% if site.collections.size > 0 %},{% endif %}
|
24
|
-
{% for collection in site.collections %}"{{ collection[0] | xml_escape }}": {{ collection[1].docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
22
|
+
{% for collection in collections %}"{{ collection[0] | xml_escape }}": {{ collection[1] | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
25
23
|
{% endfor %}
|
26
24
|
},
|
27
|
-
"pages": {{ site.html_pages | cc_jsonify }},
|
28
|
-
"static-pages": {{ site.static_files | cc_static_files_jsonify }},
|
29
25
|
"data": {{ data | cc_jsonify }},
|
30
26
|
{% if config.baseurl %}
|
31
27
|
"base-url": {{ config.baseurl | cc_jsonify }},
|
@@ -58,11 +54,10 @@
|
|
58
54
|
},
|
59
55
|
{% endif %}
|
60
56
|
"paths": {
|
57
|
+
"static": "",
|
61
58
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
62
59
|
"data": {{ config.data_dir | cc_jsonify }},
|
63
|
-
"pages": "",
|
64
60
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
65
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
66
61
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
67
62
|
},
|
68
63
|
{% if config._array_structures %}
|
@@ -19,12 +19,9 @@
|
|
19
19
|
{% endif %}
|
20
20
|
"collections-config": {{ collections_config | cc_jsonify }},
|
21
21
|
"collections": {
|
22
|
-
"
|
23
|
-
{% for collection in site.collections %}"{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
22
|
+
{% for collection in collections %}"{{ collection[0] | xml_escape }}": {{ collection[1] | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
24
23
|
{% endfor %}
|
25
24
|
},
|
26
|
-
"pages": {{ site.html_pages | cc_jsonify }},
|
27
|
-
"static-pages": {{ site.static_files | cc_static_files_jsonify }},
|
28
25
|
"data": {{ data | cc_jsonify }},
|
29
26
|
{% if config.baseurl %}
|
30
27
|
"base-url": {{ config.baseurl | cc_jsonify }},
|
@@ -57,11 +54,10 @@
|
|
57
54
|
},
|
58
55
|
{% endif %}
|
59
56
|
"paths": {
|
57
|
+
"static": "",
|
60
58
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
61
59
|
"data": {{ config.data_dir | cc_jsonify }},
|
62
|
-
"pages": "",
|
63
60
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
64
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
65
61
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
66
62
|
},
|
67
63
|
{% if config._array_structures %}
|
@@ -1,5 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"time": {{ site.time | date_to_xmlschema | cc_jsonify }},
|
3
|
+
"version": {{ version | cc_jsonify }},
|
3
4
|
"cloudcannon": {
|
4
5
|
"name": "cloudcannon-jekyll",
|
5
6
|
"version": {{ gem_version | cc_jsonify }}
|
@@ -19,14 +20,11 @@
|
|
19
20
|
{%- endif %}
|
20
21
|
"collections-config": {{ collections_config | cc_jsonify }},
|
21
22
|
"collections": {
|
22
|
-
|
23
|
-
|
24
|
-
"{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}
|
23
|
+
{%- for collection in collections -%}
|
24
|
+
"{{ collection[0] | xml_escape }}": {{ collection[1] | cc_jsonify }}
|
25
25
|
{%- unless forloop.last %},{% endunless %}
|
26
26
|
{%- endfor -%}
|
27
27
|
},
|
28
|
-
"pages": {{ site.html_pages | cc_jsonify }},
|
29
|
-
"static-pages": {{ site.static_files | cc_static_files_jsonify }},
|
30
28
|
"data": {{ data | cc_jsonify }},
|
31
29
|
{% if config.baseurl -%}
|
32
30
|
"base-url": {{ config.baseurl | cc_jsonify }},
|
@@ -59,11 +57,10 @@
|
|
59
57
|
},
|
60
58
|
{%- endif %}
|
61
59
|
"paths": {
|
60
|
+
"static": "",
|
62
61
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
63
62
|
"data": {{ config.data_dir | cc_jsonify }},
|
64
|
-
"pages": "",
|
65
63
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
66
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
67
64
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
68
65
|
},
|
69
66
|
{% if config._array_structures -%}
|
@@ -13,51 +13,82 @@ module CloudCannonJekyll
|
|
13
13
|
1
|
14
14
|
end
|
15
15
|
|
16
|
+
# rubocop:disable Metrics/MethodLength
|
16
17
|
def generate(site)
|
18
|
+
log "⭐️ Starting #{"cloudcannon-jekyll".blue}"
|
19
|
+
|
17
20
|
@site = site
|
18
21
|
@reader = Reader.new(@site)
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
payload = @site.site_payload.merge({
|
24
|
-
"gem_version" => CloudCannonJekyll::VERSION,
|
25
|
-
})
|
26
|
-
|
23
|
+
migrate_legacy_config
|
24
|
+
pages = generate_pages
|
25
|
+
collections_config = generate_collections_config(pages)
|
27
26
|
drafts = add_blogging_config(collections_config)
|
28
27
|
add_collection_paths(collections_config)
|
28
|
+
|
29
|
+
collections = generate_collections(collections_config, pages, drafts)
|
30
|
+
remove_empty_collection_config(collections_config, collections)
|
31
|
+
|
29
32
|
add_data_config(collections_config)
|
30
|
-
|
33
|
+
data = generate_data
|
31
34
|
|
32
|
-
generate_file("info",
|
35
|
+
generate_file("info", @site.site_payload.merge({
|
33
36
|
"pwd" => Dir.pwd,
|
37
|
+
"version" => "0.0.2",
|
38
|
+
"gem_version" => CloudCannonJekyll::VERSION,
|
34
39
|
"config" => @site.config,
|
35
40
|
"collections_config" => collections_config,
|
36
|
-
"
|
41
|
+
"collections" => collections,
|
37
42
|
"data" => data,
|
38
43
|
}))
|
39
44
|
end
|
45
|
+
# rubocop:enable Metrics/MethodLength
|
40
46
|
|
41
|
-
def
|
47
|
+
def generate_collections_config(pages)
|
42
48
|
collections = @site.config["collections"]&.dup || {}
|
43
|
-
|
49
|
+
collections_config = @site.config.dig("cloudcannon", "collections")&.dup || {}
|
44
50
|
|
45
51
|
collections.each_key do |key|
|
46
52
|
# Workaround for empty collection configurations
|
47
53
|
defaults = collections[key] || { "output" => false }
|
48
|
-
|
54
|
+
collections_config[key] = (collections_config[key] || {}).merge(defaults)
|
49
55
|
end
|
50
56
|
|
51
|
-
|
57
|
+
unless pages.empty?
|
58
|
+
collections_config["pages"] ||= {
|
59
|
+
"output" => true,
|
60
|
+
"filter" => "strict",
|
61
|
+
"path" => "",
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
collections_config
|
52
66
|
end
|
53
67
|
|
54
|
-
|
55
|
-
|
68
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
69
|
+
def generate_collections(collections_config, pages, drafts)
|
70
|
+
split_posts = group_by_category_folder(all_posts, "posts")
|
71
|
+
split_drafts = group_by_category_folder(drafts, "drafts")
|
72
|
+
|
73
|
+
collections = {}
|
74
|
+
collections_config.each_key do |key|
|
75
|
+
collections[key] = if key == "posts" || key.end_with?("/posts")
|
76
|
+
split_posts[key]
|
77
|
+
elsif key == "drafts" || key.end_with?("/drafts")
|
78
|
+
split_drafts[key]
|
79
|
+
else
|
80
|
+
@site.collections[key]&.docs
|
81
|
+
end
|
82
|
+
|
83
|
+
collections[key] ||= []
|
84
|
+
end
|
56
85
|
|
57
|
-
|
86
|
+
collections["pages"] = pages if collections["pages"].empty? && !pages.empty?
|
87
|
+
collections
|
58
88
|
end
|
89
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
59
90
|
|
60
|
-
def
|
91
|
+
def generate_data
|
61
92
|
cc_data = @site.config.dig("cloudcannon", "data")
|
62
93
|
data = if cc_data == true
|
63
94
|
@site.data&.dup
|
@@ -68,20 +99,57 @@ module CloudCannonJekyll
|
|
68
99
|
data ||= {}
|
69
100
|
data["categories"] ||= @site.categories.keys
|
70
101
|
data["tags"] ||= @site.tags.keys
|
102
|
+
|
103
|
+
data.each_key do |key|
|
104
|
+
log "💾 Processed #{key.bold} data set"
|
105
|
+
end
|
106
|
+
|
71
107
|
data
|
72
108
|
end
|
73
109
|
|
110
|
+
def generate_pages
|
111
|
+
html_pages = @site.pages.select do |page|
|
112
|
+
page.html? || page.url.end_with?("/")
|
113
|
+
end
|
114
|
+
|
115
|
+
static_pages = @site.static_files.select do |static_page|
|
116
|
+
JsonifyFilter::STATIC_EXTENSIONS.include?(static_page.extname)
|
117
|
+
end
|
118
|
+
|
119
|
+
html_pages + static_pages
|
120
|
+
end
|
121
|
+
|
122
|
+
def collections_dir
|
123
|
+
return "" if Jekyll::VERSION.start_with? "2."
|
124
|
+
|
125
|
+
@site.config["collections_dir"] || ""
|
126
|
+
end
|
127
|
+
|
74
128
|
def data_dir
|
75
129
|
@site.config["data_dir"] || "_data"
|
76
130
|
end
|
77
131
|
|
78
|
-
|
79
|
-
def add_category_folder_config(collections_config, posts_config = {})
|
132
|
+
def all_posts
|
80
133
|
posts = @site.posts || @site.collections["posts"]
|
81
|
-
|
134
|
+
posts.class.method_defined?(:docs) ? posts.docs : posts
|
135
|
+
end
|
136
|
+
|
137
|
+
def group_by_category_folder(collection, key)
|
138
|
+
split_path = "/_#{key}/"
|
139
|
+
collection.group_by do |doc|
|
140
|
+
parts = doc.relative_path.split(split_path)
|
141
|
+
if parts.length > 1
|
142
|
+
"#{parts.first}/#{key}".sub(%r!^\/+!, "")
|
143
|
+
else
|
144
|
+
key
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def add_category_folder_config(collections_config, posts_config = {})
|
82
150
|
seen = {}
|
83
151
|
|
84
|
-
|
152
|
+
all_posts.map do |post|
|
85
153
|
parts = post.relative_path.split("/_posts/")
|
86
154
|
path = parts.first
|
87
155
|
|
@@ -108,7 +176,23 @@ module CloudCannonJekyll
|
|
108
176
|
path
|
109
177
|
end
|
110
178
|
end
|
111
|
-
|
179
|
+
|
180
|
+
def remove_empty_collection_config(collections_config, collections)
|
181
|
+
cc_collections = @site.config.dig("cloudcannon", "collections") || {}
|
182
|
+
|
183
|
+
collections_config.each_key do |key|
|
184
|
+
if collections[key].empty? && !cc_collections.key?(key)
|
185
|
+
log "📂 #{"Ignored".yellow} #{key.bold} collection"
|
186
|
+
collections_config.delete(key)
|
187
|
+
else
|
188
|
+
log "📁 Processed #{key.bold} collection with #{collections[key]&.length || 0} files"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def migrate_legacy_config
|
194
|
+
add_legacy_explore_groups
|
195
|
+
end
|
112
196
|
|
113
197
|
# Support for the deprecated _explore configuration
|
114
198
|
def add_legacy_explore_groups
|
@@ -128,8 +212,8 @@ module CloudCannonJekyll
|
|
128
212
|
collections_config["posts"] = { "output" => true } if Jekyll::VERSION.start_with? "2."
|
129
213
|
drafts = @reader.read_drafts(collections_dir)
|
130
214
|
|
131
|
-
if drafts.any?
|
132
|
-
collections_config["drafts"] = {}
|
215
|
+
if drafts.any? && !collections_config.key?("drafts")
|
216
|
+
collections_config["drafts"] = { "output" => !!@site.show_drafts }
|
133
217
|
end
|
134
218
|
|
135
219
|
folders = add_category_folder_config(collections_config, collections_config["posts"])
|
@@ -153,6 +237,11 @@ module CloudCannonJekyll
|
|
153
237
|
File.open(dest, "w") { |file| file.write(file_content(filename, data)) }
|
154
238
|
@site.keep_files ||= []
|
155
239
|
@site.keep_files << path(filename)
|
240
|
+
log "🏁 Generated #{path(filename).bold} #{"successfully".green}"
|
241
|
+
end
|
242
|
+
|
243
|
+
def log(str)
|
244
|
+
Jekyll.logger.info("CloudCannon:", str)
|
156
245
|
end
|
157
246
|
|
158
247
|
def version_path_suffix
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudcannon-jekyll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CloudCannon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|