cloudcannon-jekyll 1.5.3 → 1.6.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/.gitignore +2 -2
- data/HISTORY.md +22 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/details-2.x.json +1 -1
- data/lib/cloudcannon-jekyll/_cloudcannon/details-3.0-4.x.json +1 -1
- data/lib/cloudcannon-jekyll/_cloudcannon/details.json +1 -1
- data/lib/cloudcannon-jekyll/generator.rb +6 -4
- data/lib/cloudcannon-jekyll/jsonify-filter.rb +17 -5
- data/lib/cloudcannon-jekyll/reader.rb +20 -15
- 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: 10ce07fce474de172ceafec1ecbe0a0d4e6d012d2357befc0cef41e2418a992e
|
4
|
+
data.tar.gz: 418f38e206327042999eca17c901477e7fd864bce425a5410a6b49cc503760f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db5ebdba978110b1b312dafb9b1e3f9928edd4259b9095af266a2be1964bdf3028a0fe303080353b8a5a18685ae52705dd630cf16285e1be9f7c129c328fc525
|
7
|
+
data.tar.gz: 76f36521f6b0888b90be9e0a071bd5c3258e97ec2623d996ebf3a5cdc7f0f3f771e35bf6b0f258f4e5654538e7dcc17524f32fd37223414b0cb5ffbf8f24700d
|
data/.gitignore
CHANGED
data/HISTORY.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# 1.6.0
|
2
|
+
|
3
|
+
* Add `collections_dir` to details collection item paths
|
4
|
+
|
5
|
+
# 1.5.7
|
6
|
+
|
7
|
+
* Fix pages collection clash with built-in pages
|
8
|
+
* Fixed posts collection config data overwriting drafts data
|
9
|
+
|
10
|
+
# 1.5.6
|
11
|
+
|
12
|
+
* Force generator to run after other lowest priority plugins
|
13
|
+
|
14
|
+
# 1.5.5
|
15
|
+
|
16
|
+
* Re-add id field for documents
|
17
|
+
* Fix for potential nil reference
|
18
|
+
|
19
|
+
# 1.5.4
|
20
|
+
|
21
|
+
* Rework fallback for older versions of Jekyll when reading data, posts and drafts again
|
22
|
+
|
1
23
|
# 1.5.3
|
2
24
|
|
3
25
|
* Rework fallback for older versions of Jekyll when reading data, posts and drafts
|
@@ -23,6 +23,6 @@
|
|
23
23
|
{% for collection in site.collections %}"{{ collection[0] | xml_escape }}": {{ collection[1].docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
24
24
|
{% endfor %}
|
25
25
|
},
|
26
|
-
"pages": {{ site.
|
26
|
+
"pages": {{ site.html_pages | cc_jsonify }},
|
27
27
|
"static-pages": {{ site.static_files | cc_static_files_jsonify }}
|
28
28
|
}
|
@@ -22,6 +22,6 @@
|
|
22
22
|
{% for collection in site.collections %}"{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
23
23
|
{% endfor %}
|
24
24
|
},
|
25
|
-
"pages": {{ site.
|
25
|
+
"pages": {{ site.html_pages | cc_jsonify }},
|
26
26
|
"static-pages": {{ site.static_files | cc_static_files_jsonify }}
|
27
27
|
}
|
@@ -7,13 +7,17 @@ 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 || {}
|
17
21
|
|
18
22
|
# Workaround for empty collection configurations
|
19
23
|
collections_config.each_key do |key|
|
@@ -95,9 +99,7 @@ module CloudCannonJekyll
|
|
95
99
|
collections_config["posts"] = { "output" => true } if Jekyll::VERSION.start_with? "2."
|
96
100
|
drafts = @reader.read_drafts(collections_dir)
|
97
101
|
|
98
|
-
if collections_config.key?("posts")
|
99
|
-
collections_config["drafts"] = collections_config["posts"].dup
|
100
|
-
elsif drafts.any?
|
102
|
+
if (collections_config.key?("posts") && !collections_config.key?("drafts")) || drafts.any?
|
101
103
|
collections_config["drafts"] = {}
|
102
104
|
end
|
103
105
|
|
@@ -106,20 +106,32 @@ module CloudCannonJekyll
|
|
106
106
|
"{#{out.join(",")}}"
|
107
107
|
end
|
108
108
|
|
109
|
+
def self.document_path(input)
|
110
|
+
collections_dir = input.site.config["collections_dir"] || ""
|
111
|
+
if input.collection && !collections_dir.empty?
|
112
|
+
"#{collections_dir}/#{input.relative_path}"
|
113
|
+
else
|
114
|
+
input.relative_path
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
109
118
|
def self.document_to_json(input, depth, max_depth)
|
110
|
-
prevent = %w(dir
|
119
|
+
prevent = %w(dir relative_path url collection)
|
111
120
|
|
112
121
|
out = [
|
113
|
-
"\"path\": #{JsonifyFilter.to_json(input
|
122
|
+
"\"path\": #{JsonifyFilter.to_json(JsonifyFilter.document_path(input), depth, max_depth)}",
|
114
123
|
"\"url\": #{JsonifyFilter.to_json(input.url, depth, max_depth)}",
|
115
124
|
]
|
116
125
|
|
117
|
-
|
118
|
-
|
119
|
-
collection_json = JsonifyFilter.to_json(collection.label, depth, max_depth)
|
126
|
+
unless input.collection.nil?
|
127
|
+
collection_json = JsonifyFilter.to_json(input.collection.label, depth, max_depth)
|
120
128
|
out.push("\"collection\": #{collection_json}")
|
121
129
|
end
|
122
130
|
|
131
|
+
if input.respond_to? :id
|
132
|
+
out.push("\"id\": #{JsonifyFilter.to_json(input.id, depth, max_depth)}")
|
133
|
+
end
|
134
|
+
|
123
135
|
out += JsonifyFilter.document_data_to_a(input.data, prevent, depth, max_depth)
|
124
136
|
"{#{out.join(",")}}"
|
125
137
|
end
|
@@ -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
|
-
rescue NameError
|
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,21 +14,30 @@ module CloudCannonJekyll
|
|
18
14
|
end
|
19
15
|
|
20
16
|
def read_data(dir = "_data")
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
# DataReader doesn't exist in old versions of Jekyll
|
18
|
+
if Jekyll::VERSION.start_with? "2."
|
19
|
+
CloudCannonJekyll::OldDataReader.new(@site).read(dir)
|
20
|
+
else
|
21
|
+
CloudCannonJekyll::DataReader.new(@site).read(dir)
|
22
|
+
end
|
24
23
|
end
|
25
24
|
|
26
25
|
def read_drafts(dir = "")
|
27
|
-
Jekyll
|
28
|
-
|
29
|
-
|
26
|
+
# PostReader doesn't exist in old versions of Jekyll
|
27
|
+
if Jekyll::VERSION.start_with? "2."
|
28
|
+
@site.read_content(dir, "_drafts", Jekyll::Draft)
|
29
|
+
else
|
30
|
+
Jekyll::PostReader.new(@site).read_drafts(dir)
|
31
|
+
end
|
30
32
|
end
|
31
33
|
|
32
34
|
def read_posts(dir = "")
|
33
|
-
Jekyll
|
34
|
-
|
35
|
-
|
35
|
+
# PostReader doesn't exist in old versions of Jekyll
|
36
|
+
if Jekyll::VERSION.start_with? "2."
|
37
|
+
@site.read_content(dir, "_posts", Jekyll::Post)
|
38
|
+
else
|
39
|
+
Jekyll::PostReader.new(@site).read_posts(dir)
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
@@ -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.
|
4
|
+
version: 1.6.0
|
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-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|