jekyll-open-sdg-plugins 1.0.0.rc21 → 1.2.0.pre.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +16 -16
- data/.github/workflows/test-pull-requests.yml +17 -0
- data/.gitignore +6 -4
- data/Makefile +33 -0
- data/README.md +7 -7
- data/jekyll-open-sdg-plugins.gemspec +18 -17
- data/lib/jekyll-open-sdg-plugins.rb +16 -13
- data/lib/jekyll-open-sdg-plugins/create_goals.rb +75 -75
- data/lib/jekyll-open-sdg-plugins/create_indicators.rb +118 -67
- data/lib/jekyll-open-sdg-plugins/create_pages.rb +127 -99
- data/lib/jekyll-open-sdg-plugins/fetch_remote_data.rb +187 -167
- data/lib/jekyll-open-sdg-plugins/helpers.rb +132 -66
- data/lib/jekyll-open-sdg-plugins/schema-indicator-config.json +516 -0
- data/lib/jekyll-open-sdg-plugins/schema-site-config.json +1153 -0
- data/lib/jekyll-open-sdg-plugins/sdg_variables.rb +439 -410
- data/lib/jekyll-open-sdg-plugins/search_index.rb +102 -92
- data/lib/jekyll-open-sdg-plugins/site_configuration.rb +43 -0
- data/lib/jekyll-open-sdg-plugins/translate_date.rb +98 -67
- data/lib/jekyll-open-sdg-plugins/translate_key.rb +20 -20
- data/lib/jekyll-open-sdg-plugins/translate_metadata_field.rb +111 -111
- data/lib/jekyll-open-sdg-plugins/validate_indicator_config.rb +52 -0
- data/lib/jekyll-open-sdg-plugins/validate_site_config.rb +34 -0
- data/lib/jekyll-open-sdg-plugins/version.rb +3 -3
- data/tests/Gemfile +7 -0
- data/tests/_config.yml +147 -0
- metadata +26 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 714570ee0a7ab38905c524b6fad9c1590340e09052778c82adc543574d11e7ac
|
4
|
+
data.tar.gz: ed6ee32ba2cb547dd8f46159fb133197b044fc101c0d00af12662cf78a245872
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c5862fc0ffd6241ef72f92d15e72f5a0dc4fe682a8b0a9cfe80e418968b1eadfa0aa5fa7c5ea83e82b2ebe441535d3c8e77283b7925d9ce83f491b7bcf7f99d
|
7
|
+
data.tar.gz: 789bb89817ceb676ab5eaac06411435030a6fcdf24dd4ad5c0529fa7cfadac27d5dcd91670f5894fdc983220e9cd6a04324309fee46bb747c93996e561a79821
|
data/.editorconfig
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
root = true
|
2
|
-
|
3
|
-
[*]
|
4
|
-
indent_style = space
|
5
|
-
indent_size = 2
|
6
|
-
trim_trailing_whitespace = true
|
7
|
-
insert_final_newline = true
|
8
|
-
|
9
|
-
[*.{md,rb,gemspec},Makefile]
|
10
|
-
charset = utf-8
|
11
|
-
|
12
|
-
[Makefile]
|
13
|
-
indent_style = tab
|
14
|
-
|
15
|
-
[*.md]
|
16
|
-
trim_trailing_whitespace = false
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
indent_style = space
|
5
|
+
indent_size = 2
|
6
|
+
trim_trailing_whitespace = true
|
7
|
+
insert_final_newline = true
|
8
|
+
|
9
|
+
[*.{md,rb,gemspec},Makefile]
|
10
|
+
charset = utf-8
|
11
|
+
|
12
|
+
[Makefile]
|
13
|
+
indent_style = tab
|
14
|
+
|
15
|
+
[*.md]
|
16
|
+
trim_trailing_whitespace = false
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: Test PRs
|
2
|
+
|
3
|
+
on: [pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v1
|
12
|
+
- name: Set up Ruby 2.6
|
13
|
+
uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.6.x
|
16
|
+
- name: Run all tests
|
17
|
+
run: make test
|
data/.gitignore
CHANGED
data/Makefile
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
.PHONY: clean build serve serve.detached
|
2
|
+
all: test
|
3
|
+
|
4
|
+
clean:
|
5
|
+
# Stop the detached Jekyll web server.
|
6
|
+
-pkill -f -9 jekyll
|
7
|
+
# Delete the builds.
|
8
|
+
rm -fr open-sdg-site-starter
|
9
|
+
rm -fr open-sdg
|
10
|
+
|
11
|
+
install: clean
|
12
|
+
git clone https://github.com/open-sdg/open-sdg-site-starter.git
|
13
|
+
git clone https://github.com/open-sdg/open-sdg.git
|
14
|
+
# Copy all the theme files into the site starter.
|
15
|
+
cp -r open-sdg/_includes/* open-sdg-site-starter/_includes/
|
16
|
+
cp -r open-sdg/_layouts/* open-sdg-site-starter/_layouts/
|
17
|
+
cp -r open-sdg/_sass/* open-sdg-site-starter/_sass/
|
18
|
+
cp -r open-sdg/assets/* open-sdg-site-starter/assets/
|
19
|
+
# Copy the required files into the site starter.
|
20
|
+
cp tests/_config.yml open-sdg-site-starter/
|
21
|
+
cp tests/Gemfile open-sdg-site-starter/
|
22
|
+
# Create a symlink to our plugin files.
|
23
|
+
ln -s ../lib/jekyll-open-sdg-plugins open-sdg-site-starter/_plugins
|
24
|
+
# Install Ruby dependencies.
|
25
|
+
cd open-sdg-site-starter && bundle install
|
26
|
+
|
27
|
+
build:
|
28
|
+
cd open-sdg-site-starter && bundle exec jekyll build
|
29
|
+
|
30
|
+
serve:
|
31
|
+
cd open-sdg-site-starter && bundle exec jekyll serve
|
32
|
+
|
33
|
+
test: install build
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# jekyll-open-sdg-plugins
|
2
|
-
|
3
|
-
> 💎 Jekyll plugins for use with the Open SDG platform
|
4
|
-
|
5
|
-
This plugin provides required Jekyll functionality for the [Open SDG](https://github.com/open-sdg/open-sdg) platform.
|
6
|
-
|
7
|
-
The details on this functionality can be found throughout the [Open SDG documentation](https://open-sdg.readthedocs.io/en/latest/).
|
1
|
+
# jekyll-open-sdg-plugins
|
2
|
+
|
3
|
+
> 💎 Jekyll plugins for use with the Open SDG platform
|
4
|
+
|
5
|
+
This plugin provides required Jekyll functionality for the [Open SDG](https://github.com/open-sdg/open-sdg) platform.
|
6
|
+
|
7
|
+
The details on this functionality can be found throughout the [Open SDG documentation](https://open-sdg.readthedocs.io/en/latest/).
|
@@ -1,17 +1,18 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "jekyll-open-sdg-plugins/version"
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "jekyll-open-sdg-plugins"
|
6
|
-
spec.summary = "Jekyll plugins for use with the Open SDG platform"
|
7
|
-
spec.description = "Jekyll plugins for use with the Open SDG platform"
|
8
|
-
spec.version = JekyllOpenSdgPlugins::VERSION
|
9
|
-
spec.authors = ["Brock Fanning"]
|
10
|
-
spec.email = ["brockfanning@gmail.com"]
|
11
|
-
spec.homepage = "https://github.com/open-sdg/jekyll-open-sdg-plugins"
|
12
|
-
spec.licenses = ["MIT"]
|
13
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
14
|
-
spec.require_paths = ["lib"]
|
15
|
-
spec.add_dependency "jekyll", "~> 3.0"
|
16
|
-
spec.add_dependency "deep_merge", "~> 1.2"
|
17
|
-
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "jekyll-open-sdg-plugins/version"
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "jekyll-open-sdg-plugins"
|
6
|
+
spec.summary = "Jekyll plugins for use with the Open SDG platform"
|
7
|
+
spec.description = "Jekyll plugins for use with the Open SDG platform"
|
8
|
+
spec.version = JekyllOpenSdgPlugins::VERSION
|
9
|
+
spec.authors = ["Brock Fanning"]
|
10
|
+
spec.email = ["brockfanning@gmail.com"]
|
11
|
+
spec.homepage = "https://github.com/open-sdg/jekyll-open-sdg-plugins"
|
12
|
+
spec.licenses = ["MIT"]
|
13
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|spec|features)/!) }
|
14
|
+
spec.require_paths = ["lib"]
|
15
|
+
spec.add_dependency "jekyll", "~> 3.0"
|
16
|
+
spec.add_dependency "deep_merge", "~> 1.2"
|
17
|
+
spec.add_dependency "json_schemer", "~> 0.2"
|
18
|
+
end
|
@@ -1,13 +1,16 @@
|
|
1
|
-
require_relative "jekyll-open-sdg-plugins/version"
|
2
|
-
require_relative "jekyll-open-sdg-plugins/
|
3
|
-
require_relative "jekyll-open-sdg-plugins/
|
4
|
-
require_relative "jekyll-open-sdg-plugins/
|
5
|
-
require_relative "jekyll-open-sdg-plugins/
|
6
|
-
require_relative "jekyll-open-sdg-plugins/
|
7
|
-
require_relative "jekyll-open-sdg-plugins/
|
8
|
-
require_relative "jekyll-open-sdg-plugins/
|
9
|
-
require_relative "jekyll-open-sdg-plugins/
|
10
|
-
require_relative "jekyll-open-sdg-plugins/
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
require_relative "jekyll-open-sdg-plugins/version"
|
2
|
+
require_relative "jekyll-open-sdg-plugins/site_configuration"
|
3
|
+
require_relative "jekyll-open-sdg-plugins/validate_site_config"
|
4
|
+
require_relative "jekyll-open-sdg-plugins/fetch_remote_data"
|
5
|
+
require_relative "jekyll-open-sdg-plugins/translate_key"
|
6
|
+
require_relative "jekyll-open-sdg-plugins/translate_date"
|
7
|
+
require_relative "jekyll-open-sdg-plugins/translate_metadata_field"
|
8
|
+
require_relative "jekyll-open-sdg-plugins/create_indicators"
|
9
|
+
require_relative "jekyll-open-sdg-plugins/create_goals"
|
10
|
+
require_relative "jekyll-open-sdg-plugins/create_pages"
|
11
|
+
require_relative "jekyll-open-sdg-plugins/sdg_variables"
|
12
|
+
require_relative "jekyll-open-sdg-plugins/search_index"
|
13
|
+
require_relative "jekyll-open-sdg-plugins/validate_indicator_config"
|
14
|
+
|
15
|
+
module JekyllOpenSdgPlugins
|
16
|
+
end
|
@@ -1,75 +1,75 @@
|
|
1
|
-
require "jekyll"
|
2
|
-
require_relative "helpers"
|
3
|
-
|
4
|
-
module JekyllOpenSdgPlugins
|
5
|
-
class CreateGoals < Jekyll::Generator
|
6
|
-
safe true
|
7
|
-
priority :normal
|
8
|
-
|
9
|
-
def generate(site)
|
10
|
-
# If site.create_goals is set, create goals per the metadata.
|
11
|
-
if site.config['languages'] and site.config['create_goals']
|
12
|
-
# Compile the list of goals.
|
13
|
-
goals = {}
|
14
|
-
# Are we using translated builds?
|
15
|
-
metadata = {}
|
16
|
-
if opensdg_translated_builds(site)
|
17
|
-
# If we are using translated builds, the 'meta' data is underneath
|
18
|
-
# language codes. We just use the first language.
|
19
|
-
default_language = site.config['languages'][0]
|
20
|
-
metadata = site.data[default_language]['meta']
|
21
|
-
else
|
22
|
-
# Otherwise the 'meta' data is not underneath any language code.
|
23
|
-
metadata = site.data['meta']
|
24
|
-
end
|
25
|
-
metadata.each do |inid, indicator|
|
26
|
-
goal = inid.split('-')[0].to_i
|
27
|
-
goals[goal] = true
|
28
|
-
end
|
29
|
-
# Decide what layout to use for the goal pages.
|
30
|
-
layout = 'goal'
|
31
|
-
if site.config['create_goals'].key?('layout')
|
32
|
-
layout = site.config['create_goals']['layout']
|
33
|
-
end
|
34
|
-
# See if we need to "map" any language codes.
|
35
|
-
languages_public = Hash.new
|
36
|
-
if site.config['languages_public']
|
37
|
-
languages_public = site
|
38
|
-
end
|
39
|
-
# Loop through the languages.
|
40
|
-
site.config['languages'].each_with_index do |language, index|
|
41
|
-
# Get the "public language" (for URLs) which may be different.
|
42
|
-
language_public = language
|
43
|
-
if languages_public[language]
|
44
|
-
language_public = languages_public[language]
|
45
|
-
end
|
46
|
-
# Loop through the goals.
|
47
|
-
goals.sort.each do |goal, value|
|
48
|
-
# Add the language subfolder for all except the default (first) language.
|
49
|
-
dir = index == 0 ? goal.to_s : File.join(language_public, goal.to_s)
|
50
|
-
# Create the goal page.
|
51
|
-
site.collections['goals'].docs << GoalPage.new(site, site.source, dir, goal, language, layout)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# A Page subclass used in the `CreateGoals` class.
|
59
|
-
class GoalPage < Jekyll::Page
|
60
|
-
def initialize(site, base, dir, goal, language, layout)
|
61
|
-
@site = site
|
62
|
-
@base = base
|
63
|
-
@dir = dir
|
64
|
-
@name = 'index.html'
|
65
|
-
|
66
|
-
self.process(@name)
|
67
|
-
self.data = {}
|
68
|
-
self.data['goal_number'] = goal.to_s
|
69
|
-
self.data['language'] = language
|
70
|
-
self.data['layout'] = layout
|
71
|
-
# Backwards compatibility:
|
72
|
-
self.data['sdg_goal'] = self.data['goal_number']
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
1
|
+
require "jekyll"
|
2
|
+
require_relative "helpers"
|
3
|
+
|
4
|
+
module JekyllOpenSdgPlugins
|
5
|
+
class CreateGoals < Jekyll::Generator
|
6
|
+
safe true
|
7
|
+
priority :normal
|
8
|
+
|
9
|
+
def generate(site)
|
10
|
+
# If site.create_goals is set, create goals per the metadata.
|
11
|
+
if site.config['languages'] and site.config['create_goals']
|
12
|
+
# Compile the list of goals.
|
13
|
+
goals = {}
|
14
|
+
# Are we using translated builds?
|
15
|
+
metadata = {}
|
16
|
+
if opensdg_translated_builds(site)
|
17
|
+
# If we are using translated builds, the 'meta' data is underneath
|
18
|
+
# language codes. We just use the first language.
|
19
|
+
default_language = site.config['languages'][0]
|
20
|
+
metadata = site.data[default_language]['meta']
|
21
|
+
else
|
22
|
+
# Otherwise the 'meta' data is not underneath any language code.
|
23
|
+
metadata = site.data['meta']
|
24
|
+
end
|
25
|
+
metadata.each do |inid, indicator|
|
26
|
+
goal = inid.split('-')[0].to_i
|
27
|
+
goals[goal] = true
|
28
|
+
end
|
29
|
+
# Decide what layout to use for the goal pages.
|
30
|
+
layout = 'goal'
|
31
|
+
if site.config['create_goals'].key?('layout')
|
32
|
+
layout = site.config['create_goals']['layout']
|
33
|
+
end
|
34
|
+
# See if we need to "map" any language codes.
|
35
|
+
languages_public = Hash.new
|
36
|
+
if site.config['languages_public']
|
37
|
+
languages_public = opensdg_languages_public(site)
|
38
|
+
end
|
39
|
+
# Loop through the languages.
|
40
|
+
site.config['languages'].each_with_index do |language, index|
|
41
|
+
# Get the "public language" (for URLs) which may be different.
|
42
|
+
language_public = language
|
43
|
+
if languages_public[language]
|
44
|
+
language_public = languages_public[language]
|
45
|
+
end
|
46
|
+
# Loop through the goals.
|
47
|
+
goals.sort.each do |goal, value|
|
48
|
+
# Add the language subfolder for all except the default (first) language.
|
49
|
+
dir = index == 0 ? goal.to_s : File.join(language_public, goal.to_s)
|
50
|
+
# Create the goal page.
|
51
|
+
site.collections['goals'].docs << GoalPage.new(site, site.source, dir, goal, language, layout)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# A Page subclass used in the `CreateGoals` class.
|
59
|
+
class GoalPage < Jekyll::Page
|
60
|
+
def initialize(site, base, dir, goal, language, layout)
|
61
|
+
@site = site
|
62
|
+
@base = base
|
63
|
+
@dir = dir
|
64
|
+
@name = 'index.html'
|
65
|
+
|
66
|
+
self.process(@name)
|
67
|
+
self.data = {}
|
68
|
+
self.data['goal_number'] = goal.to_s
|
69
|
+
self.data['language'] = language
|
70
|
+
self.data['layout'] = layout
|
71
|
+
# Backwards compatibility:
|
72
|
+
self.data['sdg_goal'] = self.data['goal_number']
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -1,67 +1,118 @@
|
|
1
|
-
require "jekyll"
|
2
|
-
require_relative "helpers"
|
3
|
-
|
4
|
-
module JekyllOpenSdgPlugins
|
5
|
-
class CreateIndicators < Jekyll::Generator
|
6
|
-
safe true
|
7
|
-
priority :normal
|
8
|
-
|
9
|
-
def generate(site)
|
10
|
-
# If site.create_indicators is set, create indicators per the metadata.
|
11
|
-
if site.config['languages'] and site.config['create_indicators']
|
12
|
-
# Decide what layout to use for the indicator pages.
|
13
|
-
layout = 'indicator'
|
14
|
-
if site.config['create_indicators'].key?('layout')
|
15
|
-
layout = site.config['create_indicators']['layout']
|
16
|
-
end
|
17
|
-
# See if we need to "map" any language codes.
|
18
|
-
languages_public = Hash.new
|
19
|
-
if site.config['languages_public']
|
20
|
-
languages_public = site
|
21
|
-
end
|
22
|
-
# Loop through the languages.
|
23
|
-
site.config['languages'].each_with_index do |language, index|
|
24
|
-
# Get the "public language" (for URLs) which may be different.
|
25
|
-
language_public = language
|
26
|
-
if languages_public[language]
|
27
|
-
language_public = languages_public[language]
|
28
|
-
end
|
29
|
-
metadata = {}
|
30
|
-
if opensdg_translated_builds(site)
|
31
|
-
# If we are using translated builds, the metadata is underneath a
|
32
|
-
# language code.
|
33
|
-
metadata = site.data[language]['meta']
|
34
|
-
else
|
35
|
-
# Otherwise the 'meta' data is not underneath any language code.
|
36
|
-
metadata = site.data['meta']
|
37
|
-
end
|
38
|
-
# Loop through the indicators (using metadata as a list).
|
39
|
-
metadata.each do |inid, meta|
|
40
|
-
# Add the language subfolder for all except the default (first) language.
|
41
|
-
dir = index == 0 ? inid : File.join(language_public, inid)
|
42
|
-
# Create the indicator page.
|
43
|
-
site.collections['indicators'].docs << IndicatorPage.new(site, site.source, dir, inid, language, layout)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
1
|
+
require "jekyll"
|
2
|
+
require_relative "helpers"
|
3
|
+
|
4
|
+
module JekyllOpenSdgPlugins
|
5
|
+
class CreateIndicators < Jekyll::Generator
|
6
|
+
safe true
|
7
|
+
priority :normal
|
8
|
+
|
9
|
+
def generate(site)
|
10
|
+
# If site.create_indicators is set, create indicators per the metadata.
|
11
|
+
if site.config['languages'] and site.config['create_indicators']
|
12
|
+
# Decide what layout to use for the indicator pages.
|
13
|
+
layout = 'indicator'
|
14
|
+
if site.config['create_indicators'].key?('layout')
|
15
|
+
layout = site.config['create_indicators']['layout']
|
16
|
+
end
|
17
|
+
# See if we need to "map" any language codes.
|
18
|
+
languages_public = Hash.new
|
19
|
+
if site.config['languages_public']
|
20
|
+
languages_public = opensdg_languages_public(site)
|
21
|
+
end
|
22
|
+
# Loop through the languages.
|
23
|
+
site.config['languages'].each_with_index do |language, index|
|
24
|
+
# Get the "public language" (for URLs) which may be different.
|
25
|
+
language_public = language
|
26
|
+
if languages_public[language]
|
27
|
+
language_public = languages_public[language]
|
28
|
+
end
|
29
|
+
metadata = {}
|
30
|
+
if opensdg_translated_builds(site)
|
31
|
+
# If we are using translated builds, the metadata is underneath a
|
32
|
+
# language code.
|
33
|
+
metadata = site.data[language]['meta']
|
34
|
+
else
|
35
|
+
# Otherwise the 'meta' data is not underneath any language code.
|
36
|
+
metadata = site.data['meta']
|
37
|
+
end
|
38
|
+
# Loop through the indicators (using metadata as a list).
|
39
|
+
metadata.each do |inid, meta|
|
40
|
+
# Add the language subfolder for all except the default (first) language.
|
41
|
+
dir = index == 0 ? inid : File.join(language_public, inid)
|
42
|
+
# Create the indicator page.
|
43
|
+
site.collections['indicators'].docs << IndicatorPage.new(site, site.source, dir, inid, language, layout)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
# Create the indicator configuration pages.
|
47
|
+
metadata = {}
|
48
|
+
if opensdg_translated_builds(site)
|
49
|
+
if site.data.has_key?('untranslated')
|
50
|
+
metadata = site.data['untranslated']['meta']
|
51
|
+
else
|
52
|
+
default_language = site.config['languages'][0]
|
53
|
+
metadata = site.data[default_language]['meta']
|
54
|
+
end
|
55
|
+
else
|
56
|
+
metadata = site.data['meta']
|
57
|
+
end
|
58
|
+
# Loop through the indicators (using metadata as a list).
|
59
|
+
if !metadata.empty?
|
60
|
+
site.config['show_indicator_config_forms'] = true
|
61
|
+
# Loop through the languages.
|
62
|
+
site.config['languages'].each_with_index do |language, index|
|
63
|
+
# Get the "public language" (for URLs) which may be different.
|
64
|
+
language_public = language
|
65
|
+
if languages_public[language]
|
66
|
+
language_public = languages_public[language]
|
67
|
+
end
|
68
|
+
metadata.each do |inid, meta|
|
69
|
+
dir = File.join('config', inid)
|
70
|
+
if index != 0
|
71
|
+
dir = File.join(language_public, 'config', inid)
|
72
|
+
end
|
73
|
+
site.collections['pages'].docs << IndicatorConfigPage.new(site, site.source, dir, inid, language, meta)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
# A Page subclass used in the `CreateIndicators` class.
|
82
|
+
class IndicatorPage < Jekyll::Page
|
83
|
+
def initialize(site, base, dir, inid, language, layout)
|
84
|
+
@site = site
|
85
|
+
@base = base
|
86
|
+
@dir = dir
|
87
|
+
@name = 'index.html'
|
88
|
+
|
89
|
+
self.process(@name)
|
90
|
+
self.data = {}
|
91
|
+
self.data['indicator_number'] = inid.gsub('-', '.')
|
92
|
+
self.data['layout'] = layout
|
93
|
+
self.data['language'] = language
|
94
|
+
# Backwards compatibility:
|
95
|
+
self.data['indicator'] = self.data['indicator_number']
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# A Page subclass used in the `CreateIndicators` class.
|
100
|
+
class IndicatorConfigPage < Jekyll::Page
|
101
|
+
def initialize(site, base, dir, inid, language, meta)
|
102
|
+
@site = site
|
103
|
+
@base = base
|
104
|
+
@dir = dir
|
105
|
+
@name = 'index.html'
|
106
|
+
|
107
|
+
self.process(@name)
|
108
|
+
self.data = {}
|
109
|
+
self.data['language'] = language
|
110
|
+
self.data['indicator_number'] = inid.gsub('-', '.')
|
111
|
+
self.data['config_type'] = 'indicator'
|
112
|
+
self.data['layout'] = 'config-builder'
|
113
|
+
self.data['meta'] = meta
|
114
|
+
self.data['title'] = 'Open SDG indicator configuration: ' + self.data['indicator_number']
|
115
|
+
self.data['config_filename'] = inid + '.yml'
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|