cloudcannon-jekyll 2.2.0 → 2.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +25 -0
- data/README.md +7 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/info-2.x.json +8 -7
- data/lib/cloudcannon-jekyll/_cloudcannon/info-3.0-4.x.json +8 -6
- data/lib/cloudcannon-jekyll/_cloudcannon/info.json +10 -7
- data/lib/cloudcannon-jekyll/generator.rb +119 -25
- data/lib/cloudcannon-jekyll/jsonify-filter.rb +2 -2
- 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: c62beece4089cf5687f4c84d38495a602f62800a19bd5e195eb0272f79724965
|
4
|
+
data.tar.gz: 34024730134cd587c13ba63e259454c9d1aedb3fd0479f8ef32a2401ddab0753
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09a307c7f7d9deba9f4fe4407ae982b16c6a260bda34bbe140547cfe978a5268c0016210f995a8a6cf69c0b0815b3e883b369265586af64dfc07b41daa78e0ef'
|
7
|
+
data.tar.gz: 798272f7382f5da33c7bb6c03e30733a506346bc162eb042c1ef09fc1b62ae405d8660bb10771a07377cefeda9995852295dbd0cc37066f2c83944ae4b0777f8
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
# 2.3.3
|
2
|
+
|
3
|
+
* Add _structures
|
4
|
+
|
5
|
+
# 2.3.2
|
6
|
+
|
7
|
+
* Add _inputs to templates
|
8
|
+
|
9
|
+
# 2.3.1
|
10
|
+
|
11
|
+
* Fix issue where pages config overwrites default
|
12
|
+
* Fix issue when a site has no pages
|
13
|
+
|
14
|
+
# 2.3.0
|
15
|
+
|
16
|
+
* Fix output for drafts collection config
|
17
|
+
* Update schema version
|
18
|
+
* fix parsing for category folders
|
19
|
+
* Add logging
|
20
|
+
|
21
|
+
# 2.2.0
|
22
|
+
|
23
|
+
* Move data logic out of template
|
24
|
+
* Auto-populate categories and tags in data
|
25
|
+
|
1
26
|
# 2.1.0
|
2
27
|
|
3
28
|
* 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 }},
|
@@ -42,6 +38,9 @@
|
|
42
38
|
{% if config._options %}
|
43
39
|
"_options": {{ config._options | cc_jsonify }},
|
44
40
|
{% endif %}
|
41
|
+
{% if config._inputs %}
|
42
|
+
"_inputs": {{ config._inputs | cc_jsonify }},
|
43
|
+
{% endif %}
|
45
44
|
{% if config._collection_groups %}
|
46
45
|
"_collection_groups": {{ config._collection_groups | cc_jsonify }},
|
47
46
|
{% endif %}
|
@@ -58,13 +57,15 @@
|
|
58
57
|
},
|
59
58
|
{% endif %}
|
60
59
|
"paths": {
|
60
|
+
"static": "",
|
61
61
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
62
62
|
"data": {{ config.data_dir | cc_jsonify }},
|
63
|
-
"pages": "",
|
64
63
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
65
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
66
64
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
67
65
|
},
|
66
|
+
{% if config._structures %}
|
67
|
+
"_structures": {{ config._structures | cc_jsonify: 50 }},
|
68
|
+
{% endif %}
|
68
69
|
{% if config._array_structures %}
|
69
70
|
"_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
|
70
71
|
{% endif %}
|
@@ -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 }},
|
@@ -41,6 +38,9 @@
|
|
41
38
|
{% if config._options %}
|
42
39
|
"_options": {{ config._options | cc_jsonify }},
|
43
40
|
{% endif %}
|
41
|
+
{% if config._inputs %}
|
42
|
+
"_inputs": {{ config._inputs | cc_jsonify }},
|
43
|
+
{% endif %}
|
44
44
|
{% if config._collection_groups %}
|
45
45
|
"_collection_groups": {{ config._collection_groups | cc_jsonify }},
|
46
46
|
{% endif %}
|
@@ -57,13 +57,15 @@
|
|
57
57
|
},
|
58
58
|
{% endif %}
|
59
59
|
"paths": {
|
60
|
+
"static": "",
|
60
61
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
61
62
|
"data": {{ config.data_dir | cc_jsonify }},
|
62
|
-
"pages": "",
|
63
63
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
64
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
65
64
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
66
65
|
},
|
66
|
+
{% if config._structures %}
|
67
|
+
"_structures": {{ config._structures | cc_jsonify: 50 }},
|
68
|
+
{% endif %}
|
67
69
|
{% if config._array_structures %}
|
68
70
|
"_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
|
69
71
|
{% endif %}
|
@@ -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 }},
|
@@ -43,6 +41,9 @@
|
|
43
41
|
{% if config._options -%}
|
44
42
|
"_options": {{ config._options | cc_jsonify }},
|
45
43
|
{%- endif %}
|
44
|
+
{% if config._inputs -%}
|
45
|
+
"_inputs": {{ config._inputs | cc_jsonify }},
|
46
|
+
{%- endif %}
|
46
47
|
{% if config._collection_groups -%}
|
47
48
|
"_collection_groups": {{ config._collection_groups | cc_jsonify }},
|
48
49
|
{%- endif %}
|
@@ -59,13 +60,15 @@
|
|
59
60
|
},
|
60
61
|
{%- endif %}
|
61
62
|
"paths": {
|
63
|
+
"static": "",
|
62
64
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
63
65
|
"data": {{ config.data_dir | cc_jsonify }},
|
64
|
-
"pages": "",
|
65
66
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
66
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
67
67
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
68
68
|
},
|
69
|
+
{% if config._structures -%}
|
70
|
+
"_structures": {{ config._structures | cc_jsonify: 50 }},
|
71
|
+
{%- endif %}
|
69
72
|
{% if config._array_structures -%}
|
70
73
|
"_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
|
71
74
|
{%- endif %}
|
@@ -13,51 +13,87 @@ 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
|
-
|
47
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
48
|
+
def generate_collections_config(pages)
|
42
49
|
collections = @site.config["collections"]&.dup || {}
|
43
|
-
|
50
|
+
collections_config = @site.config.dig("cloudcannon", "collections")&.dup || {}
|
44
51
|
|
45
52
|
collections.each_key do |key|
|
46
53
|
# Workaround for empty collection configurations
|
47
54
|
defaults = collections[key] || { "output" => false }
|
48
|
-
|
55
|
+
collections_config[key] = (collections_config[key] || {}).merge(defaults)
|
49
56
|
end
|
50
57
|
|
51
|
-
|
58
|
+
unless pages.empty? || collections.key?("pages")
|
59
|
+
pages_defaults = {
|
60
|
+
"output" => true,
|
61
|
+
"filter" => "strict",
|
62
|
+
"path" => "",
|
63
|
+
}
|
64
|
+
|
65
|
+
collections_config["pages"] = pages_defaults.merge(collections_config["pages"] || {})
|
66
|
+
end
|
67
|
+
|
68
|
+
collections_config
|
52
69
|
end
|
53
70
|
|
54
|
-
|
55
|
-
|
71
|
+
# rubocop:disable Metrics/PerceivedComplexity
|
72
|
+
def generate_collections(collections_config, pages, drafts)
|
73
|
+
split_posts = group_by_category_folder(all_posts, "posts")
|
74
|
+
split_drafts = group_by_category_folder(drafts, "drafts")
|
75
|
+
|
76
|
+
collections = {}
|
77
|
+
collections_config.each_key do |key|
|
78
|
+
collections[key] = if key == "posts" || key.end_with?("/posts")
|
79
|
+
split_posts[key]
|
80
|
+
elsif key == "drafts" || key.end_with?("/drafts")
|
81
|
+
split_drafts[key]
|
82
|
+
else
|
83
|
+
@site.collections[key]&.docs
|
84
|
+
end
|
85
|
+
|
86
|
+
collections[key] ||= []
|
87
|
+
end
|
56
88
|
|
57
|
-
|
89
|
+
has_collection_pages = collections.key?("pages") && !collections["pages"].empty?
|
90
|
+
collections["pages"] = pages unless pages.empty? || has_collection_pages
|
91
|
+
collections
|
58
92
|
end
|
93
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
94
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
59
95
|
|
60
|
-
def
|
96
|
+
def generate_data
|
61
97
|
cc_data = @site.config.dig("cloudcannon", "data")
|
62
98
|
data = if cc_data == true
|
63
99
|
@site.data&.dup
|
@@ -68,20 +104,57 @@ module CloudCannonJekyll
|
|
68
104
|
data ||= {}
|
69
105
|
data["categories"] ||= @site.categories.keys
|
70
106
|
data["tags"] ||= @site.tags.keys
|
107
|
+
|
108
|
+
data.each_key do |key|
|
109
|
+
log "💾 Processed #{key.bold} data set"
|
110
|
+
end
|
111
|
+
|
71
112
|
data
|
72
113
|
end
|
73
114
|
|
115
|
+
def generate_pages
|
116
|
+
html_pages = @site.pages.select do |page|
|
117
|
+
page.html? || page.url.end_with?("/")
|
118
|
+
end
|
119
|
+
|
120
|
+
static_pages = @site.static_files.select do |static_page|
|
121
|
+
JsonifyFilter::STATIC_EXTENSIONS.include?(static_page.extname)
|
122
|
+
end
|
123
|
+
|
124
|
+
html_pages + static_pages
|
125
|
+
end
|
126
|
+
|
127
|
+
def collections_dir
|
128
|
+
return "" if Jekyll::VERSION.start_with? "2."
|
129
|
+
|
130
|
+
@site.config["collections_dir"] || ""
|
131
|
+
end
|
132
|
+
|
74
133
|
def data_dir
|
75
134
|
@site.config["data_dir"] || "_data"
|
76
135
|
end
|
77
136
|
|
78
|
-
|
79
|
-
def add_category_folder_config(collections_config, posts_config = {})
|
137
|
+
def all_posts
|
80
138
|
posts = @site.posts || @site.collections["posts"]
|
81
|
-
|
139
|
+
posts.class.method_defined?(:docs) ? posts.docs : posts
|
140
|
+
end
|
141
|
+
|
142
|
+
def group_by_category_folder(collection, key)
|
143
|
+
split_path = "/_#{key}/"
|
144
|
+
collection.group_by do |doc|
|
145
|
+
parts = doc.relative_path.split(split_path)
|
146
|
+
if parts.length > 1
|
147
|
+
"#{parts.first}/#{key}".sub(%r!^\/+!, "")
|
148
|
+
else
|
149
|
+
key
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def add_category_folder_config(collections_config, posts_config = {})
|
82
155
|
seen = {}
|
83
156
|
|
84
|
-
|
157
|
+
all_posts.map do |post|
|
85
158
|
parts = post.relative_path.split("/_posts/")
|
86
159
|
path = parts.first
|
87
160
|
|
@@ -108,7 +181,23 @@ module CloudCannonJekyll
|
|
108
181
|
path
|
109
182
|
end
|
110
183
|
end
|
111
|
-
|
184
|
+
|
185
|
+
def remove_empty_collection_config(collections_config, collections)
|
186
|
+
cc_collections = @site.config.dig("cloudcannon", "collections") || {}
|
187
|
+
|
188
|
+
collections_config.each_key do |key|
|
189
|
+
if collections[key].empty? && !cc_collections.key?(key)
|
190
|
+
log "📂 #{"Ignored".yellow} #{key.bold} collection"
|
191
|
+
collections_config.delete(key)
|
192
|
+
else
|
193
|
+
log "📁 Processed #{key.bold} collection with #{collections[key]&.length || 0} files"
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
def migrate_legacy_config
|
199
|
+
add_legacy_explore_groups
|
200
|
+
end
|
112
201
|
|
113
202
|
# Support for the deprecated _explore configuration
|
114
203
|
def add_legacy_explore_groups
|
@@ -128,8 +217,8 @@ module CloudCannonJekyll
|
|
128
217
|
collections_config["posts"] = { "output" => true } if Jekyll::VERSION.start_with? "2."
|
129
218
|
drafts = @reader.read_drafts(collections_dir)
|
130
219
|
|
131
|
-
if drafts.any?
|
132
|
-
collections_config["drafts"] = {}
|
220
|
+
if drafts.any? && !collections_config.key?("drafts")
|
221
|
+
collections_config["drafts"] = { "output" => !!@site.show_drafts }
|
133
222
|
end
|
134
223
|
|
135
224
|
folders = add_category_folder_config(collections_config, collections_config["posts"])
|
@@ -153,6 +242,11 @@ module CloudCannonJekyll
|
|
153
242
|
File.open(dest, "w") { |file| file.write(file_content(filename, data)) }
|
154
243
|
@site.keep_files ||= []
|
155
244
|
@site.keep_files << path(filename)
|
245
|
+
log "🏁 Generated #{path(filename).bold} #{"successfully".green}"
|
246
|
+
end
|
247
|
+
|
248
|
+
def log(str)
|
249
|
+
Jekyll.logger.info("CloudCannon:", str)
|
156
250
|
end
|
157
251
|
|
158
252
|
def version_path_suffix
|
@@ -50,7 +50,7 @@ module CloudCannonJekyll
|
|
50
50
|
next if prevent.include?(key) || key.nil?
|
51
51
|
|
52
52
|
prevent.push key
|
53
|
-
next_max_depth =
|
53
|
+
next_max_depth = %w(_array_structures _structures).include?(key) ? 20 : max_depth
|
54
54
|
"#{key.to_json}: #{JsonifyFilter.to_json(value, depth, next_max_depth)}"
|
55
55
|
end
|
56
56
|
|
@@ -134,7 +134,7 @@ module CloudCannonJekyll
|
|
134
134
|
|
135
135
|
def self.hash_to_json(input, depth, max_depth)
|
136
136
|
out = input.map do |key, value|
|
137
|
-
next_max_depth =
|
137
|
+
next_max_depth = %w(_array_structures _structures).include?(key) ? 20 : max_depth
|
138
138
|
string_key = key.to_s.to_json
|
139
139
|
"#{string_key}: #{JsonifyFilter.to_json(value, depth, next_max_depth)}"
|
140
140
|
end
|
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.3
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|