cloudcannon-jekyll 1.6.1 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a266498a3b883dfc9855310c042b181cef8b0949feab77d8918e345e9c72fe68
4
- data.tar.gz: d4884d8ca59e5cddb15e395fc9c058667e28c82fbd25b953b8cae4feaace2b82
3
+ metadata.gz: 400439f9c6fb804aca466171d82c98d2b9925547ea3b4e2b0d08eafe92b3c8dd
4
+ data.tar.gz: 5867df83dfb8e2adecb88812e285db78582be51b52f7809a25931e8cd7bdc815
5
5
  SHA512:
6
- metadata.gz: 43d10a91998d62ff91e67935912d752415212cf3c6162731c761af6fcf1a4af967b51a3f711c815a8b8a3c8a5407818fd927ec7cd6444561a3efa6d2171f5bc9
7
- data.tar.gz: 23b4eae55f04f524c949856a264818548159567c3b121f892ee86776fe582cf7d9817e646222ea7a68a6ff2fbd88749435b260951d8cd26bb0384997cdcd5de7
6
+ metadata.gz: 7caed857729fb823104ffad2a2e6229dd9009a5522eb13a945d2bb3fee43cad093547740ba862d98749da7a3686f520f0e738786b220e2243ebbe61e551fb725
7
+ data.tar.gz: 5036b4de220e4624312952d2c67b27ed77784ef74c4f3e36baee1367f5dc8251854a3529c4c9e80655406c9fe65b8e682782d137e52f649e2f8d0dbcc474a2e8
data/.travis.yml CHANGED
@@ -16,4 +16,4 @@ env:
16
16
  - JEKYLL_VERSION="2.4.0"
17
17
  - JEKYLL_VERSION="3.0.0"
18
18
  - JEKYLL_VERSION="3.8.5"
19
- - JEKYLL_VERSION="4.1.1"
19
+ - JEKYLL_VERSION="4.2.0"
data/HISTORY.md CHANGED
@@ -1,3 +1,22 @@
1
+ # 2.1.0
2
+
3
+ * Add `_instance_values` to global scope
4
+
5
+ # 2.0.2
6
+
7
+ * Add `_enabled_editors` to global scope
8
+ * Increase max jsonify depth
9
+ * Remove unused key swaps
10
+
11
+ # 2.0.1
12
+
13
+ * Fix potential for null keys in cc_jsonify filter
14
+
15
+ # 2.0.0
16
+
17
+ * Rename a number of top level configuration keys to match source keys
18
+ * Combine `details.json` and `config.json` into `info.json`
19
+
1
20
  # 1.6.1
2
21
 
3
22
  * Increase max depth for array structures defined outside of global
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A Jekyll plugin to create CloudCannon editor details.
4
4
 
