cloudcannon-jekyll 1.0.3 → 1.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/.gitignore +1 -0
- data/.rubocop.yml +17 -2
- data/.travis.yml +1 -1
- data/Gemfile +2 -0
- data/HISTORY.md +29 -0
- data/cloudcannon-jekyll.gemspec +5 -4
- data/lib/cloudcannon-jekyll.rb +2 -2
- data/lib/cloudcannon-jekyll/_cloudcannon/config-2.x.json +30 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/config-3.0-4.x.json +30 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/config.json +53 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/details-2.x.json +14 -12
- data/lib/cloudcannon-jekyll/_cloudcannon/details-3.0-4.x.json +26 -0
- data/lib/cloudcannon-jekyll/_cloudcannon/details.json +26 -14
- data/lib/cloudcannon-jekyll/generator.rb +36 -16
- data/lib/cloudcannon-jekyll/jsonify-filter.rb +218 -0
- data/lib/cloudcannon-jekyll/version.rb +1 -1
- data/script/ci-smoke-test +11 -0
- data/script/cibuild +1 -2
- data/script/test +1 -0
- metadata +27 -10
- data/lib/cloudcannon-jekyll/_cloudcannon/details-3.0.x.json +0 -24
- data/lib/cloudcannon-jekyll/safe-jsonify-filter.rb +0 -169
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ced0f81dcb95e29ce12684d892c70e0b55cfe2b6f6b0c4558350ff67fab44274
|
4
|
+
data.tar.gz: fc357e889e99d0f76b64b45da546ec276413c644ca3653bb3a7f246eff01b668
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 459133474faa360db525f125120e3b5fe9a94387ce81ed3cea4b1fba714a80c98959a31b34b5f93f28ce1677da7afc3f4bfe7ed59681abd6ba924361af13867c
|
7
|
+
data.tar.gz: d742c5b8251541ec83383a510a0ab93d3f30d88dea601e2ccbacb2136908c162d5cdf166f23e749106f014eaa47e7eaa52db84f43e82ee48d82c87836a4e2853
|
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.4
|
8
8
|
Include:
|
9
9
|
- lib/**/*.rb
|
10
10
|
|
@@ -20,8 +20,23 @@ AllCops:
|
|
20
20
|
- script/**/*
|
21
21
|
- vendor/**/*
|
22
22
|
- gemfiles/**/*
|
23
|
-
- lib/cloudcannon-jekyll/safe-jsonify-filter.rb # TODO remove this and fix warnings
|
24
23
|
|
25
24
|
Naming/MemoizedInstanceVariableName:
|
26
25
|
Exclude:
|
27
26
|
- 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
|
+
|
32
|
+
Metrics/PerceivedComplexity:
|
33
|
+
Exclude:
|
34
|
+
- lib/cloudcannon-jekyll/jsonify-filter.rb # TODO remove this and fix warnings
|
35
|
+
|
36
|
+
Metrics/MethodLength:
|
37
|
+
Exclude:
|
38
|
+
- lib/cloudcannon-jekyll/jsonify-filter.rb # TODO remove this and fix warnings
|
39
|
+
|
40
|
+
Metrics/AbcSize:
|
41
|
+
Exclude:
|
42
|
+
- lib/cloudcannon-jekyll/jsonify-filter.rb # TODO remove this and fix warnings
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
# 1.3.1
|
2
|
+
|
3
|
+
* Fix source being output as full path on disk
|
4
|
+
* Read content for output config file directly from site config
|
5
|
+
|
6
|
+
# 1.3.0
|
7
|
+
|
8
|
+
* Add defaults and input-options keys to config output
|
9
|
+
|
10
|
+
# 1.2.3
|
11
|
+
|
12
|
+
* Add more ignore keys for legacy select data filter
|
13
|
+
|
14
|
+
# 1.2.2
|
15
|
+
|
16
|
+
* Reduce methods added from other plugins clashing
|
17
|
+
|
18
|
+
# 1.2.1
|
19
|
+
|
20
|
+
* Fix invalid output when unsupported class found
|
21
|
+
|
22
|
+
# 1.2.0
|
23
|
+
|
24
|
+
* Add output config file
|
25
|
+
|
26
|
+
# 1.1.0
|
27
|
+
|
28
|
+
* Add support for including only specified `data` keys
|
29
|
+
|
1
30
|
# 1.0.3
|
2
31
|
|
3
32
|
* Fix invalid JSON issue for sites built with Jekyll 2 and no collections
|
data/cloudcannon-jekyll.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path("
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
require "cloudcannon-jekyll/version"
|
@@ -23,8 +23,9 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_dependency "jekyll", ">= 2.4.0", "< 5"
|
25
25
|
|
26
|
+
spec.add_development_dependency "json_schemer", "~> 0.2.13"
|
26
27
|
spec.add_development_dependency "rake", "~> 13.0"
|
27
28
|
spec.add_development_dependency "rspec", "~> 3.9"
|
28
|
-
spec.add_development_dependency "rubocop", "~> 0.
|
29
|
-
spec.add_development_dependency "rubocop-jekyll", "~> 0.
|
29
|
+
spec.add_development_dependency "rubocop", "~> 0.80"
|
30
|
+
spec.add_development_dependency "rubocop-jekyll", "~> 0.11"
|
30
31
|
end
|
data/lib/cloudcannon-jekyll.rb
CHANGED
@@ -5,10 +5,10 @@ require "jekyll"
|
|
5
5
|
require_relative "cloudcannon-jekyll/page-without-a-file"
|
6
6
|
require_relative "cloudcannon-jekyll/generator"
|
7
7
|
require_relative "cloudcannon-jekyll/configuration"
|
8
|
-
require_relative "cloudcannon-jekyll/
|
8
|
+
require_relative "cloudcannon-jekyll/jsonify-filter"
|
9
9
|
require_relative "cloudcannon-jekyll/version"
|
10
10
|
|
11
|
-
Liquid::Template.register_filter(CloudCannonJekyll::
|
11
|
+
Liquid::Template.register_filter(CloudCannonJekyll::JsonifyFilter)
|
12
12
|
|
13
13
|
# Hooks didn't exist in Jekyll 2 so we monkey patch to get an :after_reset hook
|
14
14
|
if Jekyll::VERSION.start_with? "2"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
{% if config.timezone %}"timezone": {{ config.timezone | cc_jsonify }},{% endif %}
|
3
|
+
"include": {{ config.include | cc_jsonify }},
|
4
|
+
"exclude": {{ config.exclude | cc_jsonify }},
|
5
|
+
{% if config.baseurl %}"base-url": {{ config.baseurl | cc_jsonify }},{% endif %}
|
6
|
+
{% if config.collections %}"comments": {{ config.collections | cc_jsonify: 'collections' }},{% endif %}
|
7
|
+
{% if config._comments %}"comments": {{ config._comments | cc_jsonify }},{% endif %}
|
8
|
+
{% if config._options %}"input-options": {{ config._options | cc_jsonify }},{% endif %}
|
9
|
+
{% if config.defaults %}"defaults": {{ config.defaults | cc_jsonify }},{% endif %}
|
10
|
+
{% if config._editor %}"editor": {
|
11
|
+
"default-path": {{ config._editor.default_path | cc_jsonify }}
|
12
|
+
},{% endif %}
|
13
|
+
{% if config._source_editor %}"source-editor": {
|
14
|
+
"tab-size": {{ config._source_editor.tab_size | cc_jsonify }},
|
15
|
+
"show-gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
|
16
|
+
"theme": {{ config._source_editor.theme | cc_jsonify }}
|
17
|
+
},{% endif %}
|
18
|
+
{% if config._explore %}"explore": {{ config._explore | cc_jsonify }},{% endif %}
|
19
|
+
"paths": {
|
20
|
+
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
21
|
+
"plugins": {{ config.plugins_dir | cc_jsonify }},
|
22
|
+
"data": {{ config.data_dir | cc_jsonify }},
|
23
|
+
"collections": {{ config.collections_dir | cc_jsonify }},
|
24
|
+
"includes": {{ config.includes_dir | cc_jsonify }},
|
25
|
+
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
26
|
+
},
|
27
|
+
{% if config._array_structures %}"array-structures": {{ config._array_structures | cc_jsonify }},{% endif %}
|
28
|
+
{% assign select_data = config | cc_select_data_jsonify %}{% if select_data %}"select-data": {{ select_data }},{% endif %}
|
29
|
+
"source": {{ config.source | replace: pwd, "" | cc_jsonify }}
|
30
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
{
|
2
|
+
{% if config.timezone %}"timezone": {{ config.timezone | cc_jsonify }},{% endif %}
|
3
|
+
"include": {{ config.include | cc_jsonify }},
|
4
|
+
"exclude": {{ config.exclude | cc_jsonify }},
|
5
|
+
{% if config.baseurl %}"base-url": {{ config.baseurl | cc_jsonify }},{% endif %}
|
6
|
+
{% if config.collections %}"comments": {{ config.collections | cc_jsonify: 'collections' }},{% endif %}
|
7
|
+
{% if config._comments %}"comments": {{ config._comments | cc_jsonify }},{% endif %}
|
8
|
+
{% if config._options %}"input-options": {{ config._options | cc_jsonify }},{% endif %}
|
9
|
+
{% if config.defaults %}"defaults": {{ config.defaults | cc_jsonify }},{% endif %}
|
10
|
+
{% if config._editor %}"editor": {
|
11
|
+
"default-path": {{ config._editor.default_path | cc_jsonify }}
|
12
|
+
},{% endif %}
|
13
|
+
{% if config._source_editor %}"source-editor": {
|
14
|
+
"tab-size": {{ config._source_editor.tab_size | cc_jsonify }},
|
15
|
+
"show-gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
|
16
|
+
"theme": {{ config._source_editor.theme | cc_jsonify }}
|
17
|
+
},{% endif %}
|
18
|
+
{% if config._explore %}"explore": {{ config._explore | cc_jsonify }},{% endif %}
|
19
|
+
"paths": {
|
20
|
+
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
21
|
+
"plugins": {{ config.plugins_dir | cc_jsonify }},
|
22
|
+
"data": {{ config.data_dir | cc_jsonify }},
|
23
|
+
"collections": {{ config.collections_dir | cc_jsonify }},
|
24
|
+
"includes": {{ config.includes_dir | cc_jsonify }},
|
25
|
+
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
26
|
+
},
|
27
|
+
{% if config._array_structures %}"array-structures": {{ config._array_structures | cc_jsonify }},{% endif %}
|
28
|
+
{% assign select_data = config | cc_select_data_jsonify %}{% if select_data %}"select-data": {{ select_data }},{% endif %}
|
29
|
+
"source": {{ config.source | replace: pwd, "" | cc_jsonify }}
|
30
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
{
|
2
|
+
{% if config.timezone -%}
|
3
|
+
"timezone": {{ config.timezone | cc_jsonify }},
|
4
|
+
{%- endif %}
|
5
|
+
"include": {{ config.include | cc_jsonify }},
|
6
|
+
"exclude": {{ config.exclude | cc_jsonify }},
|
7
|
+
{% if config.baseurl -%}
|
8
|
+
"base-url": {{ config.baseurl | cc_jsonify }},
|
9
|
+
{%- endif %}
|
10
|
+
{% if config.collections -%}
|
11
|
+
"collections": {{ config.collections | cc_jsonify: 'collections' }},
|
12
|
+
{%- endif %}
|
13
|
+
{% if config._comments -%}
|
14
|
+
"comments": {{ config._comments | cc_jsonify }},
|
15
|
+
{%- endif %}
|
16
|
+
{% if config._options -%}
|
17
|
+
"input-options": {{ config._options | cc_jsonify }},
|
18
|
+
{%- endif %}
|
19
|
+
{% if config.defaults -%}
|
20
|
+
"defaults": {{ config.defaults | cc_jsonify }},
|
21
|
+
{%- endif %}
|
22
|
+
{% if config._editor -%}
|
23
|
+
"editor": {
|
24
|
+
"default-path": {{ config._editor.default_path | cc_jsonify }}
|
25
|
+
},
|
26
|
+
{%- endif %}
|
27
|
+
{% if config._source_editor -%}
|
28
|
+
"source-editor": {
|
29
|
+
"tab-size": {{ config._source_editor.tab_size | cc_jsonify }},
|
30
|
+
"show-gutter": {{ config._source_editor.show_gutter | cc_jsonify }},
|
31
|
+
"theme": {{ config._source_editor.theme | cc_jsonify }}
|
32
|
+
},
|
33
|
+
{%- endif %}
|
34
|
+
{% if config._explore -%}
|
35
|
+
"explore": {{ config._explore | cc_jsonify }},
|
36
|
+
{%- endif %}
|
37
|
+
"paths": {
|
38
|
+
"uploads": {{ config.uploads_dir | cc_jsonify }},
|
39
|
+
"plugins": {{ config.plugins_dir | cc_jsonify }},
|
40
|
+
"data": {{ config.data_dir | cc_jsonify }},
|
41
|
+
"collections": {{ config.collections_dir | cc_jsonify }},
|
42
|
+
"includes": {{ config.includes_dir | cc_jsonify }},
|
43
|
+
"layouts": {{ config.layouts_dir | cc_jsonify }}
|
44
|
+
},
|
45
|
+
{% if config._array_structures -%}
|
46
|
+
"array-structures": {{ config._array_structures | cc_jsonify }},
|
47
|
+
{%- endif %}
|
48
|
+
{% assign select_data = config | cc_select_data_jsonify -%}
|
49
|
+
{% if select_data -%}
|
50
|
+
"select-data": {{ select_data }},
|
51
|
+
{%- endif %}
|
52
|
+
"source": {{ config.source | replace: pwd, "" | cc_jsonify }}
|
53
|
+
}
|
@@ -1,25 +1,27 @@
|
|
1
1
|
{
|
2
|
-
"time": {{ site.time |
|
2
|
+
"time": {{ site.time | cc_jsonify }},
|
3
3
|
"cloudcannon": {
|
4
4
|
"name": "cloudcannon-jekyll",
|
5
|
-
"version": {{ gem_version |
|
5
|
+
"version": {{ gem_version | cc_jsonify }}
|
6
6
|
},
|
7
7
|
"generator": {
|
8
8
|
"name": "jekyll",
|
9
|
-
"version": {{ jekyll.version |
|
10
|
-
"environment": {{ jekyll.env |
|
9
|
+
"version": {{ jekyll.version | cc_jsonify }},
|
10
|
+
"environment": {{ jekyll.env | cc_jsonify }},
|
11
11
|
"metadata": {
|
12
|
-
"markdown": {{ site.markdown |
|
13
|
-
"kramdown": {{ site.kramdown |
|
14
|
-
"commonmark": {{ site.commonmark |
|
12
|
+
"markdown": {{ site.markdown | cc_jsonify }},
|
13
|
+
"kramdown": {{ site.kramdown | cc_jsonify }},
|
14
|
+
"commonmark": {{ site.commonmark | cc_jsonify }}
|
15
15
|
}
|
16
|
-
},{% if site.cloudcannon.data %}
|
17
|
-
"data": {
|
16
|
+
},{% if site.cloudcannon.data.first %}{% assign data_seen = false %}
|
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 %}
|
18
20
|
"collections": {
|
19
|
-
"posts": {{ site.posts | reverse |
|
20
|
-
{% for collection in site.collections %}"{{ collection[0] | xml_escape }}": {{ collection[1].docs |
|
21
|
+
"posts": {{ site.posts | reverse | cc_jsonify }}{% if site.collections.size > 0 %},{% endif %}
|
22
|
+
{% for collection in site.collections %}"{{ collection[0] | xml_escape }}": {{ collection[1].docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
21
23
|
{% endfor %}
|
22
24
|
},
|
23
|
-
"pages": {{ site.pages |
|
25
|
+
"pages": {{ site.pages | cc_jsonify }},
|
24
26
|
"static": {{ site.static_files | cc_static_files_jsonify }}
|
25
27
|
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"time": {{ site.time | cc_jsonify }},
|
3
|
+
"cloudcannon": {
|
4
|
+
"name": "cloudcannon-jekyll",
|
5
|
+
"version": {{ gem_version | cc_jsonify }}
|
6
|
+
},
|
7
|
+
"generator": {
|
8
|
+
"name": "jekyll",
|
9
|
+
"version": {{ jekyll.version | cc_jsonify }},
|
10
|
+
"environment": {{ jekyll.env | cc_jsonify }},
|
11
|
+
"metadata": {
|
12
|
+
"markdown": {{ site.markdown | cc_jsonify }},
|
13
|
+
"kramdown": {{ site.kramdown | cc_jsonify }},
|
14
|
+
"commonmark": {{ site.commonmark | cc_jsonify }}
|
15
|
+
}
|
16
|
+
},{% if site.cloudcannon.data.first %}{% assign data_seen = false %}
|
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 %}
|
20
|
+
"collections": {
|
21
|
+
{% for collection in site.collections %}"{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}{% unless forloop.last %},{% endunless %}
|
22
|
+
{% endfor %}
|
23
|
+
},
|
24
|
+
"pages": {{ site.pages | cc_jsonify }},
|
25
|
+
"static": {{ site.static_files | cc_static_files_jsonify }}
|
26
|
+
}
|
@@ -1,28 +1,40 @@
|
|
1
1
|
{
|
2
|
-
"time": {{ site.time |
|
2
|
+
"time": {{ site.time | cc_jsonify }},
|
3
3
|
"cloudcannon": {
|
4
4
|
"name": "cloudcannon-jekyll",
|
5
|
-
"version": {{ gem_version |
|
5
|
+
"version": {{ gem_version | cc_jsonify }}
|
6
6
|
},
|
7
7
|
"generator": {
|
8
8
|
"name": "jekyll",
|
9
|
-
"version": {{ jekyll.version |
|
10
|
-
"environment": {{ jekyll.env |
|
9
|
+
"version": {{ jekyll.version | cc_jsonify }},
|
10
|
+
"environment": {{ jekyll.env | cc_jsonify }},
|
11
11
|
"metadata": {
|
12
|
-
"markdown": {{ site.markdown |
|
13
|
-
"kramdown": {{ site.kramdown |
|
14
|
-
"commonmark": {{ site.commonmark |
|
12
|
+
"markdown": {{ site.markdown | cc_jsonify }},
|
13
|
+
"kramdown": {{ site.kramdown | cc_jsonify }},
|
14
|
+
"commonmark": {{ site.commonmark | cc_jsonify }}
|
15
15
|
}
|
16
16
|
},
|
17
|
-
{
|
18
|
-
"data": {
|
19
|
-
|
17
|
+
{% if site.cloudcannon.data.first -%}
|
18
|
+
"data": {
|
19
|
+
{%- assign data_seen = false %}
|
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 %}
|
20
32
|
"collections": {
|
21
|
-
{
|
22
|
-
"{{ collection.label | xml_escape }}": {{ collection.docs |
|
33
|
+
{%- for collection in site.collections -%}
|
34
|
+
"{{ collection.label | xml_escape }}": {{ collection.docs | cc_jsonify }}
|
23
35
|
{%- unless forloop.last %},{% endunless %}
|
24
|
-
{%- endfor
|
36
|
+
{%- endfor -%}
|
25
37
|
},
|
26
|
-
"pages": {{ site.pages |
|
38
|
+
"pages": {{ site.pages | cc_jsonify }},
|
27
39
|
"static": {{ site.static_files | cc_static_files_jsonify }}
|
28
40
|
}
|
@@ -9,33 +9,53 @@ module CloudCannonJekyll
|
|
9
9
|
|
10
10
|
def generate(site)
|
11
11
|
@site = site
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
payload = @site.site_payload.merge({
|
14
|
+
"gem_version" => CloudCannonJekyll::VERSION,
|
15
|
+
"pwd" => Dir.pwd,
|
16
|
+
"config" => @site.config,
|
17
|
+
})
|
18
|
+
|
19
|
+
generate_file("details", payload)
|
20
|
+
generate_file("config", payload)
|
21
|
+
|
14
22
|
@site.keep_files ||= []
|
15
|
-
@site.keep_files << "
|
23
|
+
@site.keep_files << path("details")
|
24
|
+
@site.keep_files << path("config")
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_file(filename, data)
|
28
|
+
dest = destination_path(filename)
|
29
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
30
|
+
File.open(dest, "w") { |f| f.write(file_content(filename, data)) }
|
16
31
|
end
|
17
32
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
path = "_cloudcannon/details-3.0.x.json" if Jekyll::VERSION.match? %r!3\.[0-4]\.!
|
33
|
+
def version_path_suffix
|
34
|
+
return "-2.x" if Jekyll::VERSION.start_with? "2."
|
35
|
+
return "-3.0-4.x" if Jekyll::VERSION.match? %r!3\.[0-4]\.!
|
22
36
|
|
23
|
-
|
37
|
+
""
|
24
38
|
end
|
25
39
|
|
26
|
-
def
|
27
|
-
|
40
|
+
def path(filename, suffix = "")
|
41
|
+
"_cloudcannon/#{filename}#{suffix}.json"
|
28
42
|
end
|
29
43
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
44
|
+
def source_path(filename)
|
45
|
+
File.expand_path(path(filename, version_path_suffix), File.dirname(__FILE__))
|
46
|
+
end
|
47
|
+
|
48
|
+
def destination_path(filename)
|
49
|
+
Jekyll.sanitized_path(@site.dest, path(filename))
|
50
|
+
end
|
33
51
|
|
52
|
+
def file_content(filename, data)
|
53
|
+
json = PageWithoutAFile.new(@site, File.dirname(__FILE__), "", path(filename))
|
54
|
+
json.content = File.read(source_path(filename))
|
34
55
|
json.data["layout"] = nil
|
35
56
|
json.data["sitemap"] = false
|
36
|
-
json.data["permalink"] = "
|
37
|
-
|
38
|
-
json.render({}, @site.site_payload.merge("gem_version" => CloudCannonJekyll::VERSION))
|
57
|
+
json.data["permalink"] = "/#{path(filename)}"
|
58
|
+
json.render({}, data)
|
39
59
|
json.output
|
40
60
|
end
|
41
61
|
end
|
@@ -0,0 +1,218 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "jekyll"
|
4
|
+
|
5
|
+
module CloudCannonJekyll
|
6
|
+
module JsonifyFilter
|
7
|
+
CC_JSONIFY_KEY_SWAPS = {
|
8
|
+
"collections" => {
|
9
|
+
"_sort_key" => "_sort-key",
|
10
|
+
"_subtext_key" => "_subtext-key",
|
11
|
+
"_image_key" => "_image-key",
|
12
|
+
"_image_size" => "_image-size",
|
13
|
+
"_singular_name" => "_singular-name",
|
14
|
+
"_singular_key" => "_singular-key",
|
15
|
+
"_disable_add" => "_disable-add",
|
16
|
+
"_icon" => "_icon",
|
17
|
+
"_add_options" => "_add-options",
|
18
|
+
},
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
@simple_types = [
|
22
|
+
String,
|
23
|
+
Numeric,
|
24
|
+
Integer,
|
25
|
+
Float,
|
26
|
+
Date,
|
27
|
+
Time,
|
28
|
+
NilClass,
|
29
|
+
].freeze
|
30
|
+
|
31
|
+
@document_types = [
|
32
|
+
Jekyll::Document,
|
33
|
+
Jekyll::Page,
|
34
|
+
Jekyll::VERSION.start_with?("2.") ? Jekyll::Post : nil,
|
35
|
+
].compact.freeze
|
36
|
+
|
37
|
+
def self.document_type?(input)
|
38
|
+
@document_types.include?(input.class)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.simple_type?(input)
|
42
|
+
@simple_types.include?(input.class) || [true, false].include?(input)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.static_file_to_json(input, depth)
|
46
|
+
out = [
|
47
|
+
"\"extname\": #{JsonifyFilter.to_json(input.extname, depth + 1)}",
|
48
|
+
"\"path\": #{JsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
49
|
+
]
|
50
|
+
|
51
|
+
# modified_time isn't defined in Jekyll 2.4.0
|
52
|
+
if input.respond_to? :modified_time
|
53
|
+
out.push("\"modified_time\": #{JsonifyFilter.to_json(input.modified_time, depth + 1)}")
|
54
|
+
end
|
55
|
+
|
56
|
+
"{#{out.join(",")}}"
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.document_data_to_json(data, out, prevent, depth)
|
60
|
+
prevent += %w(content output next previous excerpt)
|
61
|
+
|
62
|
+
data.each do |key, value|
|
63
|
+
next if prevent.include? key
|
64
|
+
|
65
|
+
prevent.push key
|
66
|
+
out.push("#{key.to_json}: #{JsonifyFilter.to_json(value, depth + 1)}")
|
67
|
+
end
|
68
|
+
|
69
|
+
"{#{out.join(",")}}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.legacy_post_to_json(input, depth)
|
73
|
+
prevent = %w(dir name path url date id categories tags)
|
74
|
+
|
75
|
+
out = [
|
76
|
+
"\"dir\": #{JsonifyFilter.to_json(input.dir, depth + 1)}",
|
77
|
+
"\"name\": #{JsonifyFilter.to_json(input.name, depth + 1)}",
|
78
|
+
"\"path\": #{JsonifyFilter.to_json(input.path, depth + 1)}",
|
79
|
+
"\"url\": #{JsonifyFilter.to_json(input.url, depth + 1)}",
|
80
|
+
"\"date\": #{JsonifyFilter.to_json(input.date, depth + 1)}",
|
81
|
+
"\"id\": #{JsonifyFilter.to_json(input.id, depth + 1)}",
|
82
|
+
"\"categories\": #{JsonifyFilter.to_json(input.categories, depth + 1)}",
|
83
|
+
"\"tags\": #{JsonifyFilter.to_json(input.tags, depth + 1)}",
|
84
|
+
]
|
85
|
+
|
86
|
+
JsonifyFilter.document_data_to_json(input.data, out, prevent, depth)
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.page_to_json(input, depth)
|
90
|
+
prevent = %w(dir name path url)
|
91
|
+
|
92
|
+
out = [
|
93
|
+
"\"dir\": #{JsonifyFilter.to_json(input.dir, depth + 1)}",
|
94
|
+
"\"name\": #{JsonifyFilter.to_json(input.name, depth + 1)}",
|
95
|
+
"\"path\": #{JsonifyFilter.to_json(input.path, depth + 1)}",
|
96
|
+
"\"url\": #{JsonifyFilter.to_json(input.url, depth + 1)}",
|
97
|
+
]
|
98
|
+
|
99
|
+
# Merge Jekyll Defaults into data for pages (missing at v3.8.5)
|
100
|
+
defaults = input.site.frontmatter_defaults.all(input.relative_path, :pages).tap do |h|
|
101
|
+
h.delete("date")
|
102
|
+
end
|
103
|
+
|
104
|
+
data = Jekyll::Utils.deep_merge_hashes(defaults, input.data)
|
105
|
+
JsonifyFilter.document_data_to_json(data, out, prevent, depth)
|
106
|
+
end
|
107
|
+
|
108
|
+
def self.document_to_json(input, depth)
|
109
|
+
prevent = %w(dir id relative_path url collection)
|
110
|
+
|
111
|
+
out = [
|
112
|
+
"\"path\": #{JsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
113
|
+
"\"relative_path\": #{JsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
114
|
+
"\"url\": #{JsonifyFilter.to_json(input.url, depth + 1)}",
|
115
|
+
]
|
116
|
+
|
117
|
+
unless input.collection.nil?
|
118
|
+
out.push("\"collection\": #{JsonifyFilter.to_json(input.collection.label, depth + 1)}")
|
119
|
+
end
|
120
|
+
|
121
|
+
# id isn't defined in Jekyll 2.4.0
|
122
|
+
out.push("\"id\": #{JsonifyFilter.to_json(input.id, depth + 1)}") if input.respond_to? :id
|
123
|
+
|
124
|
+
JsonifyFilter.document_data_to_json(input.data, out, prevent, depth)
|
125
|
+
end
|
126
|
+
|
127
|
+
def self.array_to_json(input, depth, key_swaps = {})
|
128
|
+
array = input.map do |value|
|
129
|
+
JsonifyFilter.to_json(value, depth + 1, key_swaps)
|
130
|
+
end
|
131
|
+
|
132
|
+
"[#{array.join(",")}]"
|
133
|
+
end
|
134
|
+
|
135
|
+
def self.hash_to_json(input, depth, key_swaps = {})
|
136
|
+
hash = input.map do |key, value|
|
137
|
+
"#{(key_swaps[key] || key).to_json}: #{JsonifyFilter.to_json(value, depth + 1, key_swaps)}"
|
138
|
+
end
|
139
|
+
|
140
|
+
"{#{hash.join(",")}}"
|
141
|
+
end
|
142
|
+
|
143
|
+
def self.config_to_select_data_json(input, depth)
|
144
|
+
prevent = %w(source destination collections_dir cache_dir plugins_dir layouts_dir data_dir
|
145
|
+
includes_dir collections safe include exclude keep_files encoding markdown_ext
|
146
|
+
strict_front_matter show_drafts limit_posts future unpublished whitelist
|
147
|
+
plugins markdown highlighter lsi excerpt_separator incremental detach port host
|
148
|
+
baseurl show_dir_listing permalink paginate_path timezone quiet verbose defaults
|
149
|
+
liquid kramdown title url description uploads_dir _comments _options _editor
|
150
|
+
_explore _source_editor _array_structures maruku redcloth rdiscount redcarpet
|
151
|
+
gems plugins)
|
152
|
+
|
153
|
+
out = input.map do |key, value|
|
154
|
+
next unless value.is_a?(Array) || value.is_a?(Hash)
|
155
|
+
next if prevent.include? key
|
156
|
+
|
157
|
+
prevent.push key
|
158
|
+
"#{key.to_json}: #{JsonifyFilter.to_json(value, depth + 1)}"
|
159
|
+
end
|
160
|
+
|
161
|
+
out.compact
|
162
|
+
|
163
|
+
"{#{out.join(",")}}" if out.any?
|
164
|
+
end
|
165
|
+
|
166
|
+
def self.to_json(input, depth, key_swaps = {})
|
167
|
+
if depth > 8 || (depth > 2 && JsonifyFilter.document_type?(input))
|
168
|
+
'"MAXIMUM_DEPTH"'
|
169
|
+
elsif JsonifyFilter.simple_type?(input)
|
170
|
+
input.to_json
|
171
|
+
elsif input.is_a?(Jekyll::StaticFile)
|
172
|
+
JsonifyFilter.static_file_to_json(input, depth)
|
173
|
+
elsif input.is_a?(Jekyll::Page)
|
174
|
+
JsonifyFilter.page_to_json(input, depth)
|
175
|
+
elsif Jekyll::VERSION.start_with?("2.") && input.is_a?(Jekyll::Post)
|
176
|
+
JsonifyFilter.legacy_post_to_json(input, depth)
|
177
|
+
elsif input.is_a?(Jekyll::Document)
|
178
|
+
JsonifyFilter.document_to_json(input, depth)
|
179
|
+
elsif input.is_a?(Array)
|
180
|
+
JsonifyFilter.array_to_json(input, depth, key_swaps)
|
181
|
+
elsif input.is_a?(Hash)
|
182
|
+
JsonifyFilter.hash_to_json(input, depth, key_swaps)
|
183
|
+
else
|
184
|
+
input.class.to_s.prepend("UNSUPPORTED:").to_json
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
def cc_static_files_jsonify(input)
|
189
|
+
out = []
|
190
|
+
input.each do |page|
|
191
|
+
next if page.extname != ".html" &&
|
192
|
+
page.extname != ".htm" &&
|
193
|
+
page.path != "/robots.txt" &&
|
194
|
+
page.path != "/sitemap.xml"
|
195
|
+
|
196
|
+
out.push(JsonifyFilter.to_json(page, 1))
|
197
|
+
end
|
198
|
+
|
199
|
+
"[#{out.join(",")}]"
|
200
|
+
end
|
201
|
+
|
202
|
+
def cc_select_data_jsonify(input)
|
203
|
+
if input.key? "_select_data"
|
204
|
+
JsonifyFilter.to_json(input["_select_data"], 0)
|
205
|
+
else
|
206
|
+
JsonifyFilter.config_to_select_data_json(input, 0)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def cc_jsonify(input, key_swaps_key = nil)
|
211
|
+
if CC_JSONIFY_KEY_SWAPS.key? key_swaps_key
|
212
|
+
JsonifyFilter.to_json(input, 0, CC_JSONIFY_KEY_SWAPS[key_swaps_key])
|
213
|
+
else
|
214
|
+
JsonifyFilter.to_json(input, 0)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
@@ -0,0 +1,11 @@
|
|
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.8.5 bundle update && $(dirname "$0")/test &&
|
11
|
+
JEKYLL_VERSION=4.1.1 bundle update && $(dirname "$0")/test
|
data/script/cibuild
CHANGED
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: 1.
|
4
|
+
version: 1.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:
|
11
|
+
date: 2020-09-09 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: '5'
|
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.13
|
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.13
|
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
|
@@ -104,14 +118,18 @@ files:
|
|
104
118
|
- Rakefile
|
105
119
|
- cloudcannon-jekyll.gemspec
|
106
120
|
- lib/cloudcannon-jekyll.rb
|
121
|
+
- lib/cloudcannon-jekyll/_cloudcannon/config-2.x.json
|
122
|
+
- lib/cloudcannon-jekyll/_cloudcannon/config-3.0-4.x.json
|
123
|
+
- lib/cloudcannon-jekyll/_cloudcannon/config.json
|
107
124
|
- lib/cloudcannon-jekyll/_cloudcannon/details-2.x.json
|
108
|
-
- lib/cloudcannon-jekyll/_cloudcannon/details-3.0.x.json
|
125
|
+
- lib/cloudcannon-jekyll/_cloudcannon/details-3.0-4.x.json
|
109
126
|
- lib/cloudcannon-jekyll/_cloudcannon/details.json
|
110
127
|
- lib/cloudcannon-jekyll/configuration.rb
|
111
128
|
- lib/cloudcannon-jekyll/generator.rb
|
129
|
+
- lib/cloudcannon-jekyll/jsonify-filter.rb
|
112
130
|
- lib/cloudcannon-jekyll/page-without-a-file.rb
|
113
|
-
- lib/cloudcannon-jekyll/safe-jsonify-filter.rb
|
114
131
|
- lib/cloudcannon-jekyll/version.rb
|
132
|
+
- script/ci-smoke-test
|
115
133
|
- script/cibuild
|
116
134
|
- script/release
|
117
135
|
- script/test
|
@@ -134,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
152
|
- !ruby/object:Gem::Version
|
135
153
|
version: '0'
|
136
154
|
requirements: []
|
137
|
-
|
138
|
-
rubygems_version: 2.7.6.2
|
155
|
+
rubygems_version: 3.0.3
|
139
156
|
signing_key:
|
140
157
|
specification_version: 4
|
141
158
|
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,169 +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
|
-
].freeze
|
16
|
-
|
17
|
-
@document_types = [
|
18
|
-
Jekyll::Document,
|
19
|
-
Jekyll::Page,
|
20
|
-
Jekyll::VERSION.start_with?("2.") ? Jekyll::Post : nil,
|
21
|
-
].compact.freeze
|
22
|
-
|
23
|
-
def self.document_type?(input)
|
24
|
-
@document_types.include?(input.class)
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.simple_type?(input)
|
28
|
-
@simple_types.include?(input.class) || [true, false].include?(input)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.static_file_to_json(input, depth)
|
32
|
-
out = [
|
33
|
-
"\"extname\": #{SafeJsonifyFilter.to_json(input.extname, depth + 1)}",
|
34
|
-
"\"path\": #{SafeJsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
35
|
-
]
|
36
|
-
|
37
|
-
# modified_time isn't defined in Jekyll 2.4.0
|
38
|
-
if input.respond_to? :modified_time
|
39
|
-
out.push("\"modified_time\": #{SafeJsonifyFilter.to_json(input.modified_time, depth + 1)}")
|
40
|
-
end
|
41
|
-
|
42
|
-
"{#{out.join(",")}}"
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.document_data_to_json(data, out, prevent, depth)
|
46
|
-
prevent += %w(content output next previous excerpt)
|
47
|
-
|
48
|
-
data.map do |key, value|
|
49
|
-
unless prevent.include? key
|
50
|
-
out.push("\"#{key}\": #{SafeJsonifyFilter.to_json(value, depth + 1)}")
|
51
|
-
prevent.push(key)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
"{#{out.join(",")}}"
|
56
|
-
end
|
57
|
-
|
58
|
-
def self.legacy_post_to_json(input, depth)
|
59
|
-
prevent = %w(dir name path url date id categories tags)
|
60
|
-
|
61
|
-
out = [
|
62
|
-
"\"dir\": #{SafeJsonifyFilter.to_json(input.dir, depth + 1)}",
|
63
|
-
"\"name\": #{SafeJsonifyFilter.to_json(input.name, depth + 1)}",
|
64
|
-
"\"path\": #{SafeJsonifyFilter.to_json(input.path, depth + 1)}",
|
65
|
-
"\"url\": #{SafeJsonifyFilter.to_json(input.url, depth + 1)}",
|
66
|
-
"\"date\": #{SafeJsonifyFilter.to_json(input.date, depth + 1)}",
|
67
|
-
"\"id\": #{SafeJsonifyFilter.to_json(input.id, depth + 1)}",
|
68
|
-
"\"categories\": #{SafeJsonifyFilter.to_json(input.categories, depth + 1)}",
|
69
|
-
"\"tags\": #{SafeJsonifyFilter.to_json(input.tags, depth + 1)}",
|
70
|
-
]
|
71
|
-
|
72
|
-
SafeJsonifyFilter.document_data_to_json(input.data, out, prevent, depth)
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.page_to_json(input, depth)
|
76
|
-
prevent = %w(dir name path url)
|
77
|
-
|
78
|
-
out = [
|
79
|
-
"\"dir\": #{SafeJsonifyFilter.to_json(input.dir, depth + 1)}",
|
80
|
-
"\"name\": #{SafeJsonifyFilter.to_json(input.name, depth + 1)}",
|
81
|
-
"\"path\": #{SafeJsonifyFilter.to_json(input.path, depth + 1)}",
|
82
|
-
"\"url\": #{SafeJsonifyFilter.to_json(input.url, depth + 1)}",
|
83
|
-
]
|
84
|
-
|
85
|
-
# Merge Jekyll Defaults into data for pages (missing at v3.8.5)
|
86
|
-
defaults = input.site.frontmatter_defaults.all(input.relative_path, :pages).tap do |h|
|
87
|
-
h.delete("date")
|
88
|
-
end
|
89
|
-
|
90
|
-
data = Jekyll::Utils.deep_merge_hashes(defaults, input.data)
|
91
|
-
SafeJsonifyFilter.document_data_to_json(data, out, prevent, depth)
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.document_to_json(input, depth)
|
95
|
-
prevent = %w(dir id relative_path url collection)
|
96
|
-
|
97
|
-
out = [
|
98
|
-
"\"path\": #{SafeJsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
99
|
-
"\"relative_path\": #{SafeJsonifyFilter.to_json(input.relative_path, depth + 1)}",
|
100
|
-
"\"url\": #{SafeJsonifyFilter.to_json(input.url, depth + 1)}",
|
101
|
-
]
|
102
|
-
|
103
|
-
unless input.collection.nil?
|
104
|
-
out.push("\"collection\": #{SafeJsonifyFilter.to_json(input.collection.label, depth + 1)}")
|
105
|
-
end
|
106
|
-
|
107
|
-
# id isn't defined in Jekyll 2.4.0
|
108
|
-
out.push("\"id\": #{SafeJsonifyFilter.to_json(input.id, depth + 1)}") if input.respond_to? :id
|
109
|
-
|
110
|
-
SafeJsonifyFilter.document_data_to_json(input.data, out, prevent, depth)
|
111
|
-
end
|
112
|
-
|
113
|
-
def self.array_to_json(input, depth)
|
114
|
-
array = input.map do |value|
|
115
|
-
SafeJsonifyFilter.to_json(value, depth + 1)
|
116
|
-
end
|
117
|
-
|
118
|
-
"[#{array.join(",")}]"
|
119
|
-
end
|
120
|
-
|
121
|
-
def self.hash_to_json(input, depth)
|
122
|
-
hash = input.map do |key, value|
|
123
|
-
"\"#{key}\": #{SafeJsonifyFilter.to_json(value, depth + 1)}"
|
124
|
-
end
|
125
|
-
|
126
|
-
"{#{hash.join(",")}}"
|
127
|
-
end
|
128
|
-
|
129
|
-
def self.to_json(input, depth)
|
130
|
-
if depth > 8 || (depth > 2 && SafeJsonifyFilter.document_type?(input))
|
131
|
-
'"MAXIMUM_DEPTH"'
|
132
|
-
elsif SafeJsonifyFilter.simple_type?(input)
|
133
|
-
input.to_json
|
134
|
-
elsif input.is_a?(Jekyll::StaticFile)
|
135
|
-
SafeJsonifyFilter.static_file_to_json(input, depth)
|
136
|
-
elsif input.is_a?(Jekyll::Page)
|
137
|
-
SafeJsonifyFilter.page_to_json(input, depth)
|
138
|
-
elsif Jekyll::VERSION.start_with?("2.") && input.is_a?(Jekyll::Post)
|
139
|
-
SafeJsonifyFilter.legacy_post_to_json(input, depth)
|
140
|
-
elsif input.is_a?(Jekyll::Document)
|
141
|
-
SafeJsonifyFilter.document_to_json(input, depth)
|
142
|
-
elsif input.is_a?(Array)
|
143
|
-
SafeJsonifyFilter.array_to_json(input, depth)
|
144
|
-
elsif input.is_a?(Hash)
|
145
|
-
SafeJsonifyFilter.hash_to_json(input, depth)
|
146
|
-
else
|
147
|
-
"\"UNSUPPORTED:#{input.class}\""
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
def cc_static_files_jsonify(input)
|
152
|
-
out = []
|
153
|
-
input.each do |page|
|
154
|
-
next if page.extname != ".html" &&
|
155
|
-
page.extname != ".htm" &&
|
156
|
-
page.path != "/robots.txt" &&
|
157
|
-
page.path != "/sitemap.xml"
|
158
|
-
|
159
|
-
out.push(SafeJsonifyFilter.to_json(page, 1))
|
160
|
-
end
|
161
|
-
|
162
|
-
"[#{out.join(",")}]"
|
163
|
-
end
|
164
|
-
|
165
|
-
def cc_safe_jsonify(input)
|
166
|
-
SafeJsonifyFilter.to_json(input, 0)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|