cloudcannon-jekyll 0.3.4 → 1.0.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 +0 -1
- data/.rubocop.yml +2 -24
- data/.travis.yml +3 -2
- data/Gemfile +0 -2
- data/HISTORY.md +3 -70
- data/cloudcannon-jekyll.gemspec +5 -6
- data/lib/cloudcannon-jekyll.rb +10 -8
- data/lib/cloudcannon-jekyll/_cloudcannon/details-2.x.json +13 -16
- data/lib/cloudcannon-jekyll/_cloudcannon/details-3.0.x.json +24 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/details.json +15 -28
- data/lib/cloudcannon-jekyll/configuration.rb +1 -2
- data/lib/cloudcannon-jekyll/generator.rb +18 -134
- data/lib/cloudcannon-jekyll/page-without-a-file.rb +0 -1
- data/lib/cloudcannon-jekyll/safe-jsonify-filter.rb +169 -0
- data/lib/cloudcannon-jekyll/version.rb +1 -1
- data/script/cibuild +2 -1
- data/script/release +2 -4
- data/script/test +0 -1
- metadata +12 -34
- data/.github/workflows/stale.yml +0 -19
- data/.reek.yml +0 -6
- data/lib/cloudcannon-jekyll/_cloudcannon/config-2.x.json +0 -36
- data/lib/cloudcannon-jekyll/_cloudcannon/config-3.0-4.x.json +0 -36
- data/lib/cloudcannon-jekyll/_cloudcannon/config.json +0 -57
- data/lib/cloudcannon-jekyll/_cloudcannon/details-3.0-4.x.json +0 -27
- data/lib/cloudcannon-jekyll/jsonify-filter.rb +0 -222
- data/lib/cloudcannon-jekyll/reader.rb +0 -43
- data/lib/cloudcannon-jekyll/readers/data-reader.rb +0 -20
- data/lib/cloudcannon-jekyll/readers/old-data-reader.rb +0 -57
- data/script/ci-smoke-test +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acbff58768a2a1c6d143ed8c0fe84cc1e3a6dc147e449fa91b69d24ea85655b8
|
4
|
+
data.tar.gz: 778145a334b54d304ff601c3547c397a6955b9edf7fa73e393565aa7a0a1d46b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfd7cd98ba79c5b49e312f75f3ade2a844565f78e8a45d75e52d1776bbbf1c34b13aa9bac5de6a2b20314d2538fe80a261e2154dab4eeaf27187f639984e7700
|
7
|
+
data.tar.gz: cf9f07c980a416af440a2ba1b7f6ae20a420b8fe758752d736ad88878bf516bd8adb3bf7141725abfd100ff2c08cfc030db2f3d2753e3fff5416f9a8c7b95cd0
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -4,7 +4,7 @@ inherit_gem:
|
|
4
4
|
rubocop-jekyll: .rubocop.yml
|
5
5
|
|
6
6
|
AllCops:
|
7
|
-
TargetRubyVersion: 2.
|
7
|
+
TargetRubyVersion: 2.6
|
8
8
|
Include:
|
9
9
|
- lib/**/*.rb
|
10
10
|
|
@@ -20,30 +20,8 @@ AllCops:
|
|
20
20
|
- script/**/*
|
21
21
|
- vendor/**/*
|
22
22
|
- gemfiles/**/*
|
23
|
+
- lib/cloudcannon-jekyll/safe-jsonify-filter.rb # TODO remove this and fix warnings
|
23
24
|
|
24
25
|
Naming/MemoizedInstanceVariableName:
|
25
26
|
Exclude:
|
26
27
|
- lib/cloudcannon-jekyll/page-without-a-file.rb
|
27
|
-
|
28
|
-
Metrics/CyclomaticComplexity:
|
29
|
-
Exclude:
|
30
|
-
- lib/cloudcannon-jekyll/jsonify-filter.rb # TODO remove this and fix warnings
|
31
|
-
- lib/cloudcannon-jekyll/readers/old-data-reader.rb # TODO remove this and fix warnings
|
32
|
-
|
33
|
-
Metrics/PerceivedComplexity:
|
34
|
-
Exclude:
|
35
|
-
- lib/cloudcannon-jekyll/jsonify-filter.rb # TODO remove this and fix warnings
|
36
|
-
|
37
|
-
Metrics/AbcSize:
|
38
|
-
Exclude:
|
39
|
-
- lib/cloudcannon-jekyll/jsonify-filter.rb # TODO remove this and fix warnings
|
40
|
-
|
41
|
-
# This is excluded since the ruby target is 2.3.8 which doesn't support String.match?(Regexp)
|
42
|
-
Performance/RegexpMatch:
|
43
|
-
Exclude:
|
44
|
-
- lib/cloudcannon-jekyll/generator.rb
|
45
|
-
|
46
|
-
# This is excluded since Jekyll used this and we need to check for it
|
47
|
-
Lint/UnifiedInteger:
|
48
|
-
Exclude:
|
49
|
-
- lib/cloudcannon-jekyll/jsonify-filter.rb
|
data/.travis.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
language: ruby
|
2
2
|
cache: bundler
|
3
3
|
rvm:
|
4
|
-
- 2.
|
4
|
+
- 2.6
|
5
5
|
|
6
6
|
before_install:
|
7
7
|
- gem update --system
|
@@ -15,4 +15,5 @@ env:
|
|
15
15
|
matrix:
|
16
16
|
- JEKYLL_VERSION="2.4.0"
|
17
17
|
- JEKYLL_VERSION="3.0.0"
|
18
|
-
- JEKYLL_VERSION="3.
|
18
|
+
- JEKYLL_VERSION="3.8.5"
|
19
|
+
- JEKYLL_VERSION="4.0.0"
|
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
@@ -1,74 +1,7 @@
|
|
1
|
-
# 0.
|
1
|
+
# 1.0.0
|
2
2
|
|
3
|
-
*
|
4
|
-
*
|
5
|
-
|
6
|
-
# 0.3.3
|
7
|
-
|
8
|
-
* Rework fallback for older versions of Jekyll when reading data, posts and drafts again
|
9
|
-
|
10
|
-
# 0.3.2
|
11
|
-
|
12
|
-
* Rework fallback for older versions of Jekyll when reading data, posts and drafts
|
13
|
-
* Fix deprecation warning for `posts.map`
|
14
|
-
|
15
|
-
# 0.3.1
|
16
|
-
|
17
|
-
* Fix for empty collection configurations
|
18
|
-
* Added max depth parameter for jsonify filter and increase it for array structures in config output
|
19
|
-
|
20
|
-
# 0.3.0
|
21
|
-
|
22
|
-
* Add empty paths.pages
|
23
|
-
* Added drafts to collections in details
|
24
|
-
* Added drafts and data to collections in config
|
25
|
-
* Added category folder drafts and posts to collections in config
|
26
|
-
* Added `_path` field to each collection definition in config
|
27
|
-
* Removed some unused fields
|
28
|
-
* Renamed static to static-pages in details and removed `robots.txt` and `sitemap.xml` exceptions
|
29
|
-
* Add `url` to static-pages
|
30
|
-
* Normalise `_path` in static-pages
|
31
|
-
|
32
|
-
# 0.2.2
|
33
|
-
|
34
|
-
* Added JSON handling for integers in hash keys
|
35
|
-
* Fix typo for collections key in older Jekyll versions
|
36
|
-
* Change date format to ISO8601
|
37
|
-
* Validate against new version of config schema
|
38
|
-
|
39
|
-
# 0.2.1
|
40
|
-
|
41
|
-
* Add gem information and time to output config file
|
42
|
-
* Fix missing in-place compact
|
43
|
-
* Fix source being output as full path on disk
|
44
|
-
* Read content for output config file directly from site config
|
45
|
-
|
46
|
-
# 0.2.0
|
47
|
-
|
48
|
-
* Add defaults and input-options keys to config output
|
49
|
-
* Add more ignore keys for legacy select data filter
|
50
|
-
* Reduce methods added from other plugins clashing
|
51
|
-
* Fix invalid output when unsupported class found
|
52
|
-
|
53
|
-
# 0.1.0
|
54
|
-
|
55
|
-
* Add output config file
|
56
|
-
* Add support for including only specified `data` keys
|
57
|
-
* Fix invalid JSON issue for sites built with Jekyll 2 and no collections
|
58
|
-
* Change module load style for easier dropping into _plugins
|
59
|
-
|
60
|
-
# 0.0.8
|
61
|
-
|
62
|
-
* Removed unsupported Jekyll test targets
|
63
|
-
|
64
|
-
# 0.0.7
|
65
|
-
|
66
|
-
* Fix invalid JSON issue for sites built with Jekyll 2 and no collections
|
67
|
-
|
68
|
-
# 0.0.6
|
69
|
-
|
70
|
-
* Fixed unsupported Fixnum for Ruby 2.3
|
71
|
-
* Fixed reference to unsupported String::match? for Ruby 2.3
|
3
|
+
* Initial release
|
4
|
+
* Dropped support for ruby 2.3
|
72
5
|
|
73
6
|
# 0.0.5
|
74
7
|
|
data/cloudcannon-jekyll.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# coding: utf-8
|
2
2
|
|
3
|
-
lib = File.expand_path("lib",
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
require "cloudcannon-jekyll/version"
|
@@ -19,11 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
all_files = `git ls-files -z`.split("\x0")
|
20
20
|
spec.files = all_files.reject { |f| f.match(%r!^(test|spec|features)/!) }
|
21
21
|
|
22
|
-
spec.add_dependency "jekyll", ">= 2.4.0", "<
|
22
|
+
spec.add_dependency "jekyll", ">= 2.4.0", "< 5"
|
23
23
|
|
24
|
-
spec.add_development_dependency "json_schemer", "~> 0.2.4"
|
25
24
|
spec.add_development_dependency "rake", "~> 13.0"
|
26
25
|
spec.add_development_dependency "rspec", "~> 3.9"
|
27
|
-
spec.add_development_dependency "rubocop", "~> 0.
|
28
|
-
spec.add_development_dependency "rubocop-jekyll", "~> 0.
|
26
|
+
spec.add_development_dependency "rubocop", "~> 0.71"
|
27
|
+
spec.add_development_dependency "rubocop-jekyll", "~> 0.10"
|
29
28
|
end
|
data/lib/cloudcannon-jekyll.rb
CHANGED
@@ -2,17 +2,19 @@
|
|
2
2
|
|
3
3
|
require "jekyll"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
module CloudCannonJekyll
|
6
|
+
autoload :PageWithoutAFile, "cloudcannon-jekyll/page-without-a-file"
|
7
|
+
autoload :Generator, "cloudcannon-jekyll/generator"
|
8
|
+
autoload :Configuration, "cloudcannon-jekyll/configuration"
|
9
|
+
autoload :SafeJsonifyFilter, "cloudcannon-jekyll/safe-jsonify-filter"
|
10
|
+
autoload :VERSION, "cloudcannon-jekyll/version"
|
11
|
+
end
|
10
12
|
|
11
|
-
Liquid::Template.register_filter(CloudCannonJekyll::
|
13
|
+
Liquid::Template.register_filter(CloudCannonJekyll::SafeJsonifyFilter)
|
12
14
|
|
13
|
-
|
15
|
+
# Hooks didn't exist in Jekyll 2 so we monkey patch to get an :after_reset hook
|
16
|
+
if Jekyll::VERSION.start_with? "2"
|
14
17
|
module Jekyll
|
15
|
-
# Hooks didn't exist in Jekyll 2 so we monkey patch to get an :after_reset hook
|
16
18
|
class Site
|
17
19
|
alias_method :jekyll_reset, :reset
|
18
20
|
|
@@ -1,28 +1,25 @@
|
|
1
1
|
{
|
2
|
-
"time": {{ site.time |
|
2
|
+
"time": {{ site.time | jsonify }},
|
3
3
|
"cloudcannon": {
|
4
4
|
"name": "cloudcannon-jekyll",
|
5
|
-
"version": {{ gem_version |
|
5
|
+
"version": {{ gem_version | jsonify }}
|
6
6
|
},
|
7
7
|
"generator": {
|
8
8
|
"name": "jekyll",
|
9
|
-
"version": {{ jekyll.version |
|
10
|
-
"environment": {{ jekyll.env |
|
9
|
+
"version": {{ jekyll.version | jsonify }},
|
10
|
+
"environment": {{ jekyll.env | jsonify }},
|
11
11
|
"metadata": {
|
12
|
-
"markdown": {{ site.markdown |
|
13
|
-
"kramdown": {{ site.kramdown |
|
14
|
-
"commonmark": {{ site.commonmark |
|
12
|
+
"markdown": {{ site.markdown | cc_safe_jsonify }},
|
13
|
+
"kramdown": {{ site.kramdown | cc_safe_jsonify }},
|
14
|
+
"commonmark": {{ site.commonmark | cc_safe_jsonify }}
|
15
15
|
}
|
16
|
-
},{% if site.cloudcannon.data
|
17
|
-
"data": {
|
18
|
-
{% for data in site.data %}{% assign key = data[0] %}{% if site.cloudcannon.data[key] %}{% if data_seen %},{% endif %}{{ data[0] | cc_jsonify }}: {{ data[1] | cc_jsonify }}{% assign data_seen = true %}{% endif %}{% endfor %}},
|
19
|
-
{% elsif site.cloudcannon.data %}"data": {{ site.data | cc_jsonify }},{% endif %}
|
16
|
+
},{% if site.cloudcannon.data %}
|
17
|
+
"data": {{ site.data | cc_safe_jsonify }},{% endif %}
|
20
18
|
"collections": {
|
21
|
-
"
|
22
|
-
"
|
23
|
-
{% for collection in site.collections %}"{{ collection[0] | xml_escape }}": {{ collection[1].docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
19
|
+
"posts": {{ site.posts | reverse | cc_safe_jsonify }},
|
20
|
+
{% for collection in site.collections %}"{{ collection[0] | xml_escape }}": {{ collection[1].docs | cc_safe_jsonify }}{% unless forloop.last %},{% endunless %}
|
24
21
|
{% endfor %}
|
25
22
|
},
|
26
|
-
"pages": {{ site.pages |
|
27
|
-
"static
|
23
|
+
"pages": {{ site.pages | cc_safe_jsonify }},
|
24
|
+
"static": {{ site.static_files | cc_static_files_jsonify }}
|
28
25
|
}
|
@@ -0,0 +1,24 @@
|
|
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,41 +1,28 @@
|
|
1
1
|
{
|
2
|
-
"time": {{ site.time |
|
2
|
+
"time": {{ site.time | jsonify }},
|
3
3
|
"cloudcannon": {
|
4
4
|
"name": "cloudcannon-jekyll",
|
5
|
-
"version": {{ gem_version |
|
5
|
+
"version": {{ gem_version | jsonify }}
|
6
6
|
},
|
7
7
|
"generator": {
|
8
8
|
"name": "jekyll",
|
9
|
-
"version": {{ jekyll.version |
|
10
|
-
"environment": {{ jekyll.env |
|
9
|
+
"version": {{ jekyll.version | jsonify }},
|
10
|
+
"environment": {{ jekyll.env | jsonify }},
|
11
11
|
"metadata": {
|
12
|
-
"markdown": {{ site.markdown |
|
13
|
-
"kramdown": {{ site.kramdown |
|
14
|
-
"commonmark": {{ site.commonmark |
|
12
|
+
"markdown": {{ site.markdown | cc_safe_jsonify }},
|
13
|
+
"kramdown": {{ site.kramdown | cc_safe_jsonify }},
|
14
|
+
"commonmark": {{ site.commonmark | cc_safe_jsonify }}
|
15
15
|
}
|
16
16
|
},
|
17
|
-
{
|
18
|
-
"data": {
|
19
|
-
|
20
|
-
{%- for data in site.data %}
|
21
|
-
{%- assign key = data[0] %}
|
22
|
-
{%- if site.cloudcannon.data[key] %}
|
23
|
-
{%- if data_seen %},{% endif -%}
|
24
|
-
{{ data[0] | cc_jsonify }}: {{ data[1] | cc_jsonify }}
|
25
|
-
{%- assign data_seen = true %}
|
26
|
-
{%- endif %}
|
27
|
-
{%- endfor -%}
|
28
|
-
},
|
29
|
-
{% elsif site.cloudcannon.data -%}
|
30
|
-
"data": {{ site.data | cc_jsonify }},
|
31
|
-
{%- endif %}
|
17
|
+
{%- if site.cloudcannon.data %}
|
18
|
+
"data": {{ site.data | cc_safe_jsonify }},
|
19
|
+
{% endif %}
|
32
20
|
"collections": {
|
33
|
-
|
34
|
-
|
35
|
-
"{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}
|
21
|
+
{% for collection in site.collections -%}
|
22
|
+
"{{ collection.label | xml_escape }}": {{ collection.docs | cc_safe_jsonify }}
|
36
23
|
{%- unless forloop.last %},{% endunless %}
|
37
|
-
{%- endfor
|
24
|
+
{%- endfor %}
|
38
25
|
},
|
39
|
-
"pages": {{ site.pages |
|
40
|
-
"static
|
26
|
+
"pages": {{ site.pages | cc_safe_jsonify }},
|
27
|
+
"static": {{ site.static_files | cc_static_files_jsonify }}
|
41
28
|
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module CloudCannonJekyll
|
4
|
-
# Processes Jekyll configuration to enable the plugin is run and fix common issues
|
5
4
|
class Configuration
|
6
5
|
def self.processed?(site)
|
7
6
|
site.instance_variable_get(:@_cloudcannon_jekyll_processed) == true
|
@@ -17,7 +16,7 @@ module CloudCannonJekyll
|
|
17
16
|
config = config.fix_common_issues if config.respond_to? :fix_common_issues
|
18
17
|
config = config.add_default_excludes if config.respond_to? :add_default_excludes
|
19
18
|
|
20
|
-
key = Jekyll::VERSION.start_with?("2
|
19
|
+
key = Jekyll::VERSION.start_with?("2") ? "gems" : "plugins"
|
21
20
|
|
22
21
|
config[key] = Array(config[key])
|
23
22
|
config[key].push("cloudcannon-jekyll") unless config[key].include? "cloudcannon-jekyll"
|
@@ -2,157 +2,41 @@
|
|
2
2
|
|
3
3
|
require "jekyll"
|
4
4
|
require "fileutils"
|
5
|
-
require_relative "reader"
|
6
5
|
|
7
6
|
module CloudCannonJekyll
|
8
|
-
# Generates JSON files containing build config and build output details
|
9
7
|
class Generator < Jekyll::Generator
|
10
8
|
priority :lowest
|
11
9
|
|
12
10
|
def generate(site)
|
13
11
|
@site = site
|
14
|
-
|
15
|
-
|
16
|
-
collections_config = @site.config["collections"]&.dup || {}
|
17
|
-
|
18
|
-
# Workaround for empty collection configurations
|
19
|
-
collections_config.each_key do |key|
|
20
|
-
collections_config[key] ||= { "output" => false }
|
21
|
-
end
|
22
|
-
|
23
|
-
payload = @site.site_payload.merge({
|
24
|
-
"gem_version" => CloudCannonJekyll::VERSION,
|
25
|
-
})
|
26
|
-
|
27
|
-
drafts = add_blogging_config(collections_config)
|
28
|
-
add_collection_paths(collections_config)
|
29
|
-
add_data_config(collections_config)
|
30
|
-
|
31
|
-
generate_file("config", payload.merge({
|
32
|
-
"pwd" => Dir.pwd,
|
33
|
-
"config" => @site.config,
|
34
|
-
"collections" => collections_config,
|
35
|
-
}))
|
36
|
-
|
37
|
-
generate_file("details", payload.merge({
|
38
|
-
"drafts" => drafts,
|
39
|
-
}))
|
40
|
-
end
|
41
|
-
|
42
|
-
def collections_dir
|
43
|
-
return "" if Jekyll::VERSION.start_with? "2."
|
44
|
-
|
45
|
-
@site.config["collections_dir"] || ""
|
46
|
-
end
|
47
|
-
|
48
|
-
def data_dir
|
49
|
-
@site.config["data_dir"] || "_data"
|
50
|
-
end
|
51
|
-
|
52
|
-
# rubocop:disable Metrics/AbcSize
|
53
|
-
def add_category_folder_config(collections_config, posts_config = {})
|
54
|
-
posts = @site.posts || @site.collections["posts"]
|
55
|
-
docs = posts.class.method_defined?(:docs) ? posts.docs : posts
|
56
|
-
seen = {}
|
57
|
-
|
58
|
-
docs.map do |post|
|
59
|
-
parts = post.relative_path.split("/_posts/")
|
60
|
-
path = parts.first
|
61
|
-
|
62
|
-
# Ignore unless it's an unseen category folder post
|
63
|
-
next if parts.length < 2 || path.empty? || seen[path]
|
64
|
-
|
65
|
-
# Could check this to ensure raw files exist since posts can be generated without files
|
66
|
-
# next if @reader.read_posts(parts[0]).empty?
|
67
|
-
|
68
|
-
seen[path] = true
|
69
|
-
folder = path.sub(%r!^\/+!, "")
|
70
|
-
collections_path = "#{collections_dir}/#{folder}".gsub(%r!\/+!, "/").sub(%r!^\/+!, "")
|
71
|
-
|
72
|
-
collections_config["#{folder}/posts"] = posts_config.merge({
|
73
|
-
"_path" => "#{collections_path}/_posts",
|
74
|
-
})
|
75
|
-
|
76
|
-
# Adding the category draft config like this isn't ideal, since you could have drafts
|
77
|
-
# without posts, but it's a decent trade off vs looking for _drafts folders
|
78
|
-
collections_config["#{folder}/drafts"] = posts_config.merge({
|
79
|
-
"_path" => "#{collections_path}/_drafts",
|
80
|
-
})
|
81
|
-
|
82
|
-
path
|
83
|
-
end
|
84
|
-
end
|
85
|
-
# rubocop:enable Metrics/AbcSize
|
86
|
-
|
87
|
-
# Add data to collections config if raw data files exist
|
88
|
-
def add_data_config(collections_config)
|
89
|
-
data_files = @reader.read_data(data_dir)
|
90
|
-
collections_config["data"] = { "_path" => data_dir } if data_files&.keys&.any?
|
91
|
-
end
|
92
|
-
|
93
|
-
# Add posts/drafts to collections config
|
94
|
-
def add_blogging_config(collections_config)
|
95
|
-
collections_config["posts"] = { "output" => true } if Jekyll::VERSION.start_with? "2."
|
96
|
-
drafts = @reader.read_drafts(collections_dir)
|
97
|
-
|
98
|
-
if collections_config.key?("posts")
|
99
|
-
collections_config["drafts"] = collections_config["posts"]&.dup || {}
|
100
|
-
elsif drafts.any?
|
101
|
-
collections_config["drafts"] = {}
|
102
|
-
end
|
103
|
-
|
104
|
-
folders = add_category_folder_config(collections_config, collections_config["posts"])
|
105
|
-
folders.compact.each do |folder|
|
106
|
-
drafts += @reader.read_drafts(folder)
|
107
|
-
end
|
108
|
-
|
109
|
-
drafts
|
110
|
-
end
|
111
|
-
|
112
|
-
# Add _path to each collection config
|
113
|
-
def add_collection_paths(collections_config)
|
114
|
-
collections_config.each do |key, collection|
|
115
|
-
next if collection.key?("_path")
|
116
|
-
|
117
|
-
collection["_path"] = File.join(collections_dir, "_#{key}").sub(%r!^\/+!, "")
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
def generate_file(filename, data)
|
122
|
-
dest = destination_path(filename)
|
123
|
-
FileUtils.mkdir_p(File.dirname(dest))
|
124
|
-
File.open(dest, "w") { |file| file.write(file_content(filename, data)) }
|
12
|
+
FileUtils.mkdir_p(File.dirname(destination_path))
|
13
|
+
File.open(destination_path, "w") { |f| f.write(file_content) }
|
125
14
|
@site.keep_files ||= []
|
126
|
-
@site.keep_files <<
|
15
|
+
@site.keep_files << "_cloudcannon/details.json"
|
127
16
|
end
|
128
17
|
|
129
|
-
def
|
130
|
-
|
131
|
-
|
18
|
+
def source_path
|
19
|
+
path = "_cloudcannon/details.json"
|
20
|
+
path = "_cloudcannon/details-2.x.json" if Jekyll::VERSION.start_with? "2."
|
21
|
+
path = "_cloudcannon/details-3.0.x.json" if Jekyll::VERSION.match? %r!3\.[0-4]\.!
|
132
22
|
|
133
|
-
|
23
|
+
File.expand_path(path, File.dirname(__FILE__))
|
134
24
|
end
|
135
25
|
|
136
|
-
def
|
137
|
-
"_cloudcannon
|
26
|
+
def destination_path
|
27
|
+
Jekyll.sanitized_path(@site.dest, "_cloudcannon/details.json")
|
138
28
|
end
|
139
29
|
|
140
|
-
def
|
141
|
-
|
142
|
-
|
30
|
+
def file_content
|
31
|
+
json = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", "_cloudcannon/details.json")
|
32
|
+
json.content = File.read(source_path)
|
143
33
|
|
144
|
-
|
145
|
-
|
146
|
-
|
34
|
+
json.data["layout"] = nil
|
35
|
+
json.data["sitemap"] = false
|
36
|
+
json.data["permalink"] = "/_cloudcannon/details.json"
|
147
37
|
|
148
|
-
|
149
|
-
|
150
|
-
page.content = File.read(source_path(filename))
|
151
|
-
page.data["layout"] = nil
|
152
|
-
page.data["sitemap"] = false
|
153
|
-
page.data["permalink"] = "/#{path(filename)}"
|
154
|
-
page.render({}, data)
|
155
|
-
page.output
|
38
|
+
json.render({}, @site.site_payload.merge("gem_version" => CloudCannonJekyll::VERSION))
|
39
|
+
json.output
|
156
40
|
end
|
157
41
|
end
|
158
42
|
end
|