5
- [![Build Status](https://travis-ci.com/CloudCannon/cloudcannon-jekyll.svg?branch=master)](https://travis-ci.com/CloudCannon/cloudcannon-jekyll) [![Gem Version](https://badge.fury.io/rb/cloudcannon-jekyll.svg)](https://badge.fury.io/rb/cloudcannon-jekyll)
5
+ [![Build Status](https://travis-ci.com/CloudCannon/cloudcannon-jekyll.svg?branch=main)](https://travis-ci.com/CloudCannon/cloudcannon-jekyll) [![Gem Version](https://badge.fury.io/rb/cloudcannon-jekyll.svg)](https://badge.fury.io/rb/cloudcannon-jekyll)
6
6
 
7
7
  ## Usage
8
8
 
@@ -0,0 +1,82 @@
1
+ {
2
+ "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
+ "cloudcannon": {
4
+ "name": "cloudcannon-jekyll",
5
+ "version": {{ gem_version | cc_jsonify }}
6
+ },
7
+ "generator": {
8
+ "name": "jekyll",
9
+ "version": {{ jekyll.version | cc_jsonify }},
10
+ "environment": {{ jekyll.env | cc_jsonify }},
11
+ "metadata": {
12
+ "markdown": {{ site.markdown | cc_jsonify }},
13
+ "kramdown": {{ site.kramdown | cc_jsonify }},
14
+ "commonmark": {{ site.commonmark | cc_jsonify }}
15
+ }
16
+ },
17
+ {% if config.timezone %}
18
+ "timezone": {{ config.timezone | cc_jsonify }},
19
+ {% endif %}
20
+ "collections-config": {{ collections_config | cc_jsonify }},
21
+ "collections": {
22
+ "drafts": {{ drafts | cc_jsonify }},
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 %}
25
+ {% endfor %}
26
+ },
27
+ "pages": {{ site.html_pages | cc_jsonify }},
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 %}
33
+ {% if config.baseurl %}
34
+ "base-url": {{ config.baseurl | cc_jsonify }},
35
+ {% endif %}
36
+ {% if config._comments %}
37
+ "_comments": {{ config._comments | cc_jsonify }},
38
+ {% endif %}
39
+ {% if config._enabled_editors %}
40
+ "_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
41
+ {% endif %}
42
+ {% if config._instance_values %}
43
+ "_instance_values": {{ config._instance_values | cc_jsonify }},
44
+ {% endif %}
45
+ {% if config._options %}
46
+ "_options": {{ config._options | cc_jsonify }},
47
+ {% endif %}
48
+ {% if config._collection_groups %}
49
+ "_collection_groups": {{ config._collection_groups | cc_jsonify }},
50
+ {% endif %}
51
+ {% if config._editor %}
52
+ "_editor": {
53
+ "default_path": {{ config._editor.default_path | cc_jsonify }}
54
+ },
55
+ {% endif %}
56
+ {% if config._source_editor %}
57
+ "_source_editor": {
58
+ "tab_size": {{ config._source_editor.tab_size | cc_jsonify }},
59
+ "show_gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
60
+ "theme": {{ config._source_editor.theme | cc_jsonify }}
61
+ },
62
+ {% endif %}
63
+ "paths": {
64
+ "uploads": {{ config.uploads_dir | cc_jsonify }},
65
+ "data": {{ config.data_dir | cc_jsonify }},
66
+ "pages": "",
67
+ "collections": {{ config.collections_dir | cc_jsonify }},
68
+ "includes": {{ config.includes_dir | cc_jsonify }},
69
+ "layouts": {{ config.layouts_dir | cc_jsonify }}
70
+ },
71
+ {% if config._array_structures %}
72
+ "_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
73
+ {% endif %}
74
+ {% assign select_data = config | cc_select_data_jsonify %}
75
+ {% if select_data %}
76
+ "_select_data": {{ select_data }},
77
+ {% endif %}
78
+ {% if config.defaults %}
79
+ "defaults": {{ config.defaults | cc_jsonify }},
80
+ {% endif %}
81
+ "source": {{ config.source | replace: pwd, "" | cc_jsonify }}
82
+ }
@@ -0,0 +1,81 @@
1
+ {
2
+ "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
+ "cloudcannon": {
4
+ "name": "cloudcannon-jekyll",
5
+ "version": {{ gem_version | cc_jsonify }}
6
+ },
7
+ "generator": {
8
+ "name": "jekyll",
9
+ "version": {{ jekyll.version | cc_jsonify }},
10
+ "environment": {{ jekyll.env | cc_jsonify }},
11
+ "metadata": {
12
+ "markdown": {{ site.markdown | cc_jsonify }},
13
+ "kramdown": {{ site.kramdown | cc_jsonify }},
14
+ "commonmark": {{ site.commonmark | cc_jsonify }}
15
+ }
16
+ },
17
+ {% if config.timezone %}
18
+ "timezone": {{ config.timezone | cc_jsonify }},
19
+ {% endif %}
20
+ "collections-config": {{ collections_config | cc_jsonify }},
21
+ "collections": {
22
+ "drafts": {{ drafts | cc_jsonify }}{% if site.collections.size > 0 %},{% endif %}
23
+ {% for collection in site.collections %}"{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
24
+ {% endfor %}
25
+ },
26
+ "pages": {{ site.html_pages | cc_jsonify }},
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 %}
32
+ {% if config.baseurl %}
33
+ "base-url": {{ config.baseurl | cc_jsonify }},
34
+ {% endif %}
35
+ {% if config._comments %}
36
+ "_comments": {{ config._comments | cc_jsonify }},
37
+ {% endif %}
38
+ {% if config._enabled_editors %}
39
+ "_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
40
+ {% endif %}
41
+ {% if config._instance_values %}
42
+ "_instance_values": {{ config._instance_values | cc_jsonify }},
43
+ {% endif %}
44
+ {% if config._options %}
45
+ "_options": {{ config._options | cc_jsonify }},
46
+ {% endif %}
47
+ {% if config._collection_groups %}
48
+ "_collection_groups": {{ config._collection_groups | cc_jsonify }},
49
+ {% endif %}
50
+ {% if config._editor %}
51
+ "_editor": {
52
+ "default_path": {{ config._editor.default_path | cc_jsonify }}
53
+ },
54
+ {% endif %}
55
+ {% if config._source_editor %}
56
+ "_source_editor": {
57
+ "tab_size": {{ config._source_editor.tab_size | cc_jsonify }},
58
+ "show_gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
59
+ "theme": {{ config._source_editor.theme | cc_jsonify }}
60
+ },
61
+ {% endif %}
62
+ "paths": {
63
+ "uploads": {{ config.uploads_dir | cc_jsonify }},
64
+ "data": {{ config.data_dir | cc_jsonify }},
65
+ "pages": "",
66
+ "collections": {{ config.collections_dir | cc_jsonify }},
67
+ "includes": {{ config.includes_dir | cc_jsonify }},
68
+ "layouts": {{ config.layouts_dir | cc_jsonify }}
69
+ },
70
+ {% if config._array_structures %}
71
+ "_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
72
+ {% endif %}
73
+ {% assign select_data = config | cc_select_data_jsonify %}
74
+ {% if select_data %}
75
+ "_select_data": {{ select_data }},
76
+ {% endif %}
77
+ {% if config.defaults %}
78
+ "defaults": {{ config.defaults | cc_jsonify }},
79
+ {% endif %}
80
+ "source": {{ config.source | replace: pwd, "" | cc_jsonify }}
81
+ }
@@ -0,0 +1,94 @@
1
+ {
2
+ "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
+ "cloudcannon": {
4
+ "name": "cloudcannon-jekyll",
5
+ "version": {{ gem_version | cc_jsonify }}
6
+ },
7
+ "generator": {
8
+ "name": "jekyll",
9
+ "version": {{ jekyll.version | cc_jsonify }},
10
+ "environment": {{ jekyll.env | cc_jsonify }},
11
+ "metadata": {
12
+ "markdown": {{ site.markdown | cc_jsonify }},
13
+ "kramdown": {{ site.kramdown | cc_jsonify }},
14
+ "commonmark": {{ site.commonmark | cc_jsonify }}
15
+ }
16
+ },
17
+ {% if config.timezone -%}
18
+ "timezone": {{ config.timezone | cc_jsonify }},
19
+ {%- endif %}
20
+ "collections-config": {{ collections_config | cc_jsonify }},
21
+ "collections": {
22
+ "drafts": {{ drafts | cc_jsonify }}{% if site.collections.size > 0 %},{% endif %}
23
+ {%- for collection in site.collections -%}
24
+ "{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}
25
+ {%- unless forloop.last %},{% endunless %}
26
+ {%- endfor -%}
27
+ },
28
+ "pages": {{ site.html_pages | cc_jsonify }},
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 %}
45
+ {% if config.baseurl -%}
46
+ "base-url": {{ config.baseurl | cc_jsonify }},
47
+ {%- endif %}
48
+ {% if config._comments -%}
49
+ "_comments": {{ config._comments | cc_jsonify }},
50
+ {%- endif %}
51
+ {% if config._enabled_editors -%}
52
+ "_enabled_editors": {{ config._enabled_editors | cc_jsonify }},
53
+ {%- endif %}
54
+ {% if config._instance_values -%}
55
+ "_instance_values": {{ config._instance_values | cc_jsonify }},
56
+ {%- endif %}
57
+ {% if config._options -%}
58
+ "_options": {{ config._options | cc_jsonify }},
59
+ {%- endif %}
60
+ {% if config._collection_groups -%}
61
+ "_collection_groups": {{ config._collection_groups | cc_jsonify }},
62
+ {%- endif %}
63
+ {% if config._editor -%}
64
+ "_editor": {
65
+ "default_path": {{ config._editor.default_path | cc_jsonify }}
66
+ },
67
+ {%- endif %}
68
+ {% if config._source_editor -%}
69
+ "_source_editor": {
70
+ "tab_size": {{ config._source_editor.tab_size | cc_jsonify }},
71
+ "show_gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
72
+ "theme": {{ config._source_editor.theme | cc_jsonify }}
73
+ },
74
+ {%- endif %}
75
+ "paths": {
76
+ "uploads": {{ config.uploads_dir | cc_jsonify }},
77
+ "data": {{ config.data_dir | cc_jsonify }},
78
+ "pages": "",
79
+ "collections": {{ config.collections_dir | cc_jsonify }},
80
+ "includes": {{ config.includes_dir | cc_jsonify }},
81
+ "layouts": {{ config.layouts_dir | cc_jsonify }}
82
+ },
83
+ {% if config._array_structures -%}
84
+ "_array_structures": {{ config._array_structures | cc_jsonify: 50 }},
85
+ {%- endif %}
86
+ {% assign select_data = config | cc_select_data_jsonify -%}
87
+ {% if select_data -%}
88
+ "_select_data": {{ select_data }},
89
+ {%- endif %}
90
+ {% if config.defaults -%}
91
+ "defaults": {{ config.defaults | cc_jsonify }},
92
+ {%- endif %}
93
+ "source": {{ config.source | replace: pwd, "" | cc_jsonify }}
94
+ }
@@ -17,12 +17,7 @@ module CloudCannonJekyll
17
17
  @site = site
