cloudcannon-jekyll 2.0.2 → 2.3.1
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 +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/jsonify-filter.rb +1 -1
- 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: 00114b22694d4a9d0f1de2f1e44a8e893c0184d5d0a9ec2e644d8115d30c3a83
|
4
|
+
data.tar.gz: 58acfeb5af57f993c0d8340722b9b45fe650062c7189c7b82f7b11841070b07b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fb1598701caa1dd4b0fc667ec2c5c5bfb6674806126a78b4905b1c680bdad689e11ce5e82880dc06246d50e73037a5d0de125d5e70bfba2d0d0bbde0d4536df
|
7
|
+
data.tar.gz: 63efb6ab686f4b62f9eae28d5fb2c146228dd6a147ad00030975407e7500de38af808fdeef79dccab4cbfbe823c5261fc5c472d1a543a09f15376dc7d5efd848
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
# 2.3.1
|
2
|
+
|
3
|
+
* Fix issue where pages config overwrites default
|
4
|
+
* Fix issue when a site has no pages
|
5
|
+
|
6
|
+
# 2.3.0
|
7
|
+
|
8
|
+
* Fix output for drafts collection config
|
9
|
+
* Update schema version
|
10
|
+
* fix parsing for category folders
|
11
|
+
* Add logging
|
12
|
+
|
13
|
+
# 2.2.0
|
14
|
+
|
15
|
+
* Move data logic out of template
|
16
|
+
* Auto-populate categories and tags in data
|
17
|
+
|
18
|
+
# 2.1.0
|
19
|
+
|
20
|
+
* Add `_instance_values` to global scope
|
21
|
+
|
1
22
|
# 2.0.2
|
2
23
|
|
3
24
|
* Add `_enabled_editors` 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 %}
|
@@ -39,6 +32,9 @@
|
|
39
32
|
{% if config._enabled_editors %}
|
40
33
|
"_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
|
41
34
|
{% endif %}
|
35
|
+
{% if config._instance_values %}
|
36
|
+
"_instance_values": {{ config._instance_values | cc_jsonify }},
|
37
|
+
{% endif %}
|
42
38
|
{% if config._options %}
|
43
39
|
"_options": {{ config._options | cc_jsonify }},
|
44
40
|
{% endif %}
|
@@ -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,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 %}
|
@@ -38,6 +32,9 @@
|
|
38
32
|
{% if config._enabled_editors %}
|
39
33
|
"_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
|
40
34
|
{% endif %}
|
35
|
+
{% if config._instance_values %}
|
36
|
+
"_instance_values": {{ config._instance_values | cc_jsonify }},
|
37
|
+
{% endif %}
|
41
38
|
{% if config._options %}
|
42
39
|
"_options": {{ config._options | cc_jsonify }},
|
43
40
|
{% endif %}
|
@@ -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,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 %}
|
@@ -51,6 +35,9 @@
|
|
51
35
|
{% if config._enabled_editors -%}
|
52
36
|
"_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
|
53
37
|
{%- endif %}
|
38
|
+
{% if config._instance_values -%}
|
39
|
+
"_instance_values": {{ config._instance_values | cc_jsonify }},
|
40
|
+
{%- endif %}
|
54
41
|
{% if config._options -%}
|
55
42
|
"_options": {{ config._options | cc_jsonify }},
|
56
43
|
{%- endif %}
|
@@ -70,11 +57,10 @@
|
|
70
57
|
},
|
71
58
|
{%- endif %}
|
72
59
|
"paths": {
|
60
|
+
"static": "",
|
73
61
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
74
62
|
"data": {{ config.data_dir | cc_jsonify }},
|
75
|
-
"pages": "",
|
76
63
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
77
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
78
64
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
79
65
|
},
|
80
66
|
{% 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
|
@@ -150,7 +150,7 @@ module CloudCannonJekyll
|
|
150
150
|
baseurl show_dir_listing permalink paginate_path timezone quiet verbose defaults
|
151
151
|
liquid kramdown title url description uploads_dir _comments _options _editor
|
152
152
|
_explore _source_editor _array_structures maruku redcloth rdiscount redcarpet
|
153
|
-
gems plugins cloudcannon _collection_groups _enabled_editors)
|
153
|
+
gems plugins cloudcannon _collection_groups _enabled_editors _instance_values)
|
154
154
|
|
155
155
|
out = input.map do |key, value|
|
156
156
|
next unless value.is_a?(Array) || value.is_a?(Hash)
|
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.1
|
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-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|