cloudcannon-jekyll 1.5.0 → 1.5.6
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 +30 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/config-2.x.json +1 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/config-3.0-4.x.json +1 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/config.json +1 -0
- data/lib/cloudcannon-jekyll/generator.rb +15 -3
- data/lib/cloudcannon-jekyll/jsonify-filter.rb +6 -2
- data/lib/cloudcannon-jekyll/reader.rb +5 -6
- data/lib/cloudcannon-jekyll/readers/data-reader.rb +14 -12
- data/lib/cloudcannon-jekyll/readers/old-data-reader.rb +43 -41
- 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: bb81e7f467450a9da1c39bd68adbc69514aa0f33c982b1b70c540f05fe7dda70
|
4
|
+
data.tar.gz: eddc9663476a26ca3d0a503760b07760803ddcb852d7da7ae80c47be0d10ca8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec82c0e7f08018be8b5007911d1286301bdf6300f468e0c86afe3e622823bd0f3611348f8f69e6ab7124d260e89edcce5f44e107ccdbb51d956cc01a959b8db1
|
7
|
+
data.tar.gz: 7196b603e2a82dd61021a927903d3ff2a21506f107e15adf3e16c2986f0a997f42d644d43bb9cf2b357aa653cb02677b1d93ccda2998a5e1a9be4a8761c3570f
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,29 @@
|
|
1
|
+
# 1.5.6
|
2
|
+
|
3
|
+
* Force generator to run after other lowest priority plugins
|
4
|
+
|
5
|
+
# 1.5.5
|
6
|
+
|
7
|
+
* Re-add id field for documents
|
8
|
+
* Fix for potential nil reference
|
9
|
+
|
10
|
+
# 1.5.4
|
11
|
+
|
12
|
+
* Rework fallback for older versions of Jekyll when reading data, posts and drafts again
|
13
|
+
|
14
|
+
# 1.5.3
|
15
|
+
|
16
|
+
* Rework fallback for older versions of Jekyll when reading data, posts and drafts
|
17
|
+
* Fix deprecation warning for `posts.map`
|
18
|
+
|
19
|
+
# 1.5.2
|
20
|
+
|
21
|
+
* Fix for empty collection configurations
|
22
|
+
|
23
|
+
# 1.5.1
|
24
|
+
|
25
|
+
* Add empty paths.pages
|
26
|
+
|
1
27
|
# 1.5.0
|
2
28
|
|
3
29
|
* Added drafts to collections in details
|
@@ -9,6 +35,10 @@
|
|
9
35
|
* Add `url` to static-pages
|
10
36
|
* Normalise `_path` in static-pages
|
11
37
|
|
38
|
+
# 1.4.3
|
39
|
+
|
40
|
+
* Fix off-by-one depth for nested documents from last change
|
41
|
+
|
12
42
|
# 1.4.2
|
13
43
|
|
14
44
|
* Added max depth parameter for jsonify filter and increase it for array structures in config output
|
@@ -25,6 +25,7 @@
|
|
25
25
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
26
26
|
"plugins": {{ config.plugins_dir | cc_jsonify }},
|
27
27
|
"data": {{ config.data_dir | cc_jsonify }},
|
28
|
+
"pages": "",
|
28
29
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
29
30
|
"includes": {{ config.includes_dir | cc_jsonify }},
|
30
31
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
@@ -25,6 +25,7 @@
|
|
25
25
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
26
26
|
"plugins": {{ config.plugins_dir | cc_jsonify }},
|
27
27
|
"data": {{ config.data_dir | cc_jsonify }},
|
28
|
+
"pages": "",
|
28
29
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
29
30
|
"includes": {{ config.includes_dir | cc_jsonify }},
|
30
31
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
@@ -41,6 +41,7 @@
|
|
41
41
|
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
42
42
|
"plugins": {{ config.plugins_dir | cc_jsonify }},
|
43
43
|
"data": {{ config.data_dir | cc_jsonify }},
|
44
|
+
"pages": "",
|
44
45
|
"collections": {{ config.collections_dir | cc_jsonify }},
|
45
46
|
"includes": {{ config.includes_dir | cc_jsonify }},
|
46
47
|
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
@@ -7,13 +7,22 @@ require_relative "reader"
|
|
7
7
|
module CloudCannonJekyll
|
8
8
|
# Generates JSON files containing build config and build output details
|
9
9
|
class Generator < Jekyll::Generator
|
10
|
+
# Override the Jekyll::Plugin spaceship to push our plugin to the very end
|
10
11
|
priority :lowest
|
12
|
+
def self.<=>(*)
|
13
|
+
1
|
14
|
+
end
|
11
15
|
|
12
16
|
def generate(site)
|
13
17
|
@site = site
|
14
18
|
@reader = Reader.new(@site)
|
15
19
|
|
16
|
-
collections_config = @site.config["collections"]
|
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
|
17
26
|
|
18
27
|
payload = @site.site_payload.merge({
|
19
28
|
"gem_version" => CloudCannonJekyll::VERSION,
|
@@ -44,11 +53,13 @@ module CloudCannonJekyll
|
|
44
53
|
@site.config["data_dir"] || "_data"
|
45
54
|
end
|
46
55
|
|
56
|
+
# rubocop:disable Metrics/AbcSize
|
47
57
|
def add_category_folder_config(collections_config, posts_config = {})
|
48
58
|
posts = @site.posts || @site.collections["posts"]
|
59
|
+
docs = posts.class.method_defined?(:docs) ? posts.docs : posts
|
49
60
|
seen = {}
|
50
61
|
|
51
|
-
|
62
|
+
docs.map do |post|
|
52
63
|
parts = post.relative_path.split("/_posts/")
|
53
64
|
path = parts.first
|
54
65
|
|
@@ -75,6 +86,7 @@ module CloudCannonJekyll
|
|
75
86
|
path
|
76
87
|
end
|
77
88
|
end
|
89
|
+
# rubocop:enable Metrics/AbcSize
|
78
90
|
|
79
91
|
# Add data to collections config if raw data files exist
|
80
92
|
def add_data_config(collections_config)
|
@@ -88,7 +100,7 @@ module CloudCannonJekyll
|
|
88
100
|
drafts = @reader.read_drafts(collections_dir)
|
89
101
|
|
90
102
|
if collections_config.key?("posts")
|
91
|
-
collections_config["drafts"] = collections_config["posts"]
|
103
|
+
collections_config["drafts"] = collections_config["posts"]&.dup || {}
|
92
104
|
elsif drafts.any?
|
93
105
|
collections_config["drafts"] = {}
|
94
106
|
end
|
@@ -107,7 +107,7 @@ module CloudCannonJekyll
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def self.document_to_json(input, depth, max_depth)
|
110
|
-
prevent = %w(dir
|
110
|
+
prevent = %w(dir relative_path url collection)
|
111
111
|
|
112
112
|
out = [
|
113
113
|
"\"path\": #{JsonifyFilter.to_json(input.relative_path, depth, max_depth)}",
|
@@ -120,6 +120,10 @@ module CloudCannonJekyll
|
|
120
120
|
out.push("\"collection\": #{collection_json}")
|
121
121
|
end
|
122
122
|
|
123
|
+
if input.respond_to? :id
|
124
|
+
out.push("\"id\": #{JsonifyFilter.to_json(input.id, depth, max_depth)}")
|
125
|
+
end
|
126
|
+
|
123
127
|
out += JsonifyFilter.document_data_to_a(input.data, prevent, depth, max_depth)
|
124
128
|
"{#{out.join(",")}}"
|
125
129
|
end
|
@@ -167,7 +171,7 @@ module CloudCannonJekyll
|
|
167
171
|
def self.to_json(input, depth, max_depth = 9, key_swaps = {})
|
168
172
|
depth += 1
|
169
173
|
|
170
|
-
if depth > max_depth || (depth >
|
174
|
+
if depth > max_depth || (depth > 3 && JsonifyFilter.document_type?(input))
|
171
175
|
'"MAXIMUM_DEPTH"'
|
172
176
|
elsif JsonifyFilter.simple_type?(input)
|
173
177
|
input.to_json
|
@@ -1,12 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "jekyll"
|
4
|
-
|
5
|
-
|
6
|
-
require_relative "readers/data-reader"
|
7
|
-
else
|
8
|
-
require_relative "readers/old-data-reader"
|
9
|
-
end
|
4
|
+
require_relative "readers/old-data-reader"
|
5
|
+
require_relative "readers/data-reader"
|
10
6
|
|
11
7
|
module CloudCannonJekyll
|
12
8
|
# Wraps read functions into one class
|
@@ -18,6 +14,7 @@ module CloudCannonJekyll
|
|
18
14
|
end
|
19
15
|
|
20
16
|
def read_data(dir = "_data")
|
17
|
+
# DataReader doesn't exist in old versions of Jekyll
|
21
18
|
if Jekyll::VERSION.start_with? "2."
|
22
19
|
CloudCannonJekyll::OldDataReader.new(@site).read(dir)
|
23
20
|
else
|
@@ -26,6 +23,7 @@ module CloudCannonJekyll
|
|
26
23
|
end
|
27
24
|
|
28
25
|
def read_drafts(dir = "")
|
26
|
+
# PostReader doesn't exist in old versions of Jekyll
|
29
27
|
if Jekyll::VERSION.start_with? "2."
|
30
28
|
@site.read_content(dir, "_drafts", Jekyll::Draft)
|
31
29
|
else
|
@@ -34,6 +32,7 @@ module CloudCannonJekyll
|
|
34
32
|
end
|
35
33
|
|
36
34
|
def read_posts(dir = "")
|
35
|
+
# PostReader doesn't exist in old versions of Jekyll
|
37
36
|
if Jekyll::VERSION.start_with? "2."
|
38
37
|
@site.read_content(dir, "_posts", Jekyll::Post)
|
39
38
|
else
|
@@ -1,18 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
unless Jekyll::VERSION.start_with? "2."
|
4
|
+
require "jekyll"
|
4
5
|
|
5
|
-
module CloudCannonJekyll
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
6
|
+
module CloudCannonJekyll
|
7
|
+
# Reads data files and creates a collections-style hash representation
|
8
|
+
class DataReader < Jekyll::DataReader
|
9
|
+
# Determines how to read a data file.
|
10
|
+
# This is overridden return a hash instead of reading the file.
|
11
|
+
#
|
12
|
+
# Returns a hash with the path to the data file.
|
13
|
+
def read_data_file(path)
|
14
|
+
{
|
15
|
+
"path" => path,
|
16
|
+
}
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
@@ -1,55 +1,57 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
3
|
+
if Jekyll::VERSION.start_with? "2."
|
4
|
+
require "jekyll"
|
5
|
+
|
6
|
+
module CloudCannonJekyll
|
7
|
+
# Reads data files and creates a collections-style hash representation
|
8
|
+
# Aims to replicate the data reading logic in Jekyll 2.5
|
9
|
+
class OldDataReader
|
10
|
+
attr_reader :site
|
11
|
+
|
12
|
+
def initialize(site)
|
13
|
+
@site = site
|
14
|
+
@safe = site.safe
|
15
|
+
@content = {}
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def read(dir)
|
19
|
+
base = Jekyll.sanitized_path(@site.source, dir)
|
20
|
+
read_data_to(base, @content)
|
21
|
+
@content
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
24
|
+
def read_data_to(dir, data)
|
25
|
+
return unless File.directory?(dir) && (!@safe || !File.symlink?(dir))
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
entries = Dir.chdir(dir) do
|
28
|
+
Dir["*.{yaml,yml,json,csv}"] + Dir["*"].select { |fn| File.directory?(fn) }
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
entries.each do |entry|
|
32
|
+
path = Jekyll.sanitized_path(dir, entry)
|
33
|
+
next if File.symlink?(path) && @safe
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
key = sanitize_filename(File.basename(entry, ".*"))
|
36
|
+
if File.directory?(path)
|
37
|
+
read_data_to(path, data[key] = {})
|
38
|
+
else
|
39
|
+
data[key] = read_data_file(path)
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
41
|
-
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
44
|
+
def read_data_file(path)
|
45
|
+
{
|
46
|
+
"path" => path,
|
47
|
+
}
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
def sanitize_filename(name)
|
51
|
+
name.gsub!(%r![^\w\s_-]+!, "")
|
52
|
+
name.gsub!(%r!(^|\b\s)\s+($|\s?\b)!, '\\1\\2')
|
53
|
+
name.gsub(%r!\s+!, "_")
|
54
|
+
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
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: 1.5.
|
4
|
+
version: 1.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CloudCannon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|