18
18
  @reader = Reader.new(@site)
19
19
 
20
- collections_config = @site.config["collections"]&.dup || {}
21
-
22
- # Workaround for empty collection configurations
23
- collections_config.each_key do |key|
24
- collections_config[key] ||= { "output" => false }
25
- end
20
+ collections_config = process_collections_config
26
21
 
27
22
  payload = @site.site_payload.merge({
28
23
  "gem_version" => CloudCannonJekyll::VERSION,
@@ -31,16 +26,27 @@ module CloudCannonJekyll
31
26
  drafts = add_blogging_config(collections_config)
32
27
  add_collection_paths(collections_config)
33
28
  add_data_config(collections_config)
29
+ add_legacy_explore_groups
34
30
 
35
- generate_file("config", payload.merge({
36
- "pwd" => Dir.pwd,
37
- "config" => @site.config,
38
- "collections" => collections_config,
31
+ generate_file("info", payload.merge({
32
+ "pwd" => Dir.pwd,
33
+ "config" => @site.config,
34
+ "collections_config" => collections_config,
35
+ "drafts" => drafts,
39
36
  }))
37
+ end
40
38
 
41
- generate_file("details", payload.merge({
42
- "drafts" => drafts,
43
- }))
39
+ def process_collections_config
40
+ collections = @site.config["collections"]&.dup || {}
41
+ cc_collections = @site.config.dig("cloudcannon", "collections")&.dup || {}
42
+
43
+ collections.each_key do |key|
44
+ # Workaround for empty collection configurations
45
+ defaults = collections[key] || { "output" => false }
46
+ cc_collections[key] = (cc_collections[key] || {}).merge(defaults)
47
+ end
48
+
49
+ cc_collections
44
50
  end
45
51
 
46
52
  def collections_dir
@@ -74,13 +80,13 @@ module CloudCannonJekyll
74
80
  collections_path = "#{collections_dir}/#{folder}".gsub(%r!\/+!, "/").sub(%r!^\/+!, "")
75
81
 
76
82
  collections_config["#{folder}/posts"] = posts_config.merge({
77
- "_path" => "#{collections_path}/_posts",
83
+ "path" => "#{collections_path}/_posts",
78
84
  })
79
85
 
80
86
  # Adding the category draft config like this isn't ideal, since you could have drafts
81
87
  # without posts, but it's a decent trade off vs looking for _drafts folders
82
88
  collections_config["#{folder}/drafts"] = posts_config.merge({
83
- "_path" => "#{collections_path}/_drafts",
89
+ "path" => "#{collections_path}/_drafts",
84
90
  })
85
91
 
86
92
  path
@@ -88,10 +94,17 @@ module CloudCannonJekyll
88
94
  end
89
95
  # rubocop:enable Metrics/AbcSize
90
96
 
97
+ # Support for the deprecated _explore configuration
98
+ def add_legacy_explore_groups
99
+ unless @site.config.key?("_collection_groups")
100
+ @site.config["_collection_groups"] = @site.config.dig("_explore", "groups")&.dup
101
+ end
102
+ end
103
+
91
104
  # Add data to collections config if raw data files exist
92
105
  def add_data_config(collections_config)
93
106
  data_files = @reader.read_data(data_dir)
94
- collections_config["data"] = { "_path" => data_dir } if data_files&.keys&.any?
107
+ collections_config["data"] = { "path" => data_dir } if data_files&.keys&.any?
95
108
  end
96
109
 
97
110
  # Add posts/drafts to collections config
@@ -99,7 +112,7 @@ module CloudCannonJekyll
99
112
  collections_config["posts"] = { "output" => true } if Jekyll::VERSION.start_with? "2."
100
113
  drafts = @reader.read_drafts(collections_dir)
101
114
 
102
- if (collections_config.key?("posts") && !collections_config.key?("drafts")) || drafts.any?
115
+ if drafts.any? || (collections_config.key?("posts") && !collections_config.key?("drafts"))
103
116
  collections_config["drafts"] = {}
104
117
  end
105
118
 
@@ -111,12 +124,10 @@ module CloudCannonJekyll
111
124
  drafts
112
125
  end
113
126
 
114
- # Add _path to each collection config
127
+ # Add path to each collection config
115
128
  def add_collection_paths(collections_config)
116
129
  collections_config.each do |key, collection|
117
- next if collection.key?("_path")
118
-
119
- collection["_path"] = File.join(collections_dir, "_#{key}").sub(%r!^\/+!, "")
130
+ collection["path"] ||= File.join(collections_dir, "_#{key}").sub(%r!^\/+!, "")
120
131
  end
121
132
  end
122
133
 
@@ -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,
@@ -60,7 +47,7 @@ module CloudCannonJekyll
60
47
  prevent += %w(content output next previous excerpt)
61
48
 
62
49
  out = data.map do |key, value|
63
- next if prevent.include? key
50
+ next if prevent.include?(key) || key.nil?
64
51
 
65
52
  prevent.push key
66
53
  next_max_depth = key == "_array_structures" ? 20 : max_depth
@@ -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, key_swaps = {})
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, key_swaps)
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, key_swaps = {})
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 = (key_swaps[key] || key).to_s.to_json
152
- "#{string_key}: #{JsonifyFilter.to_json(value, depth, next_max_depth, key_swaps)}"
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,11 +150,11 @@ 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)
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)
170
- next if prevent.include? key
157
+ next if prevent.include?(key) || key.nil?
171
158
 
