cloudcannon-jekyll 2.1.0 → 2.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +21 -0
- data/README.md +7 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/info-2.x.json +6 -11
- data/lib/cloudcannon-jekyll/_cloudcannon/info-3.0-4.x.json +6 -10
- data/lib/cloudcannon-jekyll/_cloudcannon/info.json +8 -22
- data/lib/cloudcannon-jekyll/generator.rb +130 -20
- 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: efdfbdebe6d3466481e84abaf6b7b4864a1099eb7d0912c3ead7ac315ec4019a
|
4
|
+
data.tar.gz: fc4928e35e8668c0e9486299e998ed86ee1d5ed22b5933eb19da6bd5f4bb57ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05d2807950dee52da723333cbfbc443cea8ab22e2ca7717e68c64e74f3f0cdcebd12c1d1bea5516117bda31b6f18ba1f6951db581cba521bc0ee228569923471
|
7
|
+
data.tar.gz: '0087790fb58ed83ffdeb6ef07b403a889c6d3ef805af73a1ad231f57f8dfe20f2012da33fb3149eccd865c95521bf77184b976b48bfbbb33591478ea0d8df40c'
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# 2.3.2
|
2
|
+
|
3
|
+
* Add _inputs to templates
|
4
|
+
|
5
|
+
# 2.3.1
|
6
|
+
|
7
|
+
* Fix issue where pages config overwrites default
|
8
|
+
* Fix issue when a site has no pages
|
9
|
+
|
10
|
+
# 2.3.0
|
11
|
+
|
12
|
+
* Fix output for drafts collection config
|
13
|
+
* Update schema version
|
14
|
+
* fix parsing for category folders
|
15
|
+
* Add logging
|
16
|
+
|
17
|
+
# 2.2.0
|
18
|
+
|
19
|
+
* Move data logic out of template
|
20
|
+
* Auto-populate categories and tags in data
|
21
|
+
|
1
22
|
# 2.1.0
|
2
23
|
|
3
24
|
* 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,17 +19,10 @@
|
|
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
|
-
"
|
28
|
-
"static-pages": {{ site.static_files | cc_static_files_jsonify }},
|
29
|
-
{% if site.cloudcannon.data.first %}{% assign data_seen = false %}
|
30
|
-
"data": {
|
31
|
-
{% for data in site.data %}{% assign key = data[0] %}{% if site.cloudcannon.data[key] %}{% if data_seen %},{% endif %}{{ data[0] | cc_jsonify }}: {{ data[1] | cc_jsonify }}{% assign data_seen = true %}{% endif %}{% endfor %}},
|
32
|
-
{% elsif site.cloudcannon.data %}"data": {{ site.data | cc_jsonify }},{% endif %}
|
25
|
+
"data": {{ data | cc_jsonify }},
|
33
26
|
{% if config.baseurl %}
|
34
27
|
"base-url": {{ config.baseurl | cc_jsonify }},
|
35
28
|
{% endif %}
|
@@ -45,6 +38,9 @@
|
|
45
38
|
{% if config._options %}
|
46
39
|
"_options": {{ config._options | cc_jsonify }},
|
47
40
|
{% endif %}
|
41
|
+
{% if config._inputs %}
|
42
|
+
"_inputs": {{ config._inputs | cc_jsonify }},
|
43
|
+
{% endif %}
|
48
44
|
{% if config._collection_groups %}
|
49
45
|
"_collection_groups": {{ config._collection_groups | cc_jsonify }},
|
50
46
|
{% endif %}
|
@@ -61,11 +57,10 @@
|
|
61
57
|
},
|
62
58
|
{% endif %}
|
63
59
|
"paths": {
|
60
|
+
"static": "",
|
64
61
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
65
62
|
"data": {{ config.data_dir | cc_jsonify }},
|
66
|
-
"pages": "",
|
67
63
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
68
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
69
64
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
70
65
|
},
|
71
66
|
{% if config._array_structures %}
|
@@ -19,16 +19,10 @@
|
|
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
|
-
"
|
27
|
-
"static-pages": {{ site.static_files | cc_static_files_jsonify }},
|
28
|
-
{% if site.cloudcannon.data.first %}{% assign data_seen = false %}
|
29
|
-
"data": {
|
30
|
-
{% for data in site.data %}{% assign key = data[0] %}{% if site.cloudcannon.data[key] %}{% if data_seen %},{% endif %}{{ data[0] | cc_jsonify }}: {{ data[1] | cc_jsonify }}{% assign data_seen = true %}{% endif %}{% endfor %}},
|
31
|
-
{% elsif site.cloudcannon.data %}"data": {{ site.data | cc_jsonify }},{% endif %}
|
25
|
+
"data": {{ data | cc_jsonify }},
|
32
26
|
{% if config.baseurl %}
|
33
27
|
"base-url": {{ config.baseurl | cc_jsonify }},
|
34
28
|
{% endif %}
|
@@ -44,6 +38,9 @@
|
|
44
38
|
{% if config._options %}
|
45
39
|
"_options": {{ config._options | cc_jsonify }},
|
46
40
|
{% endif %}
|
41
|
+
{% if config._inputs %}
|
42
|
+
"_inputs": {{ config._inputs | cc_jsonify }},
|
43
|
+
{% endif %}
|
47
44
|
{% if config._collection_groups %}
|
48
45
|
"_collection_groups": {{ config._collection_groups | cc_jsonify }},
|
49
46
|
{% endif %}
|
@@ -60,11 +57,10 @@
|
|
60
57
|
},
|
61
58
|
{% endif %}
|
62
59
|
"paths": {
|
60
|
+
"static": "",
|
63
61
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
64
62
|
"data": {{ config.data_dir | cc_jsonify }},
|
65
|
-
"pages": "",
|
66
63
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
67
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
68
64
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
69
65
|
},
|
70
66
|
{% 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,29 +20,12 @@
|
|
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
|
-
"
|
29
|
-
"static-pages": {{ site.static_files | cc_static_files_jsonify }},
|
30
|
-
{% if site.cloudcannon.data.first -%}
|
31
|
-
"data": {
|
32
|
-
{%- assign data_seen = false %}
|
33
|
-
{%- for data in site.data %}
|
34
|
-
{%- assign key = data[0] %}
|
35
|
-
{%- if site.cloudcannon.data[key] %}
|
36
|
-
{%- if data_seen %},{% endif -%}
|
37
|
-
{{ data[0] | cc_jsonify }}: {{ data[1] | cc_jsonify }}
|
38
|
-
{%- assign data_seen = true %}
|
39
|
-
{%- endif %}
|
40
|
-
{%- endfor -%}
|
41
|
-
},
|
42
|
-
{% elsif site.cloudcannon.data -%}
|
43
|
-
"data": {{ site.data | cc_jsonify }},
|
44
|
-
{%- endif %}
|
28
|
+
"data": {{ data | cc_jsonify }},
|
45
29
|
{% if config.baseurl -%}
|
46
30
|
"base-url": {{ config.baseurl | cc_jsonify }},
|
47
31
|
{%- endif %}
|
@@ -57,6 +41,9 @@
|
|
57
41
|
{% if config._options -%}
|
58
42
|
"_options": {{ config._options | cc_jsonify }},
|
59
43
|
{%- endif %}
|
44
|
+
{% if config._inputs -%}
|
45
|
+
"_inputs": {{ config._inputs | cc_jsonify }},
|
46
|
+
{%- endif %}
|
60
47
|
{% if config._collection_groups -%}
|
61
48
|
"_collection_groups": {{ config._collection_groups | cc_jsonify }},
|
62
49
|
{%- endif %}
|
@@ -73,11 +60,10 @@
|
|
73
60
|
},
|
74
61
|
{%- endif %}
|
75
62
|
"paths": {
|
63
|
+
"static": "",
|
76
64
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
77
65
|
"data": {{ config.data_dir | cc_jsonify }},
|
78
|
-
"pages": "",
|
79
66
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
80
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
81
67
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
82
68
|
},
|
83
69
|
{% if config._array_structures -%}
|
@@ -13,40 +13,115 @@ 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
|
-
"gem_version" => CloudCannonJekyll::VERSION,
|
24
|
-
})
|
25
|
-
|
23
|
+
migrate_legacy_config
|
24
|
+
pages = generate_pages
|
25
|
+
collections_config = generate_collections_config(pages)
|
26
26
|
drafts = add_blogging_config(collections_config)
|
27
27
|
add_collection_paths(collections_config)
|
28
|
+
|
29
|
+
collections = generate_collections(collections_config, pages, drafts)
|
30
|
+
remove_empty_collection_config(collections_config, collections)
|
31
|
+
|
28
32
|
add_data_config(collections_config)
|
29
|
-
|
33
|
+
data = generate_data
|
30
34
|
|
31
|
-
generate_file("info",
|
35
|
+
generate_file("info", @site.site_payload.merge({
|
32
36
|
"pwd" => Dir.pwd,
|
37
|
+
"version" => "0.0.2",
|
38
|
+
"gem_version" => CloudCannonJekyll::VERSION,
|
33
39
|
"config" => @site.config,
|
34
40
|
"collections_config" => collections_config,
|
35
|
-
"
|
41
|
+
"collections" => collections,
|
42
|
+
"data" => data,
|
36
43
|
}))
|
37
44
|
end
|
45
|
+
# rubocop:enable Metrics/MethodLength
|
38
46
|
|
39
|
-
|
47
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
48
|
+
def generate_collections_config(pages)
|
40
49
|
collections = @site.config["collections"]&.dup || {}
|
41
|
-
|
50
|
+
collections_config = @site.config.dig("cloudcannon", "collections")&.dup || {}
|
42
51
|
|
43
52
|
collections.each_key do |key|
|
44
53
|
# Workaround for empty collection configurations
|
45
54
|
defaults = collections[key] || { "output" => false }
|
46
|
-
|
55
|
+
collections_config[key] = (collections_config[key] || {}).merge(defaults)
|
56
|
+
end
|
57
|
+
|
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
|
69
|
+
end
|
70
|
+
|
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
|
88
|
+
|
89
|
+
has_collection_pages = collections.key?("pages") && !collections["pages"].empty?
|
90
|
+
collections["pages"] = pages unless pages.empty? || has_collection_pages
|
91
|
+
collections
|
92
|
+
end
|
93
|
+
# rubocop:enable Metrics/PerceivedComplexity
|
94
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
95
|
+
|
96
|
+
def generate_data
|
97
|
+
cc_data = @site.config.dig("cloudcannon", "data")
|
98
|
+
data = if cc_data == true
|
99
|
+
@site.data&.dup
|
100
|
+
elsif cc_data&.is_a?(Hash)
|
101
|
+
@site.data&.select { |key, _| cc_data.key?(key) }
|
102
|
+
end
|
103
|
+
|
104
|
+
data ||= {}
|
105
|
+
data["categories"] ||= @site.categories.keys
|
106
|
+
data["tags"] ||= @site.tags.keys
|
107
|
+
|
108
|
+
data.each_key do |key|
|
109
|
+
log "💾 Processed #{key.bold} data set"
|
110
|
+
end
|
111
|
+
|
112
|
+
data
|
113
|
+
end
|
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)
|
47
122
|
end
|
48
123
|
|
49
|
-
|
124
|
+
html_pages + static_pages
|
50
125
|
end
|
51
126
|
|
52
127
|
def collections_dir
|
@@ -59,13 +134,27 @@ module CloudCannonJekyll
|
|
59
134
|
@site.config["data_dir"] || "_data"
|
60
135
|
end
|
61
136
|
|
62
|
-
|
63
|
-
def add_category_folder_config(collections_config, posts_config = {})
|
137
|
+
def all_posts
|
64
138
|
posts = @site.posts || @site.collections["posts"]
|
65
|
-
|
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 = {})
|
66
155
|
seen = {}
|
67
156
|
|
68
|
-
|
157
|
+
all_posts.map do |post|
|
69
158
|
parts = post.relative_path.split("/_posts/")
|
70
159
|
path = parts.first
|
71
160
|
|
@@ -92,7 +181,23 @@ module CloudCannonJekyll
|
|
92
181
|
path
|
93
182
|
end
|
94
183
|
end
|
95
|
-
|
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
|
96
201
|
|
97
202
|
# Support for the deprecated _explore configuration
|
98
203
|
def add_legacy_explore_groups
|
@@ -112,8 +217,8 @@ module CloudCannonJekyll
|
|
112
217
|
collections_config["posts"] = { "output" => true } if Jekyll::VERSION.start_with? "2."
|
113
218
|
drafts = @reader.read_drafts(collections_dir)
|
114
219
|
|
115
|
-
if drafts.any?
|
116
|
-
collections_config["drafts"] = {}
|
220
|
+
if drafts.any? && !collections_config.key?("drafts")
|
221
|
+
collections_config["drafts"] = { "output" => !!@site.show_drafts }
|
117
222
|
end
|
118
223
|
|
119
224
|
folders = add_category_folder_config(collections_config, collections_config["posts"])
|
@@ -137,6 +242,11 @@ module CloudCannonJekyll
|
|
137
242
|
File.open(dest, "w") { |file| file.write(file_content(filename, data)) }
|
138
243
|
@site.keep_files ||= []
|
139
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)
|
140
250
|
end
|
141
251
|
|
142
252
|
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.2
|
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
|