cloudcannon-jekyll 3.2.4 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +8 -0
- data/lib/cloudcannon-jekyll/generators/collections.rb +88 -32
- 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: 7be8e0835f8eaa063ec3669eaf538951304a13e66173335c66ff8ef0de99fb9a
|
4
|
+
data.tar.gz: 4fb906e15c40bb8c63f678074e65f61a1d6557217e339d03b9610d01238f513e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8c195eaa6969fc92b4bb5a3d6439ba5b2f7d7d83cf68bea3286079deb2049bfb138c31180ac011be5acaadc3280482438cc4c7e3ef3917a1eadf838938b4643
|
7
|
+
data.tar.gz: ca5ddb63afde7d94efe7b3833010da1501031fe54b16167672fbf661fe6e40e3c9168f5214ae9a7df3d821bd03b39fa97320454b6d8a18f6bc1771439beb1069
|
data/HISTORY.md
CHANGED
@@ -22,10 +22,19 @@ module CloudCannonJekyll
|
|
22
22
|
@split_drafts = group_by_category_folder(all_drafts, 'drafts')
|
23
23
|
end
|
24
24
|
|
25
|
+
def generate_collections_config_path(key)
|
26
|
+
if key.end_with?("/posts")
|
27
|
+
File.join(@collections_dir, key.sub(/\/posts$/, "/_posts"))
|
28
|
+
elsif key.end_with?("/drafts")
|
29
|
+
File.join(@collections_dir, key.sub(/\/drafts$/, "/_drafts"))
|
30
|
+
else
|
31
|
+
File.join(@collections_dir, "_#{key}")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
25
35
|
def generate_collections_config
|
26
36
|
collections = @site.config['collections'] || {}
|
27
|
-
|
28
|
-
collections_config = input_collections_config.reject { |_, v| v == false }
|
37
|
+
collections_config = @config['collections_config'] || {}
|
29
38
|
|
30
39
|
return collections_config if @config['collections_config_override']
|
31
40
|
|
@@ -54,18 +63,16 @@ module CloudCannonJekyll
|
|
54
63
|
}
|
55
64
|
end
|
56
65
|
|
57
|
-
collection_keys = (defaults.keys + collections.keys).uniq
|
66
|
+
collection_keys = (collections_config.keys + defaults.keys + collections.keys).uniq
|
58
67
|
|
59
68
|
collection_keys.each do |key|
|
60
|
-
next if input_collections_config[key] == false
|
61
|
-
|
62
69
|
processed = (defaults[key] || {})
|
63
70
|
.merge(collections[key] || {})
|
64
71
|
.merge(collections_config[key] || {})
|
65
72
|
|
66
73
|
processed['output'] ||= false
|
67
74
|
processed['auto_discovered'] = !collections_config.key?(key)
|
68
|
-
processed['path'] ||=
|
75
|
+
processed['path'] ||= generate_collections_config_path(key)
|
69
76
|
processed['path'] = processed['path'].sub(%r{^/+}, '')
|
70
77
|
|
71
78
|
Config.rename_legacy_collection_config_keys(processed)
|
@@ -74,8 +81,6 @@ module CloudCannonJekyll
|
|
74
81
|
end
|
75
82
|
|
76
83
|
@split_posts.each_key do |key|
|
77
|
-
next if input_collections_config[key] == false
|
78
|
-
|
79
84
|
posts_path = @split_posts[key]&.first&.relative_path&.sub(%r{(^|/)_posts.*}, '\1_posts')
|
80
85
|
next unless posts_path
|
81
86
|
|
@@ -89,8 +94,6 @@ module CloudCannonJekyll
|
|
89
94
|
end
|
90
95
|
|
91
96
|
@split_drafts.each_key do |key|
|
92
|
-
next if input_collections_config[key] == false
|
93
|
-
|
94
97
|
drafts_path = @split_drafts[key]&.first&.relative_path&.sub(%r{(^|/)_drafts.*}, '\1_drafts')
|
95
98
|
next unless drafts_path
|
96
99
|
|
@@ -114,33 +117,53 @@ module CloudCannonJekyll
|
|
114
117
|
paths.empty? ? [File.join('/', @collections_dir, '_drafts')] : paths
|
115
118
|
end
|
116
119
|
|
120
|
+
def each_document(&block)
|
121
|
+
@site.pages.each(&block)
|
122
|
+
@site.static_files.each(&block)
|
123
|
+
@site.collections.each_value { |coll| coll.docs.each(&block) }
|
124
|
+
all_drafts.each(&block)
|
125
|
+
|
126
|
+
# Jekyll 2.x.x doesn't have posts in site.collections
|
127
|
+
all_posts.each(&block) if IS_JEKYLL_2_X_X
|
128
|
+
end
|
129
|
+
|
117
130
|
def generate_collections(collections_config)
|
131
|
+
assigned_pages = {}
|
118
132
|
collections = {}
|
119
133
|
|
120
|
-
|
121
|
-
|
134
|
+
path_map = collections_config_path_map(collections_config)
|
135
|
+
|
136
|
+
each_document do |doc|
|
137
|
+
next unless allowed_document?(doc)
|
138
|
+
|
139
|
+
key = document_collection_key(doc, path_map)
|
140
|
+
|
141
|
+
unless key
|
142
|
+
Logger.warn "⚠️ No collection for #{doc.relative_path.bold}"
|
143
|
+
next
|
144
|
+
end
|
145
|
+
|
146
|
+
if collections_config.dig(key, 'parser') == false
|
147
|
+
Logger.warn "⚠️ Ignoring #{doc.relative_path.bold} in #{key.bold} collection"
|
148
|
+
next
|
149
|
+
end
|
122
150
|
|
123
151
|
collections[key] ||= []
|
152
|
+
collections[key].push(document_to_json(doc, key))
|
124
153
|
|
125
|
-
|
154
|
+
assigned_pages[doc.relative_path] = true if doc.instance_of?(Jekyll::Page)
|
155
|
+
end
|
126
156
|
|
127
|
-
|
128
|
-
|
129
|
-
elsif key == 'drafts' || key.end_with?('/drafts')
|
130
|
-
@split_drafts[key]
|
131
|
-
else
|
132
|
-
@site.collections[key]&.docs
|
133
|
-
end
|
157
|
+
collections_config.each_key do |key|
|
158
|
+
next if key == 'data'
|
134
159
|
|
135
160
|
collections[key] ||= []
|
136
|
-
collections[key] = collections[key].map do |doc|
|
137
|
-
document_to_json(doc, key)
|
138
|
-
end
|
139
161
|
end
|
140
162
|
|
141
163
|
if collections.key?('pages') && collections['pages'].empty?
|
142
|
-
|
143
|
-
|
164
|
+
all_pages.each do |page|
|
165
|
+
assigned = assigned_pages[page.relative_path]
|
166
|
+
collections['pages'].push(document_to_json(page, 'pages')) unless assigned
|
144
167
|
end
|
145
168
|
end
|
146
169
|
|
@@ -152,7 +175,7 @@ module CloudCannonJekyll
|
|
152
175
|
should_delete = if key == 'data'
|
153
176
|
!data_files?
|
154
177
|
else
|
155
|
-
collections[key]
|
178
|
+
collections[key]&.empty? && collection_config['auto_discovered']
|
156
179
|
end
|
157
180
|
|
158
181
|
if should_delete
|
@@ -177,6 +200,27 @@ module CloudCannonJekyll
|
|
177
200
|
end
|
178
201
|
end
|
179
202
|
|
203
|
+
def collections_config_path_map(collections_config)
|
204
|
+
unsorted = collections_config.map do |key, collection_config|
|
205
|
+
{
|
206
|
+
key: key,
|
207
|
+
path: "/#{collection_config['path']}/".sub(%r{/+}, '/')
|
208
|
+
}
|
209
|
+
end
|
210
|
+
|
211
|
+
unsorted.sort_by { |pair| pair[:path].length }.reverse
|
212
|
+
end
|
213
|
+
|
214
|
+
def document_collection_key(doc, path_map)
|
215
|
+
path = "/#{File.join(@collections_dir, doc.relative_path)}/".sub(%r{/+}, '/')
|
216
|
+
|
217
|
+
collection_path_pair = path_map.find do |pair|
|
218
|
+
path.start_with? pair[:path]
|
219
|
+
end
|
220
|
+
|
221
|
+
collection_path_pair[:key] if collection_path_pair
|
222
|
+
end
|
223
|
+
|
180
224
|
def legacy_document_data(doc)
|
181
225
|
legacy_data = {}
|
182
226
|
legacy_data['categories'] = doc.categories if doc.respond_to?(:categories)
|
@@ -247,15 +291,27 @@ module CloudCannonJekyll
|
|
247
291
|
end
|
248
292
|
|
249
293
|
def all_pages
|
250
|
-
|
251
|
-
|
252
|
-
|
294
|
+
pages = @site.pages.select { |doc| allowed_page?(doc) }
|
295
|
+
static_pages = @site.static_files.select { |doc| allowed_static_file?(doc) }
|
296
|
+
pages + static_pages
|
297
|
+
end
|
253
298
|
|
254
|
-
|
255
|
-
|
299
|
+
def allowed_document?(doc)
|
300
|
+
if doc.instance_of?(Jekyll::Page)
|
301
|
+
allowed_page?(doc)
|
302
|
+
elsif doc.instance_of?(Jekyll::StaticFile)
|
303
|
+
allowed_static_file?(doc)
|
304
|
+
else
|
305
|
+
true
|
256
306
|
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def allowed_page?(page)
|
310
|
+
page.html? || page.url.end_with?('/')
|
311
|
+
end
|
257
312
|
|
258
|
-
|
313
|
+
def allowed_static_file?(static_file)
|
314
|
+
STATIC_EXTENSIONS.include?(static_file.extname)
|
259
315
|
end
|
260
316
|
|
261
317
|
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.1
|
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-03-06 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: []
|