jekyll-open-sdg-plugins 1.3.0 → 1.5.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/lib/jekyll-open-sdg-plugins/create_goals.rb +8 -6
- data/lib/jekyll-open-sdg-plugins/create_indicators.rb +127 -20
- data/lib/jekyll-open-sdg-plugins/create_pages.rb +20 -5
- data/lib/jekyll-open-sdg-plugins/fetch_remote_data.rb +3 -2
- data/lib/jekyll-open-sdg-plugins/metadata_schema_to_config.rb +72 -0
- data/lib/jekyll-open-sdg-plugins/schema-indicator-config.json +114 -5
- data/lib/jekyll-open-sdg-plugins/schema-site-config.json +240 -35
- data/lib/jekyll-open-sdg-plugins/sdg_variables.rb +78 -5
- data/lib/jekyll-open-sdg-plugins/site_configuration.rb +9 -0
- data/lib/jekyll-open-sdg-plugins/translate_date.rb +25 -1
- data/lib/jekyll-open-sdg-plugins/version.rb +1 -1
- data/lib/jekyll-open-sdg-plugins.rb +1 -0
- data/tests/_config.yml +10 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06e9d51fe6fddfeab87a899fb547b6b1762d0832d59de269f12d5bddd6aeedc4
|
4
|
+
data.tar.gz: 8f1728d821fffbb4cc51382cbc705e1e1e565c8b34cba3fbfdbe7bedd0ae4c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68c29fd1482b09b1b22875375277ea93e748d6f8bfa9a89e986cea37790782761ad5f790d1e49d12335578a048140e76e9979b6cd16c1a1cd7fcbca0356670a7
|
7
|
+
data.tar.gz: 8af06e8364fd7ce44039fab11617ba98ff6e8f6eb63ea5e9b4839fcb1bd36e81746d2ec333422159f10931737bda790719895e1f6e66a28fec5212b6116622fc
|
@@ -26,7 +26,7 @@ module JekyllOpenSdgPlugins
|
|
26
26
|
if indicator.has_key?('standalone') and indicator['standalone']
|
27
27
|
next
|
28
28
|
end
|
29
|
-
goal = inid.split('-')[0]
|
29
|
+
goal = inid.split('-')[0]
|
30
30
|
goals[goal] = true
|
31
31
|
end
|
32
32
|
# Decide what layout to use for the goal pages.
|
@@ -44,11 +44,13 @@ module JekyllOpenSdgPlugins
|
|
44
44
|
language_public = languages_public[language]
|
45
45
|
end
|
46
46
|
# Loop through the goals.
|
47
|
-
|
47
|
+
goal_index = 0
|
48
|
+
goals.keys.sort.each do |goal|
|
48
49
|
# Add the language subfolder for all except the default (first) language.
|
49
50
|
dir = index == 0 ? goal.to_s : File.join(language_public, goal.to_s)
|
50
51
|
# Create the goal page.
|
51
|
-
site.collections['goals'].docs << GoalPage.new(site, site.source, dir, goal, language, layout)
|
52
|
+
site.collections['goals'].docs << GoalPage.new(site, site.source, dir, goal, language, layout, goal_index)
|
53
|
+
goal_index += 1
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
@@ -57,7 +59,7 @@ module JekyllOpenSdgPlugins
|
|
57
59
|
|
58
60
|
# A Page subclass used in the `CreateGoals` class.
|
59
61
|
class GoalPage < Jekyll::Page
|
60
|
-
def initialize(site, base, dir, goal, language, layout)
|
62
|
+
def initialize(site, base, dir, goal, language, layout, goal_index)
|
61
63
|
@site = site
|
62
64
|
@base = base
|
63
65
|
@dir = dir
|
@@ -65,8 +67,8 @@ module JekyllOpenSdgPlugins
|
|
65
67
|
|
66
68
|
goal_content = ''
|
67
69
|
if site.config['create_goals'].has_key?('goals')
|
68
|
-
if !site.config['create_goals']['goals'][
|
69
|
-
goal_content = site.config['create_goals']['goals'][
|
70
|
+
if !site.config['create_goals']['goals'][goal_index].nil?
|
71
|
+
goal_content = site.config['create_goals']['goals'][goal_index]['content']
|
70
72
|
end
|
71
73
|
end
|
72
74
|
@content = goal_content
|
@@ -7,17 +7,52 @@ module JekyllOpenSdgPlugins
|
|
7
7
|
priority :normal
|
8
8
|
|
9
9
|
def generate(site)
|
10
|
+
# Some references to clean up the code below.
|
11
|
+
language_config = site.config['languages']
|
12
|
+
indicator_config = site.config['create_indicators']
|
13
|
+
form_settings_config = site.config['indicator_config_form']
|
14
|
+
form_settings_meta = site.config['indicator_metadata_form']
|
15
|
+
form_settings_data = site.config['indicator_data_form']
|
16
|
+
|
17
|
+
# Special treatment of repository_link settings: prefix them
|
18
|
+
# with the repository_url_data site config if needed.
|
19
|
+
repo_url = site.config['repository_url_data']
|
20
|
+
if repo_url && repo_url != '' && repo_url.start_with?('http')
|
21
|
+
if form_settings_config != nil && form_settings_config && form_settings_config['enabled']
|
22
|
+
if form_settings_config['repository_link'] && form_settings_config['repository_link'] != ''
|
23
|
+
unless form_settings_config['repository_link'].start_with?('http')
|
24
|
+
form_settings_config['repository_link'] = repo_url + form_settings_config['repository_link']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
if form_settings_meta != nil && form_settings_meta && form_settings_meta['enabled']
|
29
|
+
if form_settings_meta['repository_link'] && form_settings_meta['repository_link'] != ''
|
30
|
+
unless form_settings_meta['repository_link'].start_with?('http')
|
31
|
+
form_settings_meta['repository_link'] = repo_url + form_settings_meta['repository_link']
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
if form_settings_data != nil && form_settings_data && form_settings_data['enabled']
|
36
|
+
if form_settings_data['repository_link'] && form_settings_data['repository_link'] != ''
|
37
|
+
unless form_settings_data['repository_link'].start_with?('http')
|
38
|
+
form_settings_data['repository_link'] = repo_url + form_settings_data['repository_link']
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
translations = site.data['translations']
|
10
45
|
# If site.create_indicators is set, create indicators per the metadata.
|
11
|
-
if
|
46
|
+
if (language_config and indicator_config and indicator_config.key?('layout') and indicator_config['layout'] != '')
|
12
47
|
# Decide what layout to use for the indicator pages.
|
13
|
-
layout =
|
48
|
+
layout = indicator_config['layout']
|
14
49
|
# See if we need to "map" any language codes.
|
15
50
|
languages_public = Hash.new
|
16
51
|
if site.config['languages_public']
|
17
52
|
languages_public = opensdg_languages_public(site)
|
18
53
|
end
|
19
54
|
# Loop through the languages.
|
20
|
-
|
55
|
+
language_config.each_with_index do |language, index|
|
21
56
|
# Get the "public language" (for URLs) which may be different.
|
22
57
|
language_public = language
|
23
58
|
if languages_public[language]
|
@@ -35,7 +70,7 @@ module JekyllOpenSdgPlugins
|
|
35
70
|
# Loop through the indicators (using metadata as a list).
|
36
71
|
metadata.each do |inid, meta|
|
37
72
|
permalink = inid
|
38
|
-
if meta.has_key?('permalink') and meta['permalink'] != ''
|
73
|
+
if (meta.has_key?('permalink') and meta['permalink'] != '')
|
39
74
|
permalink = meta['permalink']
|
40
75
|
end
|
41
76
|
# Add the language subfolder for all except the default (first) language.
|
@@ -45,24 +80,53 @@ module JekyllOpenSdgPlugins
|
|
45
80
|
site.collections['indicators'].docs << IndicatorPage.new(site, site.source, dir, inid, language, layout)
|
46
81
|
end
|
47
82
|
end
|
48
|
-
# Create the indicator configuration pages.
|
49
|
-
|
83
|
+
# Create the indicator settings configuration/metadata/data pages.
|
84
|
+
do_indicator_config_forms = form_settings_config && form_settings_config['enabled']
|
85
|
+
do_indicator_meta_forms = form_settings_meta && form_settings_meta['enabled']
|
86
|
+
do_indicator_data_forms = form_settings_data && form_settings_data['enabled']
|
87
|
+
use_translated_metadata = form_settings_meta && form_settings_meta['translated']
|
88
|
+
if do_indicator_config_forms || do_indicator_meta_forms || do_indicator_data_forms
|
89
|
+
|
50
90
|
metadata = {}
|
51
|
-
layout = site.config['create_config_forms']['layout']
|
52
91
|
if opensdg_translated_builds(site)
|
53
92
|
if site.data.has_key?('untranslated')
|
54
93
|
metadata = site.data['untranslated']['meta']
|
55
94
|
else
|
56
|
-
default_language =
|
95
|
+
default_language = language_config[0]
|
57
96
|
metadata = site.data[default_language]['meta']
|
58
97
|
end
|
59
98
|
else
|
60
99
|
metadata = site.data['meta']
|
61
100
|
end
|
101
|
+
|
102
|
+
metadata_by_language = {}
|
103
|
+
language_config.each do |language|
|
104
|
+
if opensdg_translated_builds(site)
|
105
|
+
metadata_by_language[language] = site.data[language]['meta']
|
106
|
+
else
|
107
|
+
metadata_by_language[language] = site.data['meta']
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Because we have config forms for indicator config or meta/data, we
|
112
|
+
# take over the meta/data_edit_url and configuration_edit_url settings
|
113
|
+
# here with simple relative links.
|
114
|
+
if do_indicator_config_forms
|
115
|
+
site.config['configuration_edit_url'] = 'config'
|
116
|
+
end
|
117
|
+
|
118
|
+
if do_indicator_meta_forms
|
119
|
+
site.config['metadata_edit_url'] = 'metadata'
|
120
|
+
end
|
121
|
+
|
122
|
+
if do_indicator_data_forms
|
123
|
+
site.config['data_edit_url'] = 'data'
|
124
|
+
end
|
125
|
+
|
62
126
|
# Loop through the indicators (using metadata as a list).
|
63
127
|
if !metadata.empty?
|
64
128
|
# Loop through the languages.
|
65
|
-
|
129
|
+
language_config.each_with_index do |language, index|
|
66
130
|
# Get the "public language" (for URLs) which may be different.
|
67
131
|
language_public = language
|
68
132
|
if languages_public[language]
|
@@ -70,14 +134,37 @@ module JekyllOpenSdgPlugins
|
|
70
134
|
end
|
71
135
|
metadata.each do |inid, meta|
|
72
136
|
permalink = inid
|
73
|
-
if meta.has_key?('permalink') and meta['permalink'] != ''
|
137
|
+
if (meta.has_key?('permalink') and meta['permalink'] != '')
|
74
138
|
permalink = meta['permalink']
|
75
139
|
end
|
76
|
-
|
140
|
+
dir_base = File.join(permalink)
|
77
141
|
if index != 0
|
78
|
-
|
142
|
+
dir_base = File.join(language_public, permalink)
|
143
|
+
end
|
144
|
+
|
145
|
+
if do_indicator_config_forms
|
146
|
+
dir = File.join(dir_base, 'config')
|
147
|
+
title = opensdg_translate_key('indicator.edit_configuration', translations, language)
|
148
|
+
config_type = 'indicator'
|
149
|
+
site.collections['pages'].docs << IndicatorConfigPage.new(site, site.source, dir, inid, language, meta, title, config_type, form_settings_config)
|
150
|
+
end
|
151
|
+
|
152
|
+
if do_indicator_meta_forms
|
153
|
+
metadata_to_use = meta
|
154
|
+
if use_translated_metadata
|
155
|
+
metadata_to_use = metadata_by_language[language][inid]
|
156
|
+
end
|
157
|
+
dir = File.join(dir_base, 'metadata')
|
158
|
+
title = opensdg_translate_key('indicator.edit_metadata', translations, language)
|
159
|
+
config_type = 'metadata'
|
160
|
+
site.collections['pages'].docs << IndicatorConfigPage.new(site, site.source, dir, inid, language, metadata_to_use, title, config_type, form_settings_meta)
|
161
|
+
end
|
162
|
+
|
163
|
+
if do_indicator_data_forms
|
164
|
+
dir = File.join(dir_base, 'data')
|
165
|
+
title = opensdg_translate_key('indicator.edit_data', translations, language)
|
166
|
+
site.collections['pages'].docs << IndicatorDataPage.new(site, site.source, dir, inid, language, title, form_settings_data)
|
79
167
|
end
|
80
|
-
site.collections['pages'].docs << IndicatorConfigPage.new(site, site.source, dir, inid, language, meta, layout)
|
81
168
|
end
|
82
169
|
end
|
83
170
|
end
|
@@ -86,7 +173,7 @@ module JekyllOpenSdgPlugins
|
|
86
173
|
end
|
87
174
|
end
|
88
175
|
|
89
|
-
# A Page subclass used in the `CreateIndicators` class.
|
176
|
+
# A Page subclass used in the `CreateIndicators` class for the indicators.
|
90
177
|
class IndicatorPage < Jekyll::Page
|
91
178
|
def initialize(site, base, dir, inid, language, layout)
|
92
179
|
@site = site
|
@@ -104,9 +191,9 @@ module JekyllOpenSdgPlugins
|
|
104
191
|
end
|
105
192
|
end
|
106
193
|
|
107
|
-
# A Page subclass used in the `CreateIndicators` class.
|
194
|
+
# A Page subclass used in the `CreateIndicators` class for the indicator config forms.
|
108
195
|
class IndicatorConfigPage < Jekyll::Page
|
109
|
-
def initialize(site, base, dir, inid, language, meta,
|
196
|
+
def initialize(site, base, dir, inid, language, meta, title, config_type, form_settings)
|
110
197
|
@site = site
|
111
198
|
@base = base
|
112
199
|
@dir = dir
|
@@ -115,12 +202,32 @@ module JekyllOpenSdgPlugins
|
|
115
202
|
self.process(@name)
|
116
203
|
self.data = {}
|
117
204
|
self.data['language'] = language
|
118
|
-
self.data['indicator_number'] = inid
|
119
|
-
self.data['config_type'] =
|
120
|
-
self.data['layout'] =
|
205
|
+
self.data['indicator_number'] = inid
|
206
|
+
self.data['config_type'] = config_type
|
207
|
+
self.data['layout'] = 'config-builder'
|
121
208
|
self.data['meta'] = meta
|
122
|
-
self.data['title'] =
|
209
|
+
self.data['title'] = title + ': ' + inid.gsub('-', '.')
|
123
210
|
self.data['config_filename'] = inid + '.yml'
|
211
|
+
self.data['form_settings'] = form_settings
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
# A Page subclass used in the `CreateIndicators` class for the indicator data forms.
|
216
|
+
class IndicatorDataPage < Jekyll::Page
|
217
|
+
def initialize(site, base, dir, inid, language, title, form_settings)
|
218
|
+
@site = site
|
219
|
+
@base = base
|
220
|
+
@dir = dir
|
221
|
+
@name = 'index.html'
|
222
|
+
|
223
|
+
self.process(@name)
|
224
|
+
self.data = {}
|
225
|
+
self.data['language'] = language
|
226
|
+
self.data['indicator_number'] = inid
|
227
|
+
self.data['layout'] = 'data-editor'
|
228
|
+
self.data['title'] = title + ': ' + inid.gsub('-', '.')
|
229
|
+
self.data['config_filename'] = 'indicator_' + inid
|
230
|
+
self.data['form_settings'] = form_settings
|
124
231
|
end
|
125
232
|
end
|
126
233
|
end
|
@@ -30,7 +30,7 @@ module JekyllOpenSdgPlugins
|
|
30
30
|
# To use the default 4 pages, simply put:
|
31
31
|
#
|
32
32
|
# create_pages: true
|
33
|
-
if site.config['languages'] and site.config['create_pages']
|
33
|
+
if (site.config['languages'] and site.config['create_pages'])
|
34
34
|
|
35
35
|
default_pages = [
|
36
36
|
{
|
@@ -54,7 +54,7 @@ module JekyllOpenSdgPlugins
|
|
54
54
|
}
|
55
55
|
]
|
56
56
|
pages = default_pages
|
57
|
-
if site.config['create_pages'].is_a?(Hash) and site.config['create_pages'].key?('pages')
|
57
|
+
if (site.config['create_pages'].is_a?(Hash) and site.config['create_pages'].key?('pages'))
|
58
58
|
# Backwards compatability to support the deprecated "pages" key.
|
59
59
|
pages = site.config['create_pages']['pages']
|
60
60
|
elsif site.config['create_pages'].is_a?(Array)
|
@@ -65,18 +65,33 @@ module JekyllOpenSdgPlugins
|
|
65
65
|
pages = pages.clone
|
66
66
|
|
67
67
|
# Hardcode the site configuration page if it's not already there.
|
68
|
+
form_settings = site.config['site_config_form']
|
68
69
|
config_page = pages.find { |page| page['layout'] == 'config-builder' }
|
69
70
|
if config_page == nil
|
70
|
-
if
|
71
|
+
if form_settings && form_settings['enabled']
|
71
72
|
pages.push({
|
72
73
|
'folder' => '/config',
|
73
|
-
'layout' =>
|
74
|
+
'layout' => 'config-builder',
|
74
75
|
'title' => 'Open SDG site configuration',
|
75
76
|
'config_type' => 'site',
|
76
|
-
'config_filename' => 'site_config.yml'
|
77
|
+
'config_filename' => 'site_config.yml',
|
77
78
|
})
|
78
79
|
end
|
79
80
|
end
|
81
|
+
# Make sure the form settings are set.
|
82
|
+
config_page = pages.find { |page| page['layout'] == 'config-builder' }
|
83
|
+
if config_page != nil && form_settings && form_settings['enabled']
|
84
|
+
# Special treatment of repository_link.
|
85
|
+
if form_settings['repository_link'] && form_settings['repository_link'] != ''
|
86
|
+
unless form_settings['repository_link'].start_with?('http')
|
87
|
+
repo_url = site.config['repository_url_site']
|
88
|
+
if repo_url && repo_url != '' && repo_url.start_with?('http')
|
89
|
+
form_settings['repository_link'] = repo_url + form_settings['repository_link']
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
config_page['form_settings'] = form_settings
|
94
|
+
end
|
80
95
|
|
81
96
|
# See if we need to "map" any language codes.
|
82
97
|
languages_public = Hash.new
|
@@ -25,7 +25,8 @@ module JekyllOpenSdgPlugins
|
|
25
25
|
'disaggregation' => 'stats/disaggregation.json',
|
26
26
|
'translations' => 'translations/translations.json',
|
27
27
|
'zip' => 'zip/all_indicators.json',
|
28
|
-
'indicator_downloads' => 'downloads/indicator-downloads.json'
|
28
|
+
'indicator_downloads' => 'downloads/indicator-downloads.json',
|
29
|
+
'data_packages' => 'data-packages/all.json',
|
29
30
|
}
|
30
31
|
end
|
31
32
|
|
@@ -43,7 +44,7 @@ module JekyllOpenSdgPlugins
|
|
43
44
|
rescue StandardError => e
|
44
45
|
# For backwards compatibility, forego the exception in some cases.
|
45
46
|
abort_build = true
|
46
|
-
if ['translations', 'indicator_downloads', 'disaggregation'].include? key
|
47
|
+
if ['translations', 'indicator_downloads', 'disaggregation', 'data_packages'].include? key
|
47
48
|
abort_build = false
|
48
49
|
elsif endpoint.include? '/untranslated/'
|
49
50
|
abort_build = false
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require "jekyll"
|
2
|
+
require_relative "helpers"
|
3
|
+
|
4
|
+
module JekyllOpenSdgPlugins
|
5
|
+
class MetadataSchemaToConfig < Jekyll::Generator
|
6
|
+
safe true
|
7
|
+
priority :lowest
|
8
|
+
|
9
|
+
def generate(site)
|
10
|
+
|
11
|
+
# Convert the metadata schema from the internal format into JSONSchema so
|
12
|
+
# it can be used to create config forms.
|
13
|
+
|
14
|
+
language_config = site.config['languages']
|
15
|
+
form_settings = site.config['indicator_metadata_form']
|
16
|
+
t = site.data['translations']
|
17
|
+
lang = language_config[0]
|
18
|
+
|
19
|
+
if form_settings && form_settings['enabled']
|
20
|
+
scopes = ['national', 'global']
|
21
|
+
if form_settings && form_settings.has_key?('scopes')
|
22
|
+
if form_settings['scopes'].kind_of?(Array) && form_settings['scopes'].length() > 0
|
23
|
+
scopes = form_settings['scopes']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
exclude_fields = []
|
27
|
+
if form_settings && form_settings.has_key?('exclude_fields')
|
28
|
+
if form_settings['exclude_fields'].kind_of?(Array) && form_settings['exclude_fields'].length() > 0
|
29
|
+
exclude_fields = form_settings['exclude_fields']
|
30
|
+
end
|
31
|
+
end
|
32
|
+
if form_settings && form_settings.has_key?('language') && form_settings['language'] != ''
|
33
|
+
lang = form_settings['language']
|
34
|
+
end
|
35
|
+
|
36
|
+
schema = {
|
37
|
+
"type" => "object",
|
38
|
+
"title" => opensdg_translate_key('indicator.edit_metadata', t, lang),
|
39
|
+
"properties" => {},
|
40
|
+
}
|
41
|
+
|
42
|
+
site.data['schema'].each do |field|
|
43
|
+
field_name = field['name']
|
44
|
+
field_scope = field['field']['scope']
|
45
|
+
next unless scopes.include?(field_scope)
|
46
|
+
next if exclude_fields.include?(field_name)
|
47
|
+
|
48
|
+
to_translate = field_name
|
49
|
+
if field['field'].has_key?('translation_key')
|
50
|
+
to_translate = field['field']['translation_key']
|
51
|
+
elsif t[lang].has_key?('metadata_fields') && t[lang]['metadata_fields'].has_key?(field_name)
|
52
|
+
to_translate = 'metadata_fields.' + field_name
|
53
|
+
elsif field['field'].has_key?('label')
|
54
|
+
to_translate = field['field']['label']
|
55
|
+
end
|
56
|
+
field_label = opensdg_translate_key(to_translate, t, lang)
|
57
|
+
|
58
|
+
schema['properties'][field_name] = {
|
59
|
+
"type" => "string",
|
60
|
+
"format" => "markdown",
|
61
|
+
"title" => field_label,
|
62
|
+
"description" => 'Scope: ' + field_scope + ', Field: ' + field_name,
|
63
|
+
}
|
64
|
+
schema['additionalProperties'] = true
|
65
|
+
end
|
66
|
+
|
67
|
+
# Regardless place the schema in site data so it can be used in Jekyll templates.
|
68
|
+
site.data['schema-indicator-metadata'] = schema
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -248,6 +248,7 @@
|
|
248
248
|
"type": "string",
|
249
249
|
"format": "color",
|
250
250
|
"title": "Line color",
|
251
|
+
"default": "#949494",
|
251
252
|
"description": "The color of the line.",
|
252
253
|
"links": [
|
253
254
|
{
|
@@ -257,9 +258,14 @@
|
|
257
258
|
]
|
258
259
|
},
|
259
260
|
"borderDash": {
|
260
|
-
"type": "
|
261
|
+
"type": "array",
|
261
262
|
"title": "Line dash type",
|
262
263
|
"description": "The type of line dash.",
|
264
|
+
"default": [10, 5],
|
265
|
+
"items": {
|
266
|
+
"type": "number"
|
267
|
+
},
|
268
|
+
"minItems": 2,
|
263
269
|
"links": [
|
264
270
|
{
|
265
271
|
"rel": "More information on the line dash setting",
|
@@ -294,12 +300,13 @@
|
|
294
300
|
"type": "string",
|
295
301
|
"format": "color",
|
296
302
|
"title": "Label color",
|
297
|
-
"description": "Color for the label text."
|
303
|
+
"description": "Color for the label text.",
|
304
|
+
"default": "#000000"
|
298
305
|
},
|
299
306
|
"backgroundColor": {
|
300
307
|
"type": "string",
|
301
308
|
"format": "color",
|
302
|
-
"default": "#
|
309
|
+
"default": "#ffffff",
|
303
310
|
"title": "Background color",
|
304
311
|
"description": "Background color for the label text."
|
305
312
|
}
|
@@ -313,7 +320,7 @@
|
|
313
320
|
"borderColor": {
|
314
321
|
"type": "string",
|
315
322
|
"format": "color",
|
316
|
-
"default": "#
|
323
|
+
"default": "#ffffff",
|
317
324
|
"title": "High-contrast line color",
|
318
325
|
"description": "The color of the line in high-contrast mode."
|
319
326
|
},
|
@@ -325,7 +332,7 @@
|
|
325
332
|
"fontColor": {
|
326
333
|
"type": "string",
|
327
334
|
"format": "color",
|
328
|
-
"default": "#
|
335
|
+
"default": "#ffffff",
|
329
336
|
"title": "High-contrast label color",
|
330
337
|
"description": "Color for the label text in high-contrast mode."
|
331
338
|
},
|
@@ -386,6 +393,40 @@
|
|
386
393
|
}
|
387
394
|
]
|
388
395
|
},
|
396
|
+
"graph_series_breaks": {
|
397
|
+
"options": {"collapsed": true},
|
398
|
+
"type": "array",
|
399
|
+
"title": "Graph series breaks",
|
400
|
+
"description": "A list of series break (ie, a gap among the years) lines to display on the graph.",
|
401
|
+
"items": {
|
402
|
+
"type": "object",
|
403
|
+
"title": "Series break",
|
404
|
+
"allOf": [
|
405
|
+
{ "$ref": "#/definitions/series_unit_constraint" },
|
406
|
+
{
|
407
|
+
"properties": {
|
408
|
+
"label_content": {
|
409
|
+
"type": "string",
|
410
|
+
"title": "Label content",
|
411
|
+
"default": "indicator.annotation_series_break",
|
412
|
+
"description": "The text to display for this series break."
|
413
|
+
},
|
414
|
+
"value": {
|
415
|
+
"type": "number",
|
416
|
+
"title": "Value",
|
417
|
+
"description": "The numeric value at which to place the series break. This number should be between 0 (the left side of the chart) and the number of years minus 1 (the right side of the chart)."
|
418
|
+
}
|
419
|
+
}
|
420
|
+
}
|
421
|
+
]
|
422
|
+
},
|
423
|
+
"links": [
|
424
|
+
{
|
425
|
+
"rel": "More information on the graph target lines setting",
|
426
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/indicator-configuration/#graph_series_breaks"
|
427
|
+
}
|
428
|
+
]
|
429
|
+
},
|
389
430
|
"graph_stacked_disaggregation": {
|
390
431
|
"type": "string",
|
391
432
|
"title": "Stacked disaggregation",
|
@@ -397,6 +438,40 @@
|
|
397
438
|
}
|
398
439
|
]
|
399
440
|
},
|
441
|
+
"graph_target_lines": {
|
442
|
+
"options": {"collapsed": true},
|
443
|
+
"type": "array",
|
444
|
+
"title": "Graph target lines",
|
445
|
+
"description": "A list of target lines to display on the graph.",
|
446
|
+
"items": {
|
447
|
+
"type": "object",
|
448
|
+
"title": "Target line",
|
449
|
+
"allOf": [
|
450
|
+
{ "$ref": "#/definitions/series_unit_constraint" },
|
451
|
+
{
|
452
|
+
"properties": {
|
453
|
+
"label_content": {
|
454
|
+
"type": "string",
|
455
|
+
"title": "Label content",
|
456
|
+
"default": "indicator.annotation_2030_target",
|
457
|
+
"description": "The text to display for this target line."
|
458
|
+
},
|
459
|
+
"value": {
|
460
|
+
"type": "number",
|
461
|
+
"title": "Value",
|
462
|
+
"description": "The numeric value at which to place the target line."
|
463
|
+
}
|
464
|
+
}
|
465
|
+
}
|
466
|
+
]
|
467
|
+
},
|
468
|
+
"links": [
|
469
|
+
{
|
470
|
+
"rel": "More information on the graph target lines setting",
|
471
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/indicator-configuration/#graph_target_lines"
|
472
|
+
}
|
473
|
+
]
|
474
|
+
},
|
400
475
|
"graph_title": {
|
401
476
|
"type": "string",
|
402
477
|
"title": "Graph title",
|
@@ -443,6 +518,17 @@
|
|
443
518
|
}
|
444
519
|
]
|
445
520
|
},
|
521
|
+
"indicator_available": {
|
522
|
+
"type": "string",
|
523
|
+
"title": "Indicator available",
|
524
|
+
"description": "An optional sub-title for the indicator, which displays below the indicator name. Intended for cases where the available data is slightly different than the indicator name.",
|
525
|
+
"links": [
|
526
|
+
{
|
527
|
+
"rel": "More information on the indicator available setting",
|
528
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/metadata-format/#recommended-special-fields"
|
529
|
+
}
|
530
|
+
]
|
531
|
+
},
|
446
532
|
"indicator_name": {
|
447
533
|
"type": "string",
|
448
534
|
"title": "Indicator name",
|
@@ -493,6 +579,18 @@
|
|
493
579
|
}
|
494
580
|
]
|
495
581
|
},
|
582
|
+
"placeholder": {
|
583
|
+
"title": "Placeholder indicator",
|
584
|
+
"type": "string",
|
585
|
+
"description": "Entering text here identifies this as a 'placeholder' indicator. The text will be displayed on the goal page, in place of a link to the indicator page.",
|
586
|
+
"format": "textarea",
|
587
|
+
"links": [
|
588
|
+
{
|
589
|
+
"rel": "More information the placeholder setting",
|
590
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/indicator-configuration/#placeholder"
|
591
|
+
}
|
592
|
+
]
|
593
|
+
},
|
496
594
|
"precision": {
|
497
595
|
"options": {"collapsed": true},
|
498
596
|
"type": "array",
|
@@ -565,6 +663,17 @@
|
|
565
663
|
"href": "https://open-sdg.readthedocs.io/en/latest/metadata-format/#recommended-special-fields"
|
566
664
|
}
|
567
665
|
]
|
666
|
+
},
|
667
|
+
"x_axis_label": {
|
668
|
+
"type": "string",
|
669
|
+
"title": "X axis label",
|
670
|
+
"description": "A label beneath the X axis on charts. This overrides the same site configuration setting.",
|
671
|
+
"links": [
|
672
|
+
{
|
673
|
+
"rel": "More information on the X axis label setting",
|
674
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/indicator-configuration/#x_axis_label"
|
675
|
+
}
|
676
|
+
]
|
568
677
|
}
|
569
678
|
},
|
570
679
|
"additionalProperties": true,
|
@@ -31,12 +31,22 @@
|
|
31
31
|
"options": {"collapsed": true},
|
32
32
|
"type": "object",
|
33
33
|
"title": "Analytics",
|
34
|
-
"description": "If these settings are used, usage statistics will be sent to Google Analytics.",
|
34
|
+
"description": "If these settings are used, usage statistics will be sent to Google Analytics. These are optional, and you don't have to use all of them. Typically you would just use one, such as the 'ua' option.",
|
35
35
|
"properties": {
|
36
|
-
"
|
36
|
+
"ua": {
|
37
37
|
"type": "string",
|
38
|
-
"title": "
|
39
|
-
"description": "The tracking ID
|
38
|
+
"title": "Universal Analytics (ua) tracking ID",
|
39
|
+
"description": "The tracking ID for the analytics.js approach, for your property on Google Analytics. Typically starts with 'UA-'."
|
40
|
+
},
|
41
|
+
"gtag": {
|
42
|
+
"type": "string",
|
43
|
+
"title": "gtag.js (gtag) tracking ID",
|
44
|
+
"description": "The tracking ID for the gtag.js approach, for your property on Google Analytics. Typically starts with 'G-'."
|
45
|
+
},
|
46
|
+
"gtm": {
|
47
|
+
"type": "string",
|
48
|
+
"title": "Google Tag Manager (gtm) tracking ID",
|
49
|
+
"description": "Your tracking ID for Google Tag Manager. Typically starts with 'GTM-'. Though this is included as an analytics approach, it requires additional configuration within Google Tag Manager in order to capture analytics."
|
40
50
|
}
|
41
51
|
},
|
42
52
|
"links": [
|
@@ -87,6 +97,45 @@
|
|
87
97
|
}
|
88
98
|
]
|
89
99
|
},
|
100
|
+
"contrast_type": {
|
101
|
+
"type": "string",
|
102
|
+
"title": "Contrast type",
|
103
|
+
"description": "The type of high-contrast toggle to use.",
|
104
|
+
"enum": ["default", "single", "long"],
|
105
|
+
"options": {
|
106
|
+
"enum_titles": [
|
107
|
+
"Default - two 'A' buttons side-by-side",
|
108
|
+
"Single - one 'A' button which toggles on/off",
|
109
|
+
"Long - text toggling between 'High contrast' and 'Default contrast'"
|
110
|
+
]
|
111
|
+
},
|
112
|
+
"links": [
|
113
|
+
{
|
114
|
+
"rel": "More information on the contrast type setting",
|
115
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#contrast_type"
|
116
|
+
}
|
117
|
+
]
|
118
|
+
},
|
119
|
+
"cookie_consent_form": {
|
120
|
+
"options": {"collapsed": true},
|
121
|
+
"type": "object",
|
122
|
+
"title": "Cookie consent form",
|
123
|
+
"description": "A cookie consent form for users",
|
124
|
+
"properties": {
|
125
|
+
"enabled": {
|
126
|
+
"type": "boolean",
|
127
|
+
"title": "Enabled",
|
128
|
+
"description": "Whether the cookie consent form will be enabled",
|
129
|
+
"format": "checkbox"
|
130
|
+
}
|
131
|
+
},
|
132
|
+
"links": [
|
133
|
+
{
|
134
|
+
"rel": "More information on the cookie_consent_form setting",
|
135
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#cookie_consent_form"
|
136
|
+
}
|
137
|
+
]
|
138
|
+
},
|
90
139
|
"country": {
|
91
140
|
"options": {"collapsed": true},
|
92
141
|
"type": "object",
|
@@ -113,35 +162,6 @@
|
|
113
162
|
}
|
114
163
|
]
|
115
164
|
},
|
116
|
-
"create_config_forms": {
|
117
|
-
"options": {"collapsed": true},
|
118
|
-
"type": "object",
|
119
|
-
"title": "Create configuration forms",
|
120
|
-
"description": "This setting can be used to automatically create the configuration form pages.",
|
121
|
-
"properties": {
|
122
|
-
"layout": {
|
123
|
-
"type": "string",
|
124
|
-
"title": "Layout",
|
125
|
-
"enum": [
|
126
|
-
"",
|
127
|
-
"config-builder"
|
128
|
-
],
|
129
|
-
"options": {
|
130
|
-
"enum_titles": [
|
131
|
-
"Do not automatically create config forms",
|
132
|
-
"config-builder"
|
133
|
-
]
|
134
|
-
},
|
135
|
-
"description": "The layout to use for the configuration form pages."
|
136
|
-
}
|
137
|
-
},
|
138
|
-
"links": [
|
139
|
-
{
|
140
|
-
"rel": "More information on the create config forms setting",
|
141
|
-
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#create_config_forms"
|
142
|
-
}
|
143
|
-
]
|
144
|
-
},
|
145
165
|
"create_goals": {
|
146
166
|
"options": {"collapsed": true},
|
147
167
|
"type": "object",
|
@@ -615,6 +635,7 @@
|
|
615
635
|
"type": "string",
|
616
636
|
"format": "color",
|
617
637
|
"title": "Graph color for headline",
|
638
|
+
"default": "#004466",
|
618
639
|
"description": "This setting can be used to customize the color used in the chart 'headlines'.",
|
619
640
|
"examples": [],
|
620
641
|
"links": [
|
@@ -628,6 +649,7 @@
|
|
628
649
|
"type": "string",
|
629
650
|
"format": "color",
|
630
651
|
"title": "Graph color for headline - high-contrast",
|
652
|
+
"default": "#55a6e5",
|
631
653
|
"description": "This setting can be used to customize the color used in the chart 'headlines' in high-contrast mode.",
|
632
654
|
"examples": [],
|
633
655
|
"links": [
|
@@ -679,6 +701,18 @@
|
|
679
701
|
}
|
680
702
|
]
|
681
703
|
},
|
704
|
+
"graph_title_from_series": {
|
705
|
+
"title": "Graph title from series",
|
706
|
+
"type": "boolean",
|
707
|
+
"description": "This setting can be set to `true` to use the selected series for the graph title, whenever possible.",
|
708
|
+
"format": "checkbox",
|
709
|
+
"links": [
|
710
|
+
{
|
711
|
+
"rel": "More information on the graph title from series setting",
|
712
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#graph_title_from_series"
|
713
|
+
}
|
714
|
+
]
|
715
|
+
},
|
682
716
|
"header": {
|
683
717
|
"options": {"collapsed": true},
|
684
718
|
"type": "object",
|
@@ -732,6 +766,30 @@
|
|
732
766
|
}
|
733
767
|
]
|
734
768
|
},
|
769
|
+
"hide_single_series": {
|
770
|
+
"title": "Hide single series",
|
771
|
+
"type": "boolean",
|
772
|
+
"description": "This setting can be used to hide the 'Series' toggle on indicators where there is only one choice.",
|
773
|
+
"format": "checkbox",
|
774
|
+
"links": [
|
775
|
+
{
|
776
|
+
"rel": "More information on the hide single series setting",
|
777
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#hide_single_series"
|
778
|
+
}
|
779
|
+
]
|
780
|
+
},
|
781
|
+
"hide_single_unit": {
|
782
|
+
"title": "Hide single unit",
|
783
|
+
"type": "boolean",
|
784
|
+
"description": "This setting can be used to hide the 'Unit' toggle on indicators where there is only one choice.",
|
785
|
+
"format": "checkbox",
|
786
|
+
"links": [
|
787
|
+
{
|
788
|
+
"rel": "More information on the hide single unit setting",
|
789
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#hide_single_unit"
|
790
|
+
}
|
791
|
+
]
|
792
|
+
},
|
735
793
|
"indicator_config_form": {
|
736
794
|
"options": {"collapsed": true},
|
737
795
|
"type": "object",
|
@@ -739,6 +797,69 @@
|
|
739
797
|
"description": "Configuration of the indicator configuration form.",
|
740
798
|
"$ref": "#/definitions/config_form_options"
|
741
799
|
},
|
800
|
+
"indicator_data_form": {
|
801
|
+
"options": {"collapsed": true},
|
802
|
+
"type": "object",
|
803
|
+
"title": "Indicator data form",
|
804
|
+
"description": "Configuration of the indicator data form.",
|
805
|
+
"properties": {
|
806
|
+
"enabled": {
|
807
|
+
"type": "boolean",
|
808
|
+
"title": "Enable this type of form",
|
809
|
+
"description": "If enabled, the indicator data form will be available.",
|
810
|
+
"format": "checkbox"
|
811
|
+
},
|
812
|
+
"repository_link": {
|
813
|
+
"type": "string",
|
814
|
+
"title": "Repository link",
|
815
|
+
"description": "The URL pattern of the 'Go to repository' link on the configuration page."
|
816
|
+
}
|
817
|
+
}
|
818
|
+
},
|
819
|
+
"indicator_metadata_form": {
|
820
|
+
"options": {"collapsed": true},
|
821
|
+
"type": "object",
|
822
|
+
"title": "Indicator metadata form",
|
823
|
+
"description": "Configuration of the indicator metadata form.",
|
824
|
+
"allOf": [
|
825
|
+
{ "$ref": "#/definitions/config_form_options" },
|
826
|
+
{
|
827
|
+
"properties": {
|
828
|
+
"language": {
|
829
|
+
"type": "string",
|
830
|
+
"title": "Language for editing",
|
831
|
+
"description": "Choose the language you prefer when editing metadata. This is used to translate the labels of the metadata fields."
|
832
|
+
},
|
833
|
+
"scopes": {
|
834
|
+
"options": {"collapsed": true},
|
835
|
+
"type": "array",
|
836
|
+
"title": "Metadata scopes",
|
837
|
+
"description": "Specify the 'scopes' of metadata to include on the form. Eg: 'national' or 'global'.",
|
838
|
+
"items": {
|
839
|
+
"type": "string",
|
840
|
+
"title": "Scope"
|
841
|
+
}
|
842
|
+
},
|
843
|
+
"exclude_fields": {
|
844
|
+
"options": {"collapsed": true},
|
845
|
+
"type": "array",
|
846
|
+
"title": "Exclude fields",
|
847
|
+
"description": "Specify any fields you would like to exclude from the form.",
|
848
|
+
"items": {
|
849
|
+
"type": "string",
|
850
|
+
"title": "Field"
|
851
|
+
}
|
852
|
+
},
|
853
|
+
"translated": {
|
854
|
+
"type": "boolean",
|
855
|
+
"title": "Display translated contents in the form",
|
856
|
+
"description": "This should only be enabled if you are using the 'subfolder' approach for your metadata.",
|
857
|
+
"format": "checkbox"
|
858
|
+
}
|
859
|
+
}
|
860
|
+
}
|
861
|
+
]
|
862
|
+
},
|
742
863
|
"languages": {
|
743
864
|
"options": {"collapsed": true},
|
744
865
|
"type": "array",
|
@@ -787,6 +908,41 @@
|
|
787
908
|
}
|
788
909
|
]
|
789
910
|
},
|
911
|
+
"logos": {
|
912
|
+
"options": {"collapsed": true},
|
913
|
+
"type": "array",
|
914
|
+
"title": "Logos",
|
915
|
+
"description": "This setting can be used to control the main logo (or logos).",
|
916
|
+
"items": {
|
917
|
+
"type": "object",
|
918
|
+
"title": "Logo",
|
919
|
+
"properties": {
|
920
|
+
"language": {
|
921
|
+
"type": "string",
|
922
|
+
"title": "Language",
|
923
|
+
"description": "The language on which this logo displays. Leave blank to show on all."
|
924
|
+
},
|
925
|
+
"src": {
|
926
|
+
"type": "string",
|
927
|
+
"minLength": 1,
|
928
|
+
"title": "Image file",
|
929
|
+
"description": "The image file (path or URL) for this logo"
|
930
|
+
},
|
931
|
+
"alt": {
|
932
|
+
"type": "string",
|
933
|
+
"minLength": 1,
|
934
|
+
"title": "Alt text",
|
935
|
+
"description": "The alt text for this logo"
|
936
|
+
}
|
937
|
+
}
|
938
|
+
},
|
939
|
+
"links": [
|
940
|
+
{
|
941
|
+
"rel": "More information on the logos setting",
|
942
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#logos"
|
943
|
+
}
|
944
|
+
]
|
945
|
+
},
|
790
946
|
"map_layers": {
|
791
947
|
"options": {"collapsed": true},
|
792
948
|
"type": "array",
|
@@ -1053,8 +1209,8 @@
|
|
1053
1209
|
"remote_data_prefix": {
|
1054
1210
|
"type": "string",
|
1055
1211
|
"minLength": 1,
|
1056
|
-
"title": "Remote data
|
1057
|
-
"description": "Specify the URL of your
|
1212
|
+
"title": "Remote data prefix",
|
1213
|
+
"description": "Specify the URL of the 'data service' that is generated from your data repository.",
|
1058
1214
|
"links": [
|
1059
1215
|
{
|
1060
1216
|
"rel": "More information on the remote data prefix setting",
|
@@ -1087,6 +1243,28 @@
|
|
1087
1243
|
}
|
1088
1244
|
]
|
1089
1245
|
},
|
1246
|
+
"repository_url_data": {
|
1247
|
+
"type": "string",
|
1248
|
+
"title": "Repository URL - Data",
|
1249
|
+
"description": "The URL of your data repository, eg: https://github.com/my-github-org/data",
|
1250
|
+
"links": [
|
1251
|
+
{
|
1252
|
+
"rel": "More information on the data repository URL setting",
|
1253
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#repository_url_data"
|
1254
|
+
}
|
1255
|
+
]
|
1256
|
+
},
|
1257
|
+
"repository_url_site": {
|
1258
|
+
"type": "string",
|
1259
|
+
"title": "Repository URL - Site",
|
1260
|
+
"description": "The URL of your site repository, eg: https://github.com/my-github-org/site",
|
1261
|
+
"links": [
|
1262
|
+
{
|
1263
|
+
"rel": "More information on the site repository URL setting",
|
1264
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#repository_url_site"
|
1265
|
+
}
|
1266
|
+
]
|
1267
|
+
},
|
1090
1268
|
"search_index_boost": {
|
1091
1269
|
"options": {"collapsed": true},
|
1092
1270
|
"type": "array",
|
@@ -1186,6 +1364,17 @@
|
|
1186
1364
|
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#validate_site_config"
|
1187
1365
|
}
|
1188
1366
|
]
|
1367
|
+
},
|
1368
|
+
"x_axis_label": {
|
1369
|
+
"type": "string",
|
1370
|
+
"title": "X axis label",
|
1371
|
+
"description": "A label beneath the X axis on charts. This is overridden by the same indicator configuration setting.",
|
1372
|
+
"links": [
|
1373
|
+
{
|
1374
|
+
"rel": "More information on the X axis label setting",
|
1375
|
+
"href": "https://open-sdg.readthedocs.io/en/latest/configuration/#x_axis_label"
|
1376
|
+
}
|
1377
|
+
]
|
1189
1378
|
}
|
1190
1379
|
},
|
1191
1380
|
"additionalProperties": true,
|
@@ -1273,6 +1462,12 @@
|
|
1273
1462
|
"config_form_options": {
|
1274
1463
|
"type": "object",
|
1275
1464
|
"properties": {
|
1465
|
+
"enabled": {
|
1466
|
+
"type": "boolean",
|
1467
|
+
"title": "Enable this type of form",
|
1468
|
+
"description": "If enabled, this type of configuration form will be available.",
|
1469
|
+
"format": "checkbox"
|
1470
|
+
},
|
1276
1471
|
"dropdowns": {
|
1277
1472
|
"type": "array",
|
1278
1473
|
"title": "Dropdown lists",
|
@@ -1306,6 +1501,16 @@
|
|
1306
1501
|
}
|
1307
1502
|
}
|
1308
1503
|
}
|
1504
|
+
},
|
1505
|
+
"repository_link": {
|
1506
|
+
"type": "string",
|
1507
|
+
"title": "Repository link",
|
1508
|
+
"description": "The URL pattern of the 'Go to repository' link on the configuration page."
|
1509
|
+
},
|
1510
|
+
"translation_link": {
|
1511
|
+
"type": "string",
|
1512
|
+
"title": "Translation link",
|
1513
|
+
"description": "The URL pattern for all 'Go to translation' links on the configuration page."
|
1309
1514
|
}
|
1310
1515
|
}
|
1311
1516
|
}
|
@@ -15,7 +15,11 @@ module JekyllOpenSdgPlugins
|
|
15
15
|
# Get a target number from an indicator number.
|
16
16
|
def get_target_number(indicator_number)
|
17
17
|
parts = indicator_number.split('.')
|
18
|
-
parts
|
18
|
+
if parts.length() < 2
|
19
|
+
indicator_number
|
20
|
+
else
|
21
|
+
parts[0] + '.' + parts[1]
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
# Is this string numeric?
|
@@ -61,10 +65,42 @@ module JekyllOpenSdgPlugins
|
|
61
65
|
list[incremented]
|
62
66
|
end
|
63
67
|
|
68
|
+
# Wrapper of get_previous_item specifically for indicators.
|
69
|
+
def get_previous_indicator(list, index)
|
70
|
+
indicator = get_previous_item(list, index)
|
71
|
+
# Skip placeholder indicators.
|
72
|
+
is_placeholder = (indicator.has_key?('placeholder') and indicator['placeholder'] != '')
|
73
|
+
while (is_placeholder)
|
74
|
+
index -= 1
|
75
|
+
if index < 0
|
76
|
+
index = list.length() - 1
|
77
|
+
end
|
78
|
+
indicator = get_previous_item(list, index)
|
79
|
+
is_placeholder = (indicator.has_key?('placeholder') and indicator['placeholder'] != '')
|
80
|
+
end
|
81
|
+
return indicator
|
82
|
+
end
|
83
|
+
|
84
|
+
# Wrapper of get_next_item specifically for indicators.
|
85
|
+
def get_next_indicator(list, index)
|
86
|
+
indicator = get_next_item(list, index)
|
87
|
+
# Skip placeholder indicators.
|
88
|
+
is_placeholder = (indicator.has_key?('placeholder') and indicator['placeholder'] != '')
|
89
|
+
while (is_placeholder)
|
90
|
+
index += 1
|
91
|
+
if index >= list.length()
|
92
|
+
index = 0
|
93
|
+
end
|
94
|
+
indicator = get_next_item(list, index)
|
95
|
+
is_placeholder = (indicator.has_key?('placeholder') and indicator['placeholder'] != '')
|
96
|
+
end
|
97
|
+
return indicator
|
98
|
+
end
|
99
|
+
|
64
100
|
# The Jekyll baseurl is user-configured, and can be inconsistent. This
|
65
101
|
# ensure it is consistent in whether it starts/ends with a slash.
|
66
102
|
def normalize_baseurl(baseurl)
|
67
|
-
if baseurl == ''
|
103
|
+
if baseurl == '' || baseurl.nil?
|
68
104
|
baseurl = '/'
|
69
105
|
end
|
70
106
|
if !baseurl.start_with? '/'
|
@@ -272,7 +308,8 @@ module JekyllOpenSdgPlugins
|
|
272
308
|
end
|
273
309
|
end
|
274
310
|
|
275
|
-
is_standalone = meta.has_key?('standalone') and meta['standalone']
|
311
|
+
is_standalone = (meta.has_key?('standalone') and meta['standalone'])
|
312
|
+
is_placeholder = (meta.has_key?('placeholder') and meta['placeholder'] != '')
|
276
313
|
|
277
314
|
# Set the goal for this language, once only.
|
278
315
|
if !is_standalone && already_added[language].index(goal_number) == nil
|
@@ -323,6 +360,14 @@ module JekyllOpenSdgPlugins
|
|
323
360
|
# Allow metadata 'sort' field to override the default sort.
|
324
361
|
indicator_sort = meta['sort']
|
325
362
|
end
|
363
|
+
if meta.has_key?('graph_annotations') && meta['graph_annotations'].length > 0
|
364
|
+
meta['graph_annotations'].each do |annotation|
|
365
|
+
if annotation.has_key?('borderDash') && annotation['borderDash'].is_a?(String)
|
366
|
+
annotation['borderDash'] = [2, 2]
|
367
|
+
opensdg_notice('The "borderDash" property in graph annotations must be an array. Using [2, 2].')
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
326
371
|
available_indicator = {
|
327
372
|
'number' => indicator_number,
|
328
373
|
'slug' => indicator_number.gsub('.', '-'),
|
@@ -383,8 +428,36 @@ module JekyllOpenSdgPlugins
|
|
383
428
|
doc.data['remote_data_prefix'] = normalize_baseurl(baseurl)
|
384
429
|
end
|
385
430
|
if opensdg_translated_builds(site)
|
431
|
+
doc.data['remote_data_prefix_untranslated'] = File.join(doc.data['remote_data_prefix'], 'untranslated')
|
386
432
|
doc.data['remote_data_prefix'] = File.join(doc.data['remote_data_prefix'], language)
|
433
|
+
else
|
434
|
+
doc.data['remote_data_prefix_untranslated'] = doc.data['remote_data_prefix']
|
435
|
+
end
|
436
|
+
|
437
|
+
# Set the logo for this page.
|
438
|
+
logo = {}
|
439
|
+
match = false
|
440
|
+
if site.config.has_key?('logos') && site.config['logos'].length > 0
|
441
|
+
match = site.config['logos'].find{ |item| item['language'] == language }
|
442
|
+
unless match
|
443
|
+
match = site.config['logos'].find{ |item| item.fetch('language', '') == '' }
|
444
|
+
end
|
445
|
+
end
|
446
|
+
if match
|
447
|
+
src = match['src']
|
448
|
+
unless src.start_with?('http')
|
449
|
+
src = normalize_baseurl(baseurl) + src
|
450
|
+
end
|
451
|
+
logo['src'] = src
|
452
|
+
logo['alt'] = opensdg_translate_key(match['alt'], translations, language)
|
453
|
+
else
|
454
|
+
logo['src'] = normalize_baseurl(baseurl) + 'assets/img/SDG_logo.png'
|
455
|
+
alt_text = opensdg_translate_key('general.sdg', translations, language)
|
456
|
+
alt_text += ' - '
|
457
|
+
alt_text += opensdg_translate_key('header.tag_line', translations, language)
|
458
|
+
logo['alt'] = alt_text
|
387
459
|
end
|
460
|
+
doc.data['logo'] = logo
|
388
461
|
|
389
462
|
if collection == 'indicators'
|
390
463
|
# For indicators we also set the current indicator/target/goal.
|
@@ -406,8 +479,8 @@ module JekyllOpenSdgPlugins
|
|
406
479
|
doc.data['target'] = available_targets[language].find {|x| x['number'] == target_number}
|
407
480
|
indicator_index = available_indicators[language].find_index {|x| x['number'] == indicator_number}
|
408
481
|
doc.data['indicator'] = available_indicators[language][indicator_index]
|
409
|
-
doc.data['next'] =
|
410
|
-
doc.data['previous'] =
|
482
|
+
doc.data['next'] = get_next_indicator(available_indicators[language], indicator_index)
|
483
|
+
doc.data['previous'] = get_previous_indicator(available_indicators[language], indicator_index)
|
411
484
|
|
412
485
|
elsif collection == 'goals'
|
413
486
|
# For goals we also set the current goal.
|
@@ -31,6 +31,15 @@ module JekyllOpenSdgPlugins
|
|
31
31
|
hash_to_hash(site.data['site_config_prod'], site.config)
|
32
32
|
end
|
33
33
|
|
34
|
+
# Look for environment variables for some settings.
|
35
|
+
env_settings = [
|
36
|
+
'REPOSITORY_URL_SITE',
|
37
|
+
]
|
38
|
+
env_settings.each do |setting|
|
39
|
+
if ENV.has_key?(setting)
|
40
|
+
site.config[setting.downcase] = ENV[setting]
|
41
|
+
end
|
42
|
+
end
|
34
43
|
end
|
35
44
|
|
36
45
|
# Copy properties from a hash onto another hash.
|
@@ -8,6 +8,8 @@ module Jekyll
|
|
8
8
|
# language of the current page and a date format given.
|
9
9
|
def t_date(date, format_type)
|
10
10
|
|
11
|
+
original = date
|
12
|
+
|
11
13
|
# Determine the language of the current page.
|
12
14
|
config = @context.registers[:site].config
|
13
15
|
translations = @context.registers[:site].data['translations']
|
@@ -57,7 +59,29 @@ module Jekyll
|
|
57
59
|
|
58
60
|
# Support timestamps.
|
59
61
|
if date.is_a? Integer
|
60
|
-
|
62
|
+
# Convert milliseconds to seconds if necessary.
|
63
|
+
if date > 9000000000
|
64
|
+
date = date / 1000
|
65
|
+
end
|
66
|
+
begin
|
67
|
+
date = Time.at(date).utc
|
68
|
+
rescue => err
|
69
|
+
return original
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Support other strings.
|
74
|
+
if date.is_a? String
|
75
|
+
begin
|
76
|
+
date = Time.parse(date).utc
|
77
|
+
rescue => err
|
78
|
+
return original
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Avoid nil errors.
|
83
|
+
unless date.is_a? Time
|
84
|
+
return original
|
61
85
|
end
|
62
86
|
|
63
87
|
# Convert the date into English.
|
@@ -11,6 +11,7 @@ require_relative "jekyll-open-sdg-plugins/create_pages"
|
|
11
11
|
require_relative "jekyll-open-sdg-plugins/sdg_variables"
|
12
12
|
require_relative "jekyll-open-sdg-plugins/search_index"
|
13
13
|
require_relative "jekyll-open-sdg-plugins/validate_indicator_config"
|
14
|
+
require_relative "jekyll-open-sdg-plugins/metadata_schema_to_config"
|
14
15
|
|
15
16
|
module JekyllOpenSdgPlugins
|
16
17
|
end
|
data/tests/_config.yml
CHANGED
@@ -9,6 +9,7 @@ data_edit_url: http://prose.io/#open-sdg/open-sdg-data-starter/edit/develop/data
|
|
9
9
|
metadata_edit_url: http://prose.io/#open-sdg/open-sdg-data-starter/edit/develop/meta/[id].md
|
10
10
|
languages:
|
11
11
|
- en
|
12
|
+
- es
|
12
13
|
|
13
14
|
title: Indicators For The Sustainable Development Goals
|
14
15
|
url: ""
|
@@ -145,3 +146,12 @@ exclude:
|
|
145
146
|
# max_zoom: 10
|
146
147
|
# subfolder: my-geojson-subfolder
|
147
148
|
# label: My map layer label (can be a translation key)
|
149
|
+
|
150
|
+
site_config_form:
|
151
|
+
repository_link: https://github.com/open-sdg/open-sdg-site-starter
|
152
|
+
indicator_config_form:
|
153
|
+
repository_link: https://github.com/open-sdg/open-sdg-data-starter/tree/develop/meta
|
154
|
+
indicator_metadata_form:
|
155
|
+
repository_link: https://github.com/open-sdg/open-sdg-data-starter/tree/develop/meta
|
156
|
+
scopes:
|
157
|
+
- national
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-open-sdg-plugins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0.pre.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brock Fanning
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/jekyll-open-sdg-plugins/create_pages.rb
|
73
73
|
- lib/jekyll-open-sdg-plugins/fetch_remote_data.rb
|
74
74
|
- lib/jekyll-open-sdg-plugins/helpers.rb
|
75
|
+
- lib/jekyll-open-sdg-plugins/metadata_schema_to_config.rb
|
75
76
|
- lib/jekyll-open-sdg-plugins/schema-indicator-config.json
|
76
77
|
- lib/jekyll-open-sdg-plugins/schema-site-config.json
|
77
78
|
- lib/jekyll-open-sdg-plugins/sdg_variables.rb
|
@@ -100,9 +101,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
101
|
version: '0'
|
101
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
103
|
requirements:
|
103
|
-
- - "
|
104
|
+
- - ">"
|
104
105
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
106
|
+
version: 1.3.1
|
106
107
|
requirements: []
|
107
108
|
rubygems_version: 3.1.4
|
108
109
|
signing_key:
|