jekyll-open-sdg-plugins 2.3.0 → 2.4.0.pre.beta1
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/jekyll-open-sdg-plugins.gemspec +0 -1
- data/lib/jekyll-open-sdg-plugins/create_indicators.rb +0 -3
- data/lib/jekyll-open-sdg-plugins/create_pages.rb +0 -3
- data/lib/jekyll-open-sdg-plugins/metadata_schema_to_config.rb +0 -2
- data/lib/jekyll-open-sdg-plugins/routes.rb +2 -2
- data/lib/jekyll-open-sdg-plugins/search_index.rb +1 -1
- data/lib/jekyll-open-sdg-plugins/version.rb +1 -1
- data/lib/jekyll-open-sdg-plugins.rb +0 -2
- data/tests/Gemfile +0 -1
- data/tests/_config.yml +0 -3
- metadata +4 -22
- data/lib/jekyll-open-sdg-plugins/schema-indicator-config.json +0 -956
- data/lib/jekyll-open-sdg-plugins/schema-site-config.json +0 -1723
- data/lib/jekyll-open-sdg-plugins/validate_indicator_config.rb +0 -48
- data/lib/jekyll-open-sdg-plugins/validate_site_config.rb +0 -34
@@ -1,48 +0,0 @@
|
|
1
|
-
require "jekyll"
|
2
|
-
require_relative "helpers"
|
3
|
-
require "json"
|
4
|
-
require "json_schemer"
|
5
|
-
|
6
|
-
module JekyllOpenSdgPlugins
|
7
|
-
class ValidateIndicatorConfig < Jekyll::Generator
|
8
|
-
safe true
|
9
|
-
priority :lowest
|
10
|
-
|
11
|
-
def generate(site)
|
12
|
-
|
13
|
-
schema_path = File.join(File.dirname(__FILE__), 'schema-indicator-config.json')
|
14
|
-
json_from_file = File.read(schema_path)
|
15
|
-
schema = JSON.parse(json_from_file)
|
16
|
-
schemer = JSONSchemer.schema(schema)
|
17
|
-
|
18
|
-
# Perform validation if the "validate_indicator_config" flag is true.
|
19
|
-
if site.config.has_key?('validate_indicator_config') && site.config['validate_indicator_config']
|
20
|
-
# We don't care too much what language we use, just get the first one.
|
21
|
-
language = 'en'
|
22
|
-
if site.config.has_key?('languages')
|
23
|
-
language = site.config['languages'][0]
|
24
|
-
end
|
25
|
-
metadata = {}
|
26
|
-
metadata = site.data[language]['meta']
|
27
|
-
# Loop through the indicators (using metadata as a list).
|
28
|
-
validation_failed = false
|
29
|
-
metadata.each do |inid, meta|
|
30
|
-
unless schemer.valid?(meta)
|
31
|
-
validation_failed = true
|
32
|
-
opensdg_notice('Indicator ' + inid + ' configuration invalid:')
|
33
|
-
errors = schemer.validate(meta).to_a
|
34
|
-
errors.each { |error| opensdg_validation_error(error) }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
if validation_failed
|
38
|
-
opensdg_notice "Some indicator configuration was not valid. See feedback above."
|
39
|
-
raise "Invalid indicator configuration"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Regardless place the schema in site data so it can be used in Jekyll templates.
|
44
|
-
site.data['schema-indicator-config'] = schema
|
45
|
-
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require "jekyll"
|
2
|
-
require_relative "helpers"
|
3
|
-
require "json"
|
4
|
-
require "json_schemer"
|
5
|
-
|
6
|
-
module JekyllOpenSdgPlugins
|
7
|
-
class ValidateSiteConfig < Jekyll::Generator
|
8
|
-
safe true
|
9
|
-
priority :highest
|
10
|
-
|
11
|
-
def generate(site)
|
12
|
-
|
13
|
-
schema_path = File.join(File.dirname(__FILE__), 'schema-site-config.json')
|
14
|
-
json_from_file = File.read(schema_path)
|
15
|
-
schema = JSON.parse(json_from_file)
|
16
|
-
schemer = JSONSchemer.schema(schema)
|
17
|
-
|
18
|
-
# Perform validation if the "validate_site_config" flag is true.
|
19
|
-
if site.config.has_key?('validate_site_config') && site.config['validate_site_config']
|
20
|
-
unless schemer.valid?(site.config)
|
21
|
-
opensdg_notice('Site configuration invalid:')
|
22
|
-
errors = schemer.validate(site.config).to_a
|
23
|
-
errors.each { |error| opensdg_validation_error(error) }
|
24
|
-
opensdg_notice "The site configuration is not valid. See feedback above."
|
25
|
-
raise "Invalid site configuration"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Regardless place the schema in site data so it can be used in Jekyll templates.
|
30
|
-
site.data['schema-site-config'] = schema
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|