cloudcannon-jekyll 0.0.8 → 0.3.1
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/.github/workflows/stale.yml +19 -0
- data/.gitignore +1 -0
- data/.reek.yml +6 -0
- data/.rubocop.yml +24 -2
- data/.travis.yml +2 -1
- data/Gemfile +2 -0
- data/HISTORY.md +45 -0
- data/cloudcannon-jekyll.gemspec +5 -4
- data/lib/cloudcannon-jekyll.rb +4 -4
- data/lib/cloudcannon-jekyll/_cloudcannon/config-2.x.json +36 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/config-3.0-4.x.json +36 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/config.json +57 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/details-2.x.json +16 -13
- data/lib/cloudcannon-jekyll/_cloudcannon/details-3.0-4.x.json +27 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/details.json +28 -15
- data/lib/cloudcannon-jekyll/configuration.rb +2 -1
- data/lib/cloudcannon-jekyll/generator.rb +131 -18
- data/lib/cloudcannon-jekyll/jsonify-filter.rb +218 -0
- data/lib/cloudcannon-jekyll/page-without-a-file.rb +1 -0
- data/lib/cloudcannon-jekyll/reader.rb +44 -0
- data/lib/cloudcannon-jekyll/readers/data-reader.rb +18 -0
- data/lib/cloudcannon-jekyll/readers/old-data-reader.rb +55 -0
- data/lib/cloudcannon-jekyll/version.rb +1 -1
- data/script/ci-smoke-test +10 -0
- data/script/cibuild +1 -2
- data/script/release +4 -2
- data/script/test +1 -0
- metadata +32 -10
- data/lib/cloudcannon-jekyll/_cloudcannon/details-3.0.x.json +0 -24
- data/lib/cloudcannon-jekyll/safe-jsonify-filter.rb +0 -170
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
|
5
|
+
module CloudCannonJekyll
|
6
|
+
# Reads data files and creates a collections-style hash representation
|
7
|
+
class DataReader < Jekyll::DataReader
|
8
|
+
# Determines how to read a data file.
|
9
|
+
# This is overridden return a hash instead of reading the file.
|
10
|
+
#
|
11
|
+
# Returns a hash with the path to the data file.
|
12
|
+
def read_data_file(path)
|
13
|
+
{
|
14
|
+
"path" => path,
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
|
5
|
+
module CloudCannonJekyll
|
6
|
+
# Reads data files and creates a collections-style hash representation
|
7
|
+
# Aims to replicate the data reading logic in Jekyll 2.5
|
8
|
+
class OldDataReader
|
9
|
+
attr_reader :site
|
10
|
+
|
11
|
+
def initialize(site)
|
12
|
+
@site = site
|
13
|
+
@safe = site.safe
|
14
|
+
@content = {}
|
15
|
+
end
|
16
|
+
|
17
|
+
def read(dir)
|
18
|
+
base = Jekyll.sanitized_path(@site.source, dir)
|
19
|
+
read_data_to(base, @content)
|
20
|
+
@content
|
21
|
+
end
|
22
|
+
|
23
|
+
def read_data_to(dir, data)
|
24
|
+
return unless File.directory?(dir) && (!@safe || !File.symlink?(dir))
|
25
|
+
|
26
|
+
entries = Dir.chdir(dir) do
|
27
|
+
Dir["*.{yaml,yml,json,csv}"] + Dir["*"].select { |fn| File.directory?(fn) }
|
28
|
+
end
|
29
|
+
|
30
|
+
entries.each do |entry|
|
31
|
+
path = Jekyll.sanitized_path(dir, entry)
|
32
|
+
next if File.symlink?(path) && @safe
|
33
|
+
|
34
|
+
key = sanitize_filename(File.basename(entry, ".*"))
|
35
|
+
if File.directory?(path)
|
36
|
+
read_data_to(path, data[key] = {})
|
37
|
+
else
|
38
|
+
data[key] = read_data_file(path)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def read_data_file(path)
|
44
|
+
{
|
45
|
+
"path" => path,
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def sanitize_filename(name)
|
50
|
+
name.gsub!(%r![^\w\s_-]+!, "")
|
51
|
+
name.gsub!(%r!(^|\b\s)\s+($|\s?\b)!, '\\1\\2')
|
52
|
+
name.gsub(%r!\s+!, "_")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
set -ex
|
4
|
+
|
5
|
+
# Checks to see the build is likely to fail on Travis.
|
6
|
+
# Duplicated the versions from .travis.yml
|
7
|
+
|
8
|
+
JEKYLL_VERSION=2.4.0 bundle update && $(dirname "$0")/test &&
|
9
|
+
JEKYLL_VERSION=3.0.0 bundle update && $(dirname "$0")/test &&
|
10
|
+
JEKYLL_VERSION=3.2.1 bundle update && $(dirname "$0")/test
|
data/script/cibuild
CHANGED
data/script/release
CHANGED
@@ -33,5 +33,7 @@ git fetch -t origin
|
|
33
33
|
|
34
34
|
# Push tag and upload new gem
|
35
35
|
|
36
|
-
|
37
|
-
git push origin master &&
|
36
|
+
git tag "$tag" &&
|
37
|
+
git push origin master &&
|
38
|
+
git push origin "$tag" &&
|
39
|
+
gem push cloudcannon-jekyll-*.gem
|
data/script/test
CHANGED
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: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CloudCannon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -30,6 +30,20 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: json_schemer
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: 0.2.4
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.2.4
|
33
47
|
- !ruby/object:Gem::Dependency
|
34
48
|
name: rake
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,28 +78,28 @@ dependencies:
|
|
64
78
|
requirements:
|
65
79
|
- - "~>"
|
66
80
|
- !ruby/object:Gem::Version
|
67
|
-
version: '0.
|
81
|
+
version: '0.80'
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
version_requirements: !ruby/object:Gem::Requirement
|
71
85
|
requirements:
|
72
86
|
- - "~>"
|
73
87
|
- !ruby/object:Gem::Version
|
74
|
-
version: '0.
|
88
|
+
version: '0.80'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: rubocop-jekyll
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
78
92
|
requirements:
|
79
93
|
- - "~>"
|
80
94
|
- !ruby/object:Gem::Version
|
81
|
-
version: '0.
|
95
|
+
version: '0.11'
|
82
96
|
type: :development
|
83
97
|
prerelease: false
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
100
|
- - "~>"
|
87
101
|
- !ruby/object:Gem::Version
|
88
|
-
version: '0.
|
102
|
+
version: '0.11'
|
89
103
|
description: Creates CloudCannon editor details for Jekyll
|
90
104
|
email:
|
91
105
|
- support@cloudcannon.com
|
@@ -93,7 +107,9 @@ executables: []
|
|
93
107
|
extensions: []
|
94
108
|
extra_rdoc_files: []
|
95
109
|
files:
|
110
|
+
- ".github/workflows/stale.yml"
|
96
111
|
- ".gitignore"
|
112
|
+
- ".reek.yml"
|
97
113
|
- ".rspec"
|
98
114
|
- ".rubocop.yml"
|
99
115
|
- ".travis.yml"
|
@@ -104,14 +120,21 @@ files:
|
|
104
120
|
- Rakefile
|
105
121
|
- cloudcannon-jekyll.gemspec
|
106
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
|
107
126
|
- lib/cloudcannon-jekyll/_cloudcannon/details-2.x.json
|
108
|
-
- lib/cloudcannon-jekyll/_cloudcannon/details-3.0.x.json
|
127
|
+
- lib/cloudcannon-jekyll/_cloudcannon/details-3.0-4.x.json
|
109
128
|
- lib/cloudcannon-jekyll/_cloudcannon/details.json
|
110
129
|
- lib/cloudcannon-jekyll/configuration.rb
|
111
130
|
- lib/cloudcannon-jekyll/generator.rb
|
131
|
+
- lib/cloudcannon-jekyll/jsonify-filter.rb
|
112
132
|
- lib/cloudcannon-jekyll/page-without-a-file.rb
|
113
|
-
- lib/cloudcannon-jekyll/
|
133
|
+
- lib/cloudcannon-jekyll/reader.rb
|
134
|
+
- lib/cloudcannon-jekyll/readers/data-reader.rb
|
135
|
+
- lib/cloudcannon-jekyll/readers/old-data-reader.rb
|
114
136
|
- lib/cloudcannon-jekyll/version.rb
|
137
|
+
- script/ci-smoke-test
|
115
138
|
- script/cibuild
|
116
139
|
- script/release
|
117
140
|
- script/test
|
@@ -134,8 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
157
|
- !ruby/object:Gem::Version
|
135
158
|
version: '0'
|
136
159
|
requirements: []
|
137
|
-
|
138
|
-
rubygems_version: 2.7.6.2
|
160
|
+
rubygems_version: 3.0.3
|
139
161
|
signing_key:
|
140
162
|
specification_version: 4
|
141
163
|
summary: CloudCannon Jekyll integration
|
@@ -1,24 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"time": {{ site.time | jsonify }},
|
3
|
-
"cloudcannon": {
|
4
|
-
"name": "cloudcannon-jekyll",
|
5
|
-
"version": {{ gem_version | jsonify }}
|
6
|
-
},
|
7
|
-
"generator": {
|
8
|
-
"name": "jekyll",
|
9
|
-
"version": {{ jekyll.version | jsonify }},
|
10
|
-
"environment": {{ jekyll.env | jsonify }},
|
11
|
-
"metadata": {
|
12
|
-
"markdown": {{ site.markdown | cc_safe_jsonify }},
|
13
|
-
"kramdown": {{ site.kramdown | cc_safe_jsonify }},
|
14
|
-
"commonmark": {{ site.commonmark | cc_safe_jsonify }}
|
15
|
-
}
|
16
|
-
},{% if site.cloudcannon.data %}
|
17
|
-
"data": {{ site.data | cc_safe_jsonify }},{% endif %}
|
18
|
-
"collections": {
|
19
|
-
{% for collection in site.collections %}"{{ collection.label | xml_escape }}": {{ collection.docs | cc_safe_jsonify }}{% unless forloop.last %},{% endunless %}
|
20
|
-
{% endfor %}
|
21
|
-
},
|
22
|
-
"pages": {{ site.pages | cc_safe_jsonify }},
|
23
|
-
"static": {{ site.static_files | cc_static_files_jsonify }}
|
24
|
-
}
|
@@ -1,170 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "jekyll"
|
4
|
-
|
5
|
-
module CloudCannonJekyll
|
6
|
-
module SafeJsonifyFilter
|
7
|
-
@simple_types = [
|
8
|
-
String,
|
9
|
-
Numeric,
|
10
|
-
Integer,
|
11
|
-
Float,
|
12
|
-
Date,
|
13
|
-
Time,
|
14
|
-
NilClass,
|
15
|
-
Object.const_defined?("Fixnum") ? Fixnum : nil,
|
16
|
-
].compact.freeze
|
17
|
-
|
18
|
-
@document_types = [
|
19
|
-
Jekyll::Document,
|
20
|
-
Jekyll::Page,
|
21
|
-
Jekyll::VERSION.start_with?("2.") ? Jekyll::Post : nil,
|
22
|
-
].compact.freeze
|
23
|
-
|
24
|
-
def self.document_type?(input)
|
25
|
-
@document_types.include?(input.class)
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.simple_type?(input)
|
29
|
-
@simple_types.include?(input.class) || [true, false].include?(input)
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.static_file_to_json(input, depth)
|
33
|
-
out = [
|
34
|
-
"\"extname\": #{SafeJsonifyFilter.to_json(input.extname, depth + 1)}",
|
35
|
-
"\"path\": #{SafeJsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
36
|
-
]
|
37
|
-
|
38
|
-
# modified_time isn't defined in Jekyll 2.4.0
|
39
|
-
if input.respond_to? :modified_time
|
40
|
-
out.push("\"modified_time\": #{SafeJsonifyFilter.to_json(input.modified_time, depth + 1)}")
|
41
|
-
end
|
42
|
-
|
43
|
-
"{#{out.join(",")}}"
|
44
|
-
end
|
45
|
-
|
46
|
-
def self.document_data_to_json(data, out, prevent, depth)
|
47
|
-
prevent += %w(content output next previous excerpt)
|
48
|
-
|
49
|
-
data.map do |key, value|
|
50
|
-
unless prevent.include? key
|
51
|
-
out.push("\"#{key}\": #{SafeJsonifyFilter.to_json(value, depth + 1)}")
|
52
|
-
prevent.push(key)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
"{#{out.join(",")}}"
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.legacy_post_to_json(input, depth)
|
60
|
-
prevent = %w(dir name path url date id categories tags)
|
61
|
-
|
62
|
-
out = [
|
63
|
-
"\"dir\": #{SafeJsonifyFilter.to_json(input.dir, depth + 1)}",
|
64
|
-
"\"name\": #{SafeJsonifyFilter.to_json(input.name, depth + 1)}",
|
65
|
-
"\"path\": #{SafeJsonifyFilter.to_json(input.path, depth + 1)}",
|
66
|
-
"\"url\": #{SafeJsonifyFilter.to_json(input.url, depth + 1)}",
|
67
|
-
"\"date\": #{SafeJsonifyFilter.to_json(input.date, depth + 1)}",
|
68
|
-
"\"id\": #{SafeJsonifyFilter.to_json(input.id, depth + 1)}",
|
69
|
-
"\"categories\": #{SafeJsonifyFilter.to_json(input.categories, depth + 1)}",
|
70
|
-
"\"tags\": #{SafeJsonifyFilter.to_json(input.tags, depth + 1)}",
|
71
|
-
]
|
72
|
-
|
73
|
-
SafeJsonifyFilter.document_data_to_json(input.data, out, prevent, depth)
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.page_to_json(input, depth)
|
77
|
-
prevent = %w(dir name path url)
|
78
|
-
|
79
|
-
out = [
|
80
|
-
"\"dir\": #{SafeJsonifyFilter.to_json(input.dir, depth + 1)}",
|
81
|
-
"\"name\": #{SafeJsonifyFilter.to_json(input.name, depth + 1)}",
|
82
|
-
"\"path\": #{SafeJsonifyFilter.to_json(input.path, depth + 1)}",
|
83
|
-
"\"url\": #{SafeJsonifyFilter.to_json(input.url, depth + 1)}",
|
84
|
-
]
|
85
|
-
|
86
|
-
# Merge Jekyll Defaults into data for pages (missing at v3.8.5)
|
87
|
-
defaults = input.site.frontmatter_defaults.all(input.relative_path, :pages).tap do |h|
|
88
|
-
h.delete("date")
|
89
|
-
end
|
90
|
-
|
91
|
-
data = Jekyll::Utils.deep_merge_hashes(defaults, input.data)
|
92
|
-
SafeJsonifyFilter.document_data_to_json(data, out, prevent, depth)
|
93
|
-
end
|
94
|
-
|
95
|
-
def self.document_to_json(input, depth)
|
96
|
-
prevent = %w(dir id relative_path url collection)
|
97
|
-
|
98
|
-
out = [
|
99
|
-
"\"path\": #{SafeJsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
100
|
-
"\"relative_path\": #{SafeJsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
101
|
-
"\"url\": #{SafeJsonifyFilter.to_json(input.url, depth + 1)}",
|
102
|
-
]
|
103
|
-
|
104
|
-
unless input.collection.nil?
|
105
|
-
out.push("\"collection\": #{SafeJsonifyFilter.to_json(input.collection.label, depth + 1)}")
|
106
|
-
end
|
107
|
-
|
108
|
-
# id isn't defined in Jekyll 2.4.0
|
109
|
-
out.push("\"id\": #{SafeJsonifyFilter.to_json(input.id, depth + 1)}") if input.respond_to? :id
|
110
|
-
|
111
|
-
SafeJsonifyFilter.document_data_to_json(input.data, out, prevent, depth)
|
112
|
-
end
|
113
|
-
|
114
|
-
def self.array_to_json(input, depth)
|
115
|
-
array = input.map do |value|
|
116
|
-
SafeJsonifyFilter.to_json(value, depth + 1)
|
117
|
-
end
|
118
|
-
|
119
|
-
"[#{array.join(",")}]"
|
120
|
-
end
|
121
|
-
|
122
|
-
def self.hash_to_json(input, depth)
|
123
|
-
hash = input.map do |key, value|
|
124
|
-
"\"#{key}\": #{SafeJsonifyFilter.to_json(value, depth + 1)}"
|
125
|
-
end
|
126
|
-
|
127
|
-
"{#{hash.join(",")}}"
|
128
|
-
end
|
129
|
-
|
130
|
-
def self.to_json(input, depth)
|
131
|
-
if depth > 8 || (depth > 2 && SafeJsonifyFilter.document_type?(input))
|
132
|
-
'"MAXIMUM_DEPTH"'
|
133
|
-
elsif SafeJsonifyFilter.simple_type?(input)
|
134
|
-
input.to_json
|
135
|
-
elsif input.is_a?(Jekyll::StaticFile)
|
136
|
-
SafeJsonifyFilter.static_file_to_json(input, depth)
|
137
|
-
elsif input.is_a?(Jekyll::Page)
|
138
|
-
SafeJsonifyFilter.page_to_json(input, depth)
|
139
|
-
elsif Jekyll::VERSION.start_with?("2.") && input.is_a?(Jekyll::Post)
|
140
|
-
SafeJsonifyFilter.legacy_post_to_json(input, depth)
|
141
|
-
elsif input.is_a?(Jekyll::Document)
|
142
|
-
SafeJsonifyFilter.document_to_json(input, depth)
|
143
|
-
elsif input.is_a?(Array)
|
144
|
-
SafeJsonifyFilter.array_to_json(input, depth)
|
145
|
-
elsif input.is_a?(Hash)
|
146
|
-
SafeJsonifyFilter.hash_to_json(input, depth)
|
147
|
-
else
|
148
|
-
"\"UNSUPPORTED:#{input.class}\""
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def cc_static_files_jsonify(input)
|
153
|
-
out = []
|
154
|
-
input.each do |page|
|
155
|
-
next if page.extname != ".html" &&
|
156
|
-
page.extname != ".htm" &&
|
157
|
-
page.path != "/robots.txt" &&
|
158
|
-
page.path != "/sitemap.xml"
|
159
|
-
|
160
|
-
out.push(SafeJsonifyFilter.to_json(page, 1))
|
161
|
-
end
|
162
|
-
|
163
|
-
"[#{out.join(",")}]"
|
164
|
-
end
|
165
|
-
|
166
|
-
def cc_safe_jsonify(input)
|
167
|
-
SafeJsonifyFilter.to_json(input, 0)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|