cloudcannon-jekyll 2.0.1 → 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 +22 -0
- data/README.md +7 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/info-2.x.json +11 -13
- data/lib/cloudcannon-jekyll/_cloudcannon/info-3.0-4.x.json +11 -12
- data/lib/cloudcannon-jekyll/_cloudcannon/info.json +13 -24
- data/lib/cloudcannon-jekyll/generator.rb +125 -20
- data/lib/cloudcannon-jekyll/jsonify-filter.rb +11 -28
- 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,25 @@
|
|
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
|
+
|
13
|
+
# 2.1.0
|
14
|
+
|
15
|
+
* Add `_instance_values` to global scope
|
16
|
+
|
17
|
+
# 2.0.2
|
18
|
+
|
19
|
+
* Add `_enabled_editors` to global scope
|
20
|
+
* Increase max jsonify depth
|
21
|
+
* Remove unused key swaps
|
22
|
+
|
1
23
|
# 2.0.1
|
2
24
|
|
3
25
|
* Fix potential for null keys in cc_jsonify filter
|
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
|
|
@@ -17,25 +17,24 @@
|
|
17
17
|
{% if config.timezone %}
|
18
18
|
"timezone": {{ config.timezone | cc_jsonify }},
|
19
19
|
{% endif %}
|
20
|
-
"collections-config": {{ collections_config | cc_jsonify
|
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 %}
|
36
29
|
{% if config._comments %}
|
37
30
|
"_comments": {{ config._comments | cc_jsonify }},
|
38
31
|
{% endif %}
|
32
|
+
{% if config._enabled_editors %}
|
33
|
+
"_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
|
34
|
+
{% endif %}
|
35
|
+
{% if config._instance_values %}
|
36
|
+
"_instance_values": {{ config._instance_values | cc_jsonify }},
|
37
|
+
{% endif %}
|
39
38
|
{% if config._options %}
|
40
39
|
"_options": {{ config._options | cc_jsonify }},
|
41
40
|
{% endif %}
|
@@ -55,15 +54,14 @@
|
|
55
54
|
},
|
56
55
|
{% endif %}
|
57
56
|
"paths": {
|
57
|
+
"static": "",
|
58
58
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
59
59
|
"data": {{ config.data_dir | cc_jsonify }},
|
60
|
-
"pages": "",
|
61
60
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
62
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
63
61
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
64
62
|
},
|
65
63
|
{% if config._array_structures %}
|
66
|
-
"_array_structures": {{ config._array_structures | cc_jsonify:
|
64
|
+
"_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
|
67
65
|
{% endif %}
|
68
66
|
{% assign select_data = config | cc_select_data_jsonify %}
|
69
67
|
{% if select_data %}
|
@@ -17,24 +17,24 @@
|
|
17
17
|
{% if config.timezone %}
|
18
18
|
"timezone": {{ config.timezone | cc_jsonify }},
|
19
19
|
{% endif %}
|
20
|
-
"collections-config": {{ collections_config | cc_jsonify
|
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 %}
|
35
29
|
{% if config._comments %}
|
36
30
|
"_comments": {{ config._comments | cc_jsonify }},
|
37
31
|
{% endif %}
|
32
|
+
{% if config._enabled_editors %}
|
33
|
+
"_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
|
34
|
+
{% endif %}
|
35
|
+
{% if config._instance_values %}
|
36
|
+
"_instance_values": {{ config._instance_values | cc_jsonify }},
|
37
|
+
{% endif %}
|
38
38
|
{% if config._options %}
|
39
39
|
"_options": {{ config._options | cc_jsonify }},
|
40
40
|
{% endif %}
|
@@ -54,15 +54,14 @@
|
|
54
54
|
},
|
55
55
|
{% endif %}
|
56
56
|
"paths": {
|
57
|
+
"static": "",
|
57
58
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
58
59
|
"data": {{ config.data_dir | cc_jsonify }},
|
59
|
-
"pages": "",
|
60
60
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
61
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
62
61
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
63
62
|
},
|
64
63
|
{% if config._array_structures %}
|
65
|
-
"_array_structures": {{ config._array_structures | cc_jsonify:
|
64
|
+
"_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
|
66
65
|
{% endif %}
|
67
66
|
{% assign select_data = config | cc_select_data_jsonify %}
|
68
67
|
{% if select_data %}
|
@@ -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 }}
|
@@ -17,37 +18,26 @@
|
|
17
18
|
{% if config.timezone -%}
|
18
19
|
"timezone": {{ config.timezone | cc_jsonify }},
|
19
20
|
{%- endif %}
|
20
|
-
"collections-config": {{ collections_config | cc_jsonify
|
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 %}
|
48
32
|
{% if config._comments -%}
|
49
33
|
"_comments": {{ config._comments | cc_jsonify }},
|
50
34
|
{%- endif %}
|
35
|
+
{% if config._enabled_editors -%}
|
36
|
+
"_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
|
37
|
+
{%- endif %}
|
38
|
+
{% if config._instance_values -%}
|
39
|
+
"_instance_values": {{ config._instance_values | cc_jsonify }},
|
40
|
+
{%- endif %}
|
51
41
|
{% if config._options -%}
|
52
42
|
"_options": {{ config._options | cc_jsonify }},
|
53
43
|
{%- endif %}
|
@@ -67,15 +57,14 @@
|
|
67
57
|
},
|
68
58
|
{%- endif %}
|
69
59
|
"paths": {
|
60
|
+
"static": "",
|
70
61
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
71
62
|
"data": {{ config.data_dir | cc_jsonify }},
|
72
|
-
"pages": "",
|
73
63
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
74
|
-
"includes": {{ config.includes_dir | cc_jsonify }},
|
75
64
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
76
65
|
},
|
77
66
|
{% if config._array_structures -%}
|
78
|
-
"_array_structures": {{ config._array_structures | cc_jsonify:
|
67
|
+
"_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
|
79
68
|
{%- endif %}
|
80
69
|
{% assign select_data = config | cc_select_data_jsonify -%}
|
81
70
|
{% if select_data -%}
|
@@ -13,40 +13,110 @@ 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
|
-
def
|
47
|
+
def generate_collections_config(pages)
|
40
48
|
collections = @site.config["collections"]&.dup || {}
|
41
|
-
|
49
|
+
collections_config = @site.config.dig("cloudcannon", "collections")&.dup || {}
|
42
50
|
|
43
51
|
collections.each_key do |key|
|
44
52
|
# Workaround for empty collection configurations
|
45
53
|
defaults = collections[key] || { "output" => false }
|
46
|
-
|
54
|
+
collections_config[key] = (collections_config[key] || {}).merge(defaults)
|
55
|
+
end
|
56
|
+
|
57
|
+
unless pages.empty?
|
58
|
+
collections_config["pages"] ||= {
|
59
|
+
"output" => true,
|
60
|
+
"filter" => "strict",
|
61
|
+
"path" => "",
|
62
|
+
}
|
47
63
|
end
|
48
64
|
|
49
|
-
|
65
|
+
collections_config
|
66
|
+
end
|
67
|
+
|
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
|
85
|
+
|
86
|
+
collections["pages"] = pages if collections["pages"].empty? && !pages.empty?
|
87
|
+
collections
|
88
|
+
end
|
89
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
90
|
+
|
91
|
+
def generate_data
|
92
|
+
cc_data = @site.config.dig("cloudcannon", "data")
|
93
|
+
data = if cc_data == true
|
94
|
+
@site.data&.dup
|
95
|
+
elsif cc_data&.is_a?(Hash)
|
96
|
+
@site.data&.select { |key, _| cc_data.key?(key) }
|
97
|
+
end
|
98
|
+
|
99
|
+
data ||= {}
|
100
|
+
data["categories"] ||= @site.categories.keys
|
101
|
+
data["tags"] ||= @site.tags.keys
|
102
|
+
|
103
|
+
data.each_key do |key|
|
104
|
+
log "💾 Processed #{key.bold} data set"
|
105
|
+
end
|
106
|
+
|
107
|
+
data
|
108
|
+
end
|
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
|
50
120
|
end
|
51
121
|
|
52
122
|
def collections_dir
|
@@ -59,13 +129,27 @@ module CloudCannonJekyll
|
|
59
129
|
@site.config["data_dir"] || "_data"
|
60
130
|
end
|
61
131
|
|
62
|
-
|
63
|
-
def add_category_folder_config(collections_config, posts_config = {})
|
132
|
+
def all_posts
|
64
133
|
posts = @site.posts || @site.collections["posts"]
|
65
|
-
|
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 = {})
|
66
150
|
seen = {}
|
67
151
|
|
68
|
-
|
152
|
+
all_posts.map do |post|
|
69
153
|
parts = post.relative_path.split("/_posts/")
|
70
154
|
path = parts.first
|
71
155
|
|
@@ -92,7 +176,23 @@ module CloudCannonJekyll
|
|
92
176
|
path
|
93
177
|
end
|
94
178
|
end
|
95
|
-
|
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
|
96
196
|
|
97
197
|
# Support for the deprecated _explore configuration
|
98
198
|
def add_legacy_explore_groups
|
@@ -112,8 +212,8 @@ module CloudCannonJekyll
|
|
112
212
|
collections_config["posts"] = { "output" => true } if Jekyll::VERSION.start_with? "2."
|
113
213
|
drafts = @reader.read_drafts(collections_dir)
|
114
214
|
|
115
|
-
if drafts.any?
|
116
|
-
collections_config["drafts"] = {}
|
215
|
+
if drafts.any? && !collections_config.key?("drafts")
|
216
|
+
collections_config["drafts"] = { "output" => !!@site.show_drafts }
|
117
217
|
end
|
118
218
|
|
119
219
|
folders = add_category_folder_config(collections_config, collections_config["posts"])
|
@@ -137,6 +237,11 @@ module CloudCannonJekyll
|
|
137
237
|
File.open(dest, "w") { |file| file.write(file_content(filename, data)) }
|
138
238
|
@site.keep_files ||= []
|
139
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)
|
140
245
|
end
|
141
246
|
|
142
247
|
def version_path_suffix
|
@@ -7,19 +7,6 @@ module CloudCannonJekyll
|
|
7
7
|
module JsonifyFilter
|
8
8
|
STATIC_EXTENSIONS = [".html", ".htm"].freeze
|
9
9
|
|
10
|
-
CC_JSONIFY_KEY_SWAPS = {
|
11
|
-
"collections" => {
|
12
|
-
"_sort_key" => "_sort-key",
|
13
|
-
"_subtext_key" => "_subtext-key",
|
14
|
-
"_image_key" => "_image-key",
|
15
|
-
"_image_size" => "_image-size",
|
16
|
-
"_singular_name" => "_singular-name",
|
17
|
-
"_singular_key" => "_singular-key",
|
18
|
-
"_disable_add" => "_disable-add",
|
19
|
-
"_add_options" => "_add-options",
|
20
|
-
},
|
21
|
-
}.freeze
|
22
|
-
|
23
10
|
@simple_types = [
|
24
11
|
String,
|
25
12
|
Numeric,
|
@@ -137,19 +124,19 @@ module CloudCannonJekyll
|
|
137
124
|
"{#{out.join(",")}}"
|
138
125
|
end
|
139
126
|
|
140
|
-
def self.array_to_json(input, depth, max_depth
|
127
|
+
def self.array_to_json(input, depth, max_depth)
|
141
128
|
array = input.map do |value|
|
142
|
-
JsonifyFilter.to_json(value, depth, max_depth
|
129
|
+
JsonifyFilter.to_json(value, depth, max_depth)
|
143
130
|
end
|
144
131
|
|
145
132
|
"[#{array.join(",")}]"
|
146
133
|
end
|
147
134
|
|
148
|
-
def self.hash_to_json(input, depth, max_depth
|
135
|
+
def self.hash_to_json(input, depth, max_depth)
|
149
136
|
out = input.map do |key, value|
|
150
137
|
next_max_depth = key == "_array_structures" ? 20 : max_depth
|
151
|
-
string_key =
|
152
|
-
"#{string_key}: #{JsonifyFilter.to_json(value, depth, next_max_depth
|
138
|
+
string_key = key.to_s.to_json
|
139
|
+
"#{string_key}: #{JsonifyFilter.to_json(value, depth, next_max_depth)}"
|
153
140
|
end
|
154
141
|
|
155
142
|
"{#{out.join(",")}}"
|
@@ -163,7 +150,7 @@ module CloudCannonJekyll
|
|
163
150
|
baseurl show_dir_listing permalink paginate_path timezone quiet verbose defaults
|
164
151
|
liquid kramdown title url description uploads_dir _comments _options _editor
|
165
152
|
_explore _source_editor _array_structures maruku redcloth rdiscount redcarpet
|
166
|
-
gems plugins cloudcannon _collection_groups)
|
153
|
+
gems plugins cloudcannon _collection_groups _enabled_editors _instance_values)
|
167
154
|
|
168
155
|
out = input.map do |key, value|
|
169
156
|
next unless value.is_a?(Array) || value.is_a?(Hash)
|
@@ -178,7 +165,7 @@ module CloudCannonJekyll
|
|
178
165
|
"{#{out.join(",")}}" if out.any?
|
179
166
|
end
|
180
167
|
|
181
|
-
def self.to_json(input, depth, max_depth =
|
168
|
+
def self.to_json(input, depth, max_depth = 12)
|
182
169
|
depth += 1
|
183
170
|
|
184
171
|
if depth > max_depth || (depth > 3 && JsonifyFilter.document_type?(input))
|
@@ -194,9 +181,9 @@ module CloudCannonJekyll
|
|
194
181
|
elsif input.is_a?(Jekyll::Document)
|
195
182
|
JsonifyFilter.document_to_json(input, depth, max_depth)
|
196
183
|
elsif input.is_a?(Array)
|
197
|
-
JsonifyFilter.array_to_json(input, depth, max_depth
|
184
|
+
JsonifyFilter.array_to_json(input, depth, max_depth)
|
198
185
|
elsif input.is_a?(Hash)
|
199
|
-
JsonifyFilter.hash_to_json(input, depth, max_depth
|
186
|
+
JsonifyFilter.hash_to_json(input, depth, max_depth)
|
200
187
|
else
|
201
188
|
input.class.to_s.prepend("UNSUPPORTED:").to_json
|
202
189
|
end
|
@@ -220,12 +207,8 @@ module CloudCannonJekyll
|
|
220
207
|
end
|
221
208
|
end
|
222
209
|
|
223
|
-
def cc_jsonify(input,
|
224
|
-
|
225
|
-
JsonifyFilter.to_json(input, 0, max_depth, CC_JSONIFY_KEY_SWAPS[key_swaps_key])
|
226
|
-
else
|
227
|
-
JsonifyFilter.to_json(input, 0, max_depth)
|
228
|
-
end
|
210
|
+
def cc_jsonify(input, max_depth = 12)
|
211
|
+
JsonifyFilter.to_json(input, 0, max_depth)
|
229
212
|
end
|
230
213
|
end
|
231
214
|
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.0
|
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-07
|
11
|
+
date: 2021-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|