172
159
  prevent.push key
173
160
  "#{key.to_s.to_json}: #{JsonifyFilter.to_json(value, depth)}"
@@ -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 = 9, key_swaps = {})
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, key_swaps)
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, key_swaps)
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, key_swaps_key = nil, max_depth = 8)
224
- if CC_JSONIFY_KEY_SWAPS.key? key_swaps_key
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CloudCannonJekyll
4
- VERSION = "1.6.1"
4
+ VERSION = "2.1.0"
5
5
  end
data/script/ci-smoke-test CHANGED
@@ -8,4 +8,4 @@ set -ex
8
8
  JEKYLL_VERSION=2.4.0 bundle update && $(dirname "$0")/test &&
9
9
  JEKYLL_VERSION=3.0.0 bundle update && $(dirname "$0")/test &&
10
10
  JEKYLL_VERSION=3.8.5 bundle update && $(dirname "$0")/test &&
11
- JEKYLL_VERSION=4.1.1 bundle update && $(dirname "$0")/test
11
+ JEKYLL_VERSION=4.2.0 bundle update && $(dirname "$0")/test
data/script/release CHANGED
@@ -11,10 +11,10 @@ cd $(dirname "$0")/..
11
11
  rm -rf cloudcannon-jekyll-*.gem
12
12
  gem build -q cloudcannon-jekyll.gemspec
