cloudcannon-jekyll 3.2.4 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +4 -0
- data/lib/cloudcannon-jekyll/generators/collections.rb +77 -31
- data/lib/cloudcannon-jekyll/logger.rb +4 -0
- data/lib/cloudcannon-jekyll/version.rb +1 -1
- data/script/test-all-versions +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c513d1410254af59fed1d369d9852c77b0aa59474cf374f538a6557e5d0445f3
|
4
|
+
data.tar.gz: bfdcbdf270b02d3ab9f5b8c869650f46c4f8eb06a73f30f821fbeb9611fe0480
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9dbf04c9447ce64b41394dfc7ed33924f089542506a054a46da581940efe44be5e2f7bca61014855dacb62efc46d86bdc3e9ac37e470f7c94f411aeec54bf05c
|
7
|
+
data.tar.gz: 9993038e810b3509f39aeadb41e77d2b29635481469c331daed39ce0154b5a8c2320fed85c301fc182088de93eb6a74b3f77eb5bd1c5ce574c65017567f4e811
|
data/HISTORY.md
CHANGED
@@ -24,8 +24,7 @@ module CloudCannonJekyll
|
|
24
24
|
|
25
25
|
def generate_collections_config
|
26
26
|
collections = @site.config['collections'] || {}
|
27
|
-
|
28
|
-
collections_config = input_collections_config.reject { |_, v| v == false }
|
27
|
+
collections_config = @config['collections_config'] || {}
|
29
28
|
|
30
29
|
return collections_config if @config['collections_config_override']
|
31
30
|
|
@@ -54,11 +53,9 @@ module CloudCannonJekyll
|
|
54
53
|
}
|
55
54
|
end
|
56
55
|
|
57
|
-
collection_keys = (defaults.keys + collections.keys).uniq
|
56
|
+
collection_keys = (collections_config.keys + defaults.keys + collections.keys).uniq
|
58
57
|
|
59
58
|
collection_keys.each do |key|
|
60
|
-
next if input_collections_config[key] == false
|
61
|
-
|
62
59
|
processed = (defaults[key] || {})
|
63
60
|
.merge(collections[key] || {})
|
64
61
|
.merge(collections_config[key] || {})
|
@@ -74,8 +71,6 @@ module CloudCannonJekyll
|
|
74
71
|
end
|
75
72
|
|
76
73
|
@split_posts.each_key do |key|
|
77
|
-
next if input_collections_config[key] == false
|
78
|
-
|
79
74
|
posts_path = @split_posts[key]&.first&.relative_path&.sub(%r{(^|/)_posts.*}, '\1_posts')
|
80
75
|
next unless posts_path
|
81
76
|
|
@@ -89,8 +84,6 @@ module CloudCannonJekyll
|
|
89
84
|
end
|
90
85
|
|
91
86
|
@split_drafts.each_key do |key|
|
92
|
-
next if input_collections_config[key] == false
|
93
|
-
|
94
87
|
drafts_path = @split_drafts[key]&.first&.relative_path&.sub(%r{(^|/)_drafts.*}, '\1_drafts')
|
95
88
|
next unless drafts_path
|
96
89
|
|
@@ -114,33 +107,53 @@ module CloudCannonJekyll
|
|
114
107
|
paths.empty? ? [File.join('/', @collections_dir, '_drafts')] : paths
|
115
108
|
end
|
116
109
|
|
110
|
+
def each_document(&block)
|
111
|
+
@site.pages.each(&block)
|
112
|
+
@site.static_files.each(&block)
|
113
|
+
@site.collections.each_value { |coll| coll.docs.each(&block) }
|
114
|
+
all_drafts.each(&block)
|
115
|
+
|
116
|
+
# Jekyll 2.x.x doesn't have posts in site.collections
|
117
|
+
all_posts.each(&block) if IS_JEKYLL_2_X_X
|
118
|
+
end
|
119
|
+
|
117
120
|
def generate_collections(collections_config)
|
121
|
+
assigned_pages = {}
|
118
122
|
collections = {}
|
119
123
|
|
120
|
-
|
121
|
-
|
124
|
+
path_map = collections_config_path_map(collections_config)
|
125
|
+
|
126
|
+
each_document do |doc|
|
127
|
+
next unless allowed_document?(doc)
|
128
|
+
|
129
|
+
key = document_collection_key(doc, path_map)
|
130
|
+
|
131
|
+
unless key
|
132
|
+
Logger.warn "⚠️ No collection for #{doc.relative_path.bold}"
|
133
|
+
next
|
134
|
+
end
|
135
|
+
|
136
|
+
if collections_config.dig(key, 'parser') == false
|
137
|
+
Logger.warn "⚠️ Ignoring #{doc.relative_path.bold} in #{key.bold} collection"
|
138
|
+
next
|
139
|
+
end
|
122
140
|
|
123
141
|
collections[key] ||= []
|
142
|
+
collections[key].push(document_to_json(doc, key))
|
124
143
|
|
125
|
-
|
144
|
+
assigned_pages[doc.relative_path] = true if doc.instance_of?(Jekyll::Page)
|
145
|
+
end
|
126
146
|
|
127
|
-
|
128
|
-
|
129
|
-
elsif key == 'drafts' || key.end_with?('/drafts')
|
130
|
-
@split_drafts[key]
|
131
|
-
else
|
132
|
-
@site.collections[key]&.docs
|
133
|
-
end
|
147
|
+
collections_config.each_key do |key|
|
148
|
+
next if key == 'data'
|
134
149
|
|
135
150
|
collections[key] ||= []
|
136
|
-
collections[key] = collections[key].map do |doc|
|
137
|
-
document_to_json(doc, key)
|
138
|
-
end
|
139
151
|
end
|
140
152
|
|
141
153
|
if collections.key?('pages') && collections['pages'].empty?
|
142
|
-
|
143
|
-
|
154
|
+
all_pages.each do |page|
|
155
|
+
assigned = assigned_pages[page.relative_path]
|
156
|
+
collections['pages'].push(document_to_json(page, 'pages')) unless assigned
|
144
157
|
end
|
145
158
|
end
|
146
159
|
|
@@ -152,7 +165,7 @@ module CloudCannonJekyll
|
|
152
165
|
should_delete = if key == 'data'
|
153
166
|
!data_files?
|
154
167
|
else
|
155
|
-
collections[key]
|
168
|
+
collections[key]&.empty? && collection_config['auto_discovered']
|
156
169
|
end
|
157
170
|
|
158
171
|
if should_delete
|
@@ -177,6 +190,27 @@ module CloudCannonJekyll
|
|
177
190
|
end
|
178
191
|
end
|
179
192
|
|
193
|
+
def collections_config_path_map(collections_config)
|
194
|
+
unsorted = collections_config.map do |key, collection_config|
|
195
|
+
{
|
196
|
+
key: key,
|
197
|
+
path: "/#{collection_config['path']}/".sub(%r{/+}, '/')
|
198
|
+
}
|
199
|
+
end
|
200
|
+
|
201
|
+
unsorted.sort_by { |pair| pair[:path].length }.reverse
|
202
|
+
end
|
203
|
+
|
204
|
+
def document_collection_key(doc, path_map)
|
205
|
+
path = "/#{File.join(@collections_dir, doc.relative_path)}/".sub(%r{/+}, '/')
|
206
|
+
|
207
|
+
collection_path_pair = path_map.find do |pair|
|
208
|
+
path.start_with? pair[:path]
|
209
|
+
end
|
210
|
+
|
211
|
+
collection_path_pair[:key] if collection_path_pair
|
212
|
+
end
|
213
|
+
|
180
214
|
def legacy_document_data(doc)
|
181
215
|
legacy_data = {}
|
182
216
|
legacy_data['categories'] = doc.categories if doc.respond_to?(:categories)
|
@@ -247,15 +281,27 @@ module CloudCannonJekyll
|
|
247
281
|
end
|
248
282
|
|
249
283
|
def all_pages
|
250
|
-
|
251
|
-
|
252
|
-
|
284
|
+
pages = @site.pages.select { |doc| allowed_page?(doc) }
|
285
|
+
static_pages = @site.static_files.select { |doc| allowed_static_file?(doc) }
|
286
|
+
pages + static_pages
|
287
|
+
end
|
253
288
|
|
254
|
-
|
255
|
-
|
289
|
+
def allowed_document?(doc)
|
290
|
+
if doc.instance_of?(Jekyll::Page)
|
291
|
+
allowed_page?(doc)
|
292
|
+
elsif doc.instance_of?(Jekyll::StaticFile)
|
293
|
+
allowed_static_file?(doc)
|
294
|
+
else
|
295
|
+
true
|
256
296
|
end
|
297
|
+
end
|
298
|
+
|
299
|
+
def allowed_page?(page)
|
300
|
+
page.html? || page.url.end_with?('/')
|
301
|
+
end
|
257
302
|
|
258
|
-
|
303
|
+
def allowed_static_file?(static_file)
|
304
|
+
STATIC_EXTENSIONS.include?(static_file.extname)
|
259
305
|
end
|
260
306
|
|
261
307
|
def data_files?
|
data/script/test-all-versions
CHANGED
@@ -6,5 +6,5 @@ JEKYLL_VERSION=2.4.0 bundle update && $(dirname "$0")/test &&
|
|
6
6
|
JEKYLL_VERSION=3.0.0 bundle update && $(dirname "$0")/test &&
|
7
7
|
JEKYLL_VERSION=3.3.1 bundle update && $(dirname "$0")/test &&
|
8
8
|
JEKYLL_VERSION=3.8.5 bundle update && $(dirname "$0")/test &&
|
9
|
-
JEKYLL_VERSION=4.
|
9
|
+
JEKYLL_VERSION=4.3.1 bundle update && $(dirname "$0")/test
|
10
10
|
|
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:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CloudCannon
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -105,7 +105,7 @@ homepage: https://github.com/cloudcannon/cloudcannon-jekyll
|
|
105
105
|
licenses:
|
106
106
|
- MIT
|
107
107
|
metadata: {}
|
108
|
-
post_install_message:
|
108
|
+
post_install_message:
|
109
109
|
rdoc_options: []
|
110
110
|
require_paths:
|
111
111
|
- lib
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
123
|
rubygems_version: 3.1.6
|
124
|
-
signing_key:
|
124
|
+
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: CloudCannon Jekyll integration
|
127
127
|
test_files: []
|