13
13
 
14
- # Ensure we're on the master branch
14
+ # Ensure we're on the main branch
15
15
 
16
- (git branch | grep -q '* master') || {
17
- echo "Only release from the master branch."
16
+ (git branch | grep -q '* main') || {
17
+ echo "Only release from the main branch."
18
18
  exit 1
19
19
  }
20
20
 
@@ -34,6 +34,6 @@ git fetch -t origin
34
34
  # Push tag and upload new gem
35
35
 
36
36
  git tag "$tag" &&
37
- git push origin master &&
37
+ git push origin main &&
38
38
  git push origin "$tag" &&
39
39
  gem push cloudcannon-jekyll-*.gem
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: 1.6.1
4
+ version: 2.1.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-03-04 00:00:00.000000000 Z
11
+ date: 2021-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -120,12 +120,9 @@ files:
120
120
  - Rakefile
121
121
  - cloudcannon-jekyll.gemspec
122
122
  - lib/cloudcannon-jekyll.rb
123
- - lib/cloudcannon-jekyll/_cloudcannon/config-2.x.json
124
- - lib/cloudcannon-jekyll/_cloudcannon/config-3.0-4.x.json
125
- - lib/cloudcannon-jekyll/_cloudcannon/config.json
126
- - lib/cloudcannon-jekyll/_cloudcannon/details-2.x.json
127
- - lib/cloudcannon-jekyll/_cloudcannon/details-3.0-4.x.json
128
- - lib/cloudcannon-jekyll/_cloudcannon/details.json
123
+ - lib/cloudcannon-jekyll/_cloudcannon/info-2.x.json
124
+ - lib/cloudcannon-jekyll/_cloudcannon/info-3.0-4.x.json
125
+ - lib/cloudcannon-jekyll/_cloudcannon/info.json
129
126
  - lib/cloudcannon-jekyll/configuration.rb
130
127
  - lib/cloudcannon-jekyll/generator.rb
131
128
  - lib/cloudcannon-jekyll/jsonify-filter.rb
@@ -1,36 +0,0 @@
1
- {
2
- "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
- "cloudcannon": {
4
- "name": "cloudcannon-jekyll",
5
- "version": {{ gem_version | cc_jsonify }}
6
- },
7
- {% if config.timezone %}"timezone": {{ config.timezone | cc_jsonify }},{% endif %}
8
- "include": {{ config.include | cc_jsonify }},
9
- "exclude": {{ config.exclude | cc_jsonify }},
10
- {% if config.baseurl %}"base-url": {{ config.baseurl | cc_jsonify }},{% endif %}
11
- "collections": {{ collections | cc_jsonify: 'collections' }},
12
- {% if config._comments %}"comments": {{ config._comments | cc_jsonify }},{% endif %}
13
- {% if config._options %}"input-options": {{ config._options | cc_jsonify }},{% endif %}
14
- {% if config.defaults %}"defaults": {{ config.defaults | cc_jsonify }},{% endif %}
15
- {% if config._editor %}"editor": {
16
- "default-path": {{ config._editor.default_path | cc_jsonify }}
17
- },{% endif %}
18
- {% if config._source_editor %}"source-editor": {
19
- "tab-size": {{ config._source_editor.tab_size | cc_jsonify }},
20
- "show-gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
21
- "theme": {{ config._source_editor.theme | cc_jsonify }}
22
- },{% endif %}
23
- {% if config._explore %}"explore": {{ config._explore | cc_jsonify }},{% endif %}
24
- "paths": {
25
- "uploads": {{ config.uploads_dir | cc_jsonify }},
26
- "plugins": {{ config.plugins_dir | cc_jsonify }},
27
- "data": {{ config.data_dir | cc_jsonify }},
28
- "pages": "",
29
- "collections": {{ config.collections_dir | cc_jsonify }},
30
- "includes": {{ config.includes_dir | cc_jsonify }},
31
- "layouts": {{ config.layouts_dir | cc_jsonify }}
32
- },
33
- {% if config._array_structures %}"array-structures": {{ config._array_structures | cc_jsonify: nil, 20 }},{% endif %}
34
- {% assign select_data = config | cc_select_data_jsonify %}{% if select_data %}"select-data": {{ select_data }},{% endif %}
35
- "source": {{ config.source | replace: pwd, "" | cc_jsonify }}
36
- }
@@ -1,36 +0,0 @@
1
- {
2
- "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
- "cloudcannon": {
4
- "name": "cloudcannon-jekyll",
5
- "version": {{ gem_version | cc_jsonify }}
6
- },
7
- {% if config.timezone %}"timezone": {{ config.timezone | cc_jsonify }},{% endif %}
8
- "include": {{ config.include | cc_jsonify }},
9
- "exclude": {{ config.exclude | cc_jsonify }},
10
- {% if config.baseurl %}"base-url": {{ config.baseurl | cc_jsonify }},{% endif %}
11
- "collections": {{ collections | cc_jsonify: 'collections' }},
12
- {% if config._comments %}"comments": {{ config._comments | cc_jsonify }},{% endif %}
13
- {% if config._options %}"input-options": {{ config._options | cc_jsonify }},{% endif %}
14
- {% if config.defaults %}"defaults": {{ config.defaults | cc_jsonify }},{% endif %}
15
- {% if config._editor %}"editor": {
16
- "default-path": {{ config._editor.default_path | cc_jsonify }}
17
- },{% endif %}
18
- {% if config._source_editor %}"source-editor": {
19
- "tab-size": {{ config._source_editor.tab_size | cc_jsonify }},
20
- "show-gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
21
- "theme": {{ config._source_editor.theme | cc_jsonify }}
22
- },{% endif %}
23
- {% if config._explore %}"explore": {{ config._explore | cc_jsonify }},{% endif %}
24
- "paths": {
25
- "uploads": {{ config.uploads_dir | cc_jsonify }},
26
- "plugins": {{ config.plugins_dir | cc_jsonify }},
27
- "data": {{ config.data_dir | cc_jsonify }},
28
- "pages": "",
29
- "collections": {{ config.collections_dir | cc_jsonify }},
30
- "includes": {{ config.includes_dir | cc_jsonify }},
31
- "layouts": {{ config.layouts_dir | cc_jsonify }}
32
- },
33
- {% if config._array_structures %}"array-structures": {{ config._array_structures | cc_jsonify: nil, 20 }},{% endif %}
34
- {% assign select_data = config | cc_select_data_jsonify %}{% if select_data %}"select-data": {{ select_data }},{% endif %}
35
- "source": {{ config.source | replace: pwd, "" | cc_jsonify }}
36
- }
@@ -1,57 +0,0 @@
1
- {
2
- "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
- "cloudcannon": {
4
- "name": "cloudcannon-jekyll",
5
- "version": {{ gem_version | cc_jsonify }}
6
- },
7
- {% if config.timezone -%}
8
- "timezone": {{ config.timezone | cc_jsonify }},
9
- {%- endif %}
10
- "include": {{ config.include | cc_jsonify }},
11
- "exclude": {{ config.exclude | cc_jsonify }},
12
- {% if config.baseurl -%}
13
- "base-url": {{ config.baseurl | cc_jsonify }},
14
- {%- endif %}
15
- "collections": {{ collections | cc_jsonify: 'collections' }},
16
- {% if config._comments -%}
17
- "comments": {{ config._comments | cc_jsonify }},
18
- {%- endif %}
19
- {% if config._options -%}
20
- "input-options": {{ config._options | cc_jsonify }},
21
- {%- endif %}
22
- {% if config.defaults -%}
23
- "defaults": {{ config.defaults | cc_jsonify }},
24
- {%- endif %}
25
- {% if config._editor -%}
26
- "editor": {
27
- "default-path": {{ config._editor.default_path | cc_jsonify }}
28
- },
29
- {%- endif %}
30
- {% if config._source_editor -%}
31
- "source-editor": {
32
- "tab-size": {{ config._source_editor.tab_size | cc_jsonify }},
33
- "show-gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
34
- "theme": {{ config._source_editor.theme | cc_jsonify }}
35
- },
36
- {%- endif %}
37
- {% if config._explore -%}
38
- "explore": {{ config._explore | cc_jsonify }},
39
- {%- endif %}
40
- "paths": {
41
- "uploads": {{ config.uploads_dir | cc_jsonify }},
42
- "plugins": {{ config.plugins_dir | cc_jsonify }},
43
- "data": {{ config.data_dir | cc_jsonify }},
44
- "pages": "",
45
- "collections": {{ config.collections_dir | cc_jsonify }},
46
- "includes": {{ config.includes_dir | cc_jsonify }},
47
- "layouts": {{ config.layouts_dir | cc_jsonify }}
48
- },
49
- {% if config._array_structures -%}
50
- "array-structures": {{ config._array_structures | cc_jsonify: nil, 20 }},
51
- {%- endif %}
52
- {% assign select_data = config | cc_select_data_jsonify -%}
53
- {% if select_data -%}
54
- "select-data": {{ select_data }},
55
- {%- endif %}
56
- "source": {{ config.source | replace: pwd, "" | cc_jsonify }}
57
- }
@@ -1,28 +0,0 @@
1
- {
2
- "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
- "cloudcannon": {
4
- "name": "cloudcannon-jekyll",
5
- "version": {{ gem_version | cc_jsonify }}
6
- },
7
- "generator": {
8
- "name": "jekyll",
9
- "version": {{ jekyll.version | cc_jsonify }},
10
- "environment": {{ jekyll.env | cc_jsonify }},
11
- "metadata": {
12
- "markdown": {{ site.markdown | cc_jsonify }},
13
- "kramdown": {{ site.kramdown | cc_jsonify }},
14
- "commonmark": {{ site.commonmark | cc_jsonify }}
15
- }
16
- },{% if site.cloudcannon.data.first %}{% assign data_seen = false %}
17
- "data": {
18
- {% 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 %}},
19
- {% elsif site.cloudcannon.data %}"data": {{ site.data | cc_jsonify }},{% endif %}
20
- "collections": {
21
- "drafts": {{ drafts | cc_jsonify }},
22
- "posts": {{ site.posts | reverse | cc_jsonify }}{% if site.collections.size > 0 %},{% endif %}
23
- {% for collection in site.collections %}"{{ collection[0] | xml_escape }}": {{ collection[1].docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
24
- {% endfor %}
25
- },
26
- "pages": {{ site.html_pages | cc_jsonify }},
27
- "static-pages": {{ site.static_files | cc_static_files_jsonify }}
28
- }
@@ -1,27 +0,0 @@
1
- {
2
- "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
- "cloudcannon": {
4
- "name": "cloudcannon-jekyll",
5
- "version": {{ gem_version | cc_jsonify }}
6
- },
7
- "generator": {
8
- "name": "jekyll",
9
- "version": {{ jekyll.version | cc_jsonify }},
10
- "environment": {{ jekyll.env | cc_jsonify }},
11
- "metadata": {
12
- "markdown": {{ site.markdown | cc_jsonify }},
13
- "kramdown": {{ site.kramdown | cc_jsonify }},
14
- "commonmark": {{ site.commonmark | cc_jsonify }}
15
- }
16
- },{% if site.cloudcannon.data.first %}{% assign data_seen = false %}
17
- "data": {
18
- {% 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 %}},
19
- {% elsif site.cloudcannon.data %}"data": {{ site.data | cc_jsonify }},{% endif %}
20
- "collections": {
21
- "drafts": {{ drafts | cc_jsonify }}{% if site.collections.size > 0 %},{% endif %}
22
- {% for collection in site.collections %}"{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
23
- {% endfor %}
24
- },
25
- "pages": {{ site.html_pages | cc_jsonify }},
26
- "static-pages": {{ site.static_files | cc_static_files_jsonify }}
27
- }
@@ -1,41 +0,0 @@
1
- {
2
- "time": {{ site.time | date_to_xmlschema | cc_jsonify }},
3
- "cloudcannon": {
4
- "name": "cloudcannon-jekyll",
5
- "version": {{ gem_version | cc_jsonify }}
6
- },
7
- "generator": {
8
- "name": "jekyll",
9
- "version": {{ jekyll.version | cc_jsonify }},
10
- "environment": {{ jekyll.env | cc_jsonify }},
11
- "metadata": {
12
- "markdown": {{ site.markdown | cc_jsonify }},
13
- "kramdown": {{ site.kramdown | cc_jsonify }},
14
- "commonmark": {{ site.commonmark | cc_jsonify }}
15
- }
16
- },
17
- {% if site.cloudcannon.data.first -%}
18
- "data": {
19
- {%- assign data_seen = false %}
20
- {%- for data in site.data %}
21
- {%- assign key = data[0] %}
22
- {%- if site.cloudcannon.data[key] %}
23
- {%- if data_seen %},{% endif -%}
24
- {{ data[0] | cc_jsonify }}: {{ data[1] | cc_jsonify }}
25
- {%- assign data_seen = true %}
26
- {%- endif %}
27
- {%- endfor -%}
28
- },
29
- {% elsif site.cloudcannon.data -%}
30
- "data": {{ site.data | cc_jsonify }},
31
- {%- endif %}
32
- "collections": {
33
- "drafts": {{ drafts | cc_jsonify }}{% if site.collections.size > 0 %},{% endif %}
34
- {%- for collection in site.collections -%}
35
- "{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}
36
- {%- unless forloop.last %},{% endunless %}
37
- {%- endfor -%}
38
- },
39
- "pages": {{ site.html_pages | cc_jsonify }},
40
- "static-pages": {{ site.static_files | cc_static_files_jsonify }}
41
- }