jekyll-open-sdg-plugins 1.3.0.pre.beta1 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1579412cd0fc422e1af1ee418f9dcf89d10a8491ff0ce362c269ca49ad3b8f9d
4
- data.tar.gz: c67a8ba97b93d0264e28f9cd764cd90f6a7db755ad10e1e5823a1cd4a25b927d
3
+ metadata.gz: f535300e051b6be3aae0ab0fc136f5fdda75d2453dd832388f3408ff8d8370d2
4
+ data.tar.gz: bcd82b1a845f92ed56c49b92f175d778bd9bfc91c1276d32dcc244b29821d685
5
5
  SHA512:
6
- metadata.gz: 77a40b3a54553c73cc1ff3a560310f97e709b94be07c1b539ed92b0423803ba628454484b3910dc62b4175463fd520c7cd4c5a90c9f051cb6fde6bf6842c6f2a
7
- data.tar.gz: d556a58a95a4627a25d947c8dd66470b3f3a580f56baa3c86da25b2b82499a5913a4ef3ec42083676cf7b7e3dffd2f8c9b944a8499e9492ab00a64d6ab0d1191
6
+ metadata.gz: edbdfc568479a3eb1e6c39a26a9e81d97e8edf9d082c32cd62448ecc6b14802b7f007afcb9076fb08671647abb56e91317604f10031cb6a312fef98cc295c4bd
7
+ data.tar.gz: '02282d6323e8b8224d8d1b7404753d6bd3ae7e075dcbc3183b11a01e113927e60c7a8058e33afb2918d9759df84ab547d0cf80a2a6858f8e2ee9f502b0cd8c1d'
@@ -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
@@ -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 site.config['languages'] and site.config['create_indicators'] and site.config['create_indicators'].key?('layout') and site.config['create_indicators']['layout'] != ''
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 = site.config['create_indicators']['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
- site.config['languages'].each_with_index do |language, index|
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
- if site.config['create_config_forms'] && site.config['create_config_forms'].key?('layout') && site.config['create_config_forms']['layout'] != ''
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 = site.config['languages'][0]
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
- site.config['languages'].each_with_index do |language, index|
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
- dir = File.join('config', permalink)
140
+ dir_base = File.join(permalink)
77
141
  if index != 0
78
- dir = File.join(language_public, 'config', permalink)
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, layout)
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.gsub('-', '.')
119
- self.data['config_type'] = 'indicator'
120
- self.data['layout'] = 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'] = 'Open SDG indicator configuration: ' + self.data['indicator_number']
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 site.config['create_config_forms'] && site.config['create_config_forms'].key?('layout') && site.config['create_config_forms']['layout'] != ''
71
+ if form_settings && form_settings['enabled']
71
72
  pages.push({
72
73
  'folder' => '/config',
73
- 'layout' => site.config['create_config_forms']['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
@@ -218,142 +218,131 @@
218
218
  "items": {
219
219
  "type": "object",
220
220
  "title": "Graph annotation",
221
- "properties": {
222
- "preset": {
223
- "type": "string",
224
- "title": "Preset",
225
- "enum": ["target_line"],
226
- "description": "A preset bundle of configurations."
227
- },
228
- "value": {
229
- "type": "number",
230
- "minimum": 0,
231
- "title": "Value",
232
- "description": "The value at which to draw the line. For horizontal lines, this number corresponds to your actual data. For vertical lines, 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)."
233
- },
234
- "endValue": {
235
- "type": "number",
236
- "title": "End value",
237
- "description": "Optionally add a different ending value for the line."
238
- },
239
- "description": {
240
- "type": "string",
241
- "title": "Description",
242
- "description": "A description of the annotation to be read by screenreaders."
243
- },
244
- "unit": {
245
- "type": "string",
246
- "title": "Unit",
247
- "description": "The unit of measurement the annotation displays on."
248
- },
249
- "series": {
250
- "type": "string",
251
- "title": "Series",
252
- "description": "The series the annotation displays on."
253
- },
254
- "mode": {
255
- "type": "string",
256
- "title": "Mode",
257
- "description": "Whether the line will be vertical or horizontal.",
258
- "enum": ["horizontal", "vertical"]
259
- },
260
- "borderColor": {
261
- "type": "string",
262
- "format": "color",
263
- "title": "Line color",
264
- "description": "The color of the line.",
265
- "links": [
266
- {
267
- "rel": "More information on the border color setting",
268
- "href": "https://github.com/chartjs/chartjs-plugin-annotation/blob/master/README.md"
269
- }
270
- ]
271
- },
272
- "borderDash": {
273
- "type": "string",
274
- "title": "Line dash type",
275
- "description": "The type of line dash.",
276
- "links": [
277
- {
278
- "rel": "More information on the line dash setting",
279
- "href": "https://github.com/chartjs/chartjs-plugin-annotation/blob/master/README.md"
280
- }
281
- ]
282
- },
283
- "label": {
284
- "type": "object",
285
- "title": "Label",
286
- "description": "A text label for the annotation.",
221
+ "allOf": [
222
+ { "$ref": "#/definitions/series_unit_constraint" },
223
+ {
287
224
  "properties": {
288
- "position": {
289
- "type": "string",
290
- "title": "Position",
291
- "description": "Placement of the label along the line.",
292
- "enum": [
293
- "top",
294
- "bottom",
295
- "left",
296
- "right",
297
- "center"
298
- ]
225
+ "value": {
226
+ "type": "number",
227
+ "minimum": 0,
228
+ "title": "Value",
229
+ "description": "The value at which to draw the line. For horizontal lines, this number corresponds to your actual data. For vertical lines, 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)."
299
230
  },
300
- "content": {
301
- "type": "string",
302
- "minLength": 1,
303
- "title": "Content",
304
- "description": "Text of the line label."
231
+ "endValue": {
232
+ "type": "number",
233
+ "title": "End value",
234
+ "description": "Optionally add a different ending value for the line."
305
235
  },
306
- "fontColor": {
236
+ "description": {
307
237
  "type": "string",
308
- "format": "color",
309
- "title": "Label color",
310
- "description": "Color for the label text."
238
+ "title": "Description",
239
+ "description": "A description of the annotation to be read by screenreaders."
311
240
  },
312
- "backgroundColor": {
241
+ "mode": {
313
242
  "type": "string",
314
- "format": "color",
315
- "default": "#FFFFFFF",
316
- "title": "Background color",
317
- "description": "Background color for the label text."
318
- }
319
- }
320
- },
321
- "highContrast": {
322
- "type": "object",
323
- "title": "High contrast options",
324
- "description": "High-contrast overrides of certain color.",
325
- "properties": {
243
+ "title": "Mode",
244
+ "description": "Whether the line will be vertical or horizontal.",
245
+ "enum": ["horizontal", "vertical"]
246
+ },
326
247
  "borderColor": {
327
248
  "type": "string",
328
249
  "format": "color",
329
- "default": "#FFFFFF",
330
- "title": "High-contrast line color",
331
- "description": "The color of the line in high-contrast mode."
250
+ "title": "Line color",
251
+ "description": "The color of the line.",
252
+ "links": [
253
+ {
254
+ "rel": "More information on the border color setting",
255
+ "href": "https://github.com/chartjs/chartjs-plugin-annotation/blob/master/README.md"
256
+ }
257
+ ]
258
+ },
259
+ "borderDash": {
260
+ "type": "string",
261
+ "title": "Line dash type",
262
+ "description": "The type of line dash.",
263
+ "links": [
264
+ {
265
+ "rel": "More information on the line dash setting",
266
+ "href": "https://github.com/chartjs/chartjs-plugin-annotation/blob/master/README.md"
267
+ }
268
+ ]
332
269
  },
333
270
  "label": {
334
271
  "type": "object",
335
- "title": "High contrast label",
336
- "description": "High-contrast version of the label.",
272
+ "title": "Label",
273
+ "description": "A text label for the annotation.",
337
274
  "properties": {
275
+ "position": {
276
+ "type": "string",
277
+ "title": "Position",
278
+ "description": "Placement of the label along the line.",
279
+ "enum": [
280
+ "top",
281
+ "bottom",
282
+ "left",
283
+ "right",
284
+ "center"
285
+ ]
286
+ },
287
+ "content": {
288
+ "type": "string",
289
+ "minLength": 1,
290
+ "title": "Content",
291
+ "description": "Text of the line label."
292
+ },
338
293
  "fontColor": {
339
294
  "type": "string",
340
295
  "format": "color",
341
- "default": "#FFFFFF",
342
- "title": "High-contrast label color",
343
- "description": "Color for the label text in high-contrast mode."
296
+ "title": "Label color",
297
+ "description": "Color for the label text."
344
298
  },
345
299
  "backgroundColor": {
346
300
  "type": "string",
347
301
  "format": "color",
348
- "default": "#000000",
349
- "title": "High-contrast background color",
350
- "description": "Background color for the label text in high-contrast mode."
302
+ "default": "#FFFFFFF",
303
+ "title": "Background color",
304
+ "description": "Background color for the label text."
305
+ }
306
+ }
307
+ },
308
+ "highContrast": {
309
+ "type": "object",
310
+ "title": "High contrast options",
311
+ "description": "High-contrast overrides of certain color.",
312
+ "properties": {
313
+ "borderColor": {
314
+ "type": "string",
315
+ "format": "color",
316
+ "default": "#FFFFFF",
317
+ "title": "High-contrast line color",
318
+ "description": "The color of the line in high-contrast mode."
319
+ },
320
+ "label": {
321
+ "type": "object",
322
+ "title": "High contrast label",
323
+ "description": "High-contrast version of the label.",
324
+ "properties": {
325
+ "fontColor": {
326
+ "type": "string",
327
+ "format": "color",
328
+ "default": "#FFFFFF",
329
+ "title": "High-contrast label color",
330
+ "description": "Color for the label text in high-contrast mode."
331
+ },
332
+ "backgroundColor": {
333
+ "type": "string",
334
+ "format": "color",
335
+ "default": "#000000",
336
+ "title": "High-contrast background color",
337
+ "description": "Background color for the label text in high-contrast mode."
338
+ }
339
+ }
351
340
  }
352
341
  }
353
342
  }
354
343
  }
355
344
  }
356
- }
345
+ ]
357
346
  },
358
347
  "links": [
359
348
  {
@@ -370,30 +359,25 @@
370
359
  "items": {
371
360
  "type": "object",
372
361
  "title": "Graph limit",
373
- "properties": {
374
- "minimum": {
375
- "type": "number",
376
- "minimum": 0,
377
- "title": "Minimum",
378
- "description": "Minimum value for the y axis."
379
- },
380
- "maximum": {
381
- "type": "number",
382
- "minimum": 0,
383
- "title": "Maximum",
384
- "description": "Maximum value for the y axis."
385
- },
386
- "unit": {
387
- "type": "string",
388
- "title": "Unit",
389
- "description": "The unit of measurement the limits apply to."
390
- },
391
- "series": {
392
- "type": "string",
393
- "title": "Series",
394
- "description": "The series the limits apply to."
362
+ "allOf": [
363
+ { "$ref": "#/definitions/series_unit_constraint" },
364
+ {
365
+ "properties": {
366
+ "minimum": {
367
+ "type": "number",
368
+ "minimum": 0,
369
+ "title": "Minimum",
370
+ "description": "Minimum value for the y axis."
371
+ },
372
+ "maximum": {
373
+ "type": "number",
374
+ "minimum": 0,
375
+ "title": "Maximum",
376
+ "description": "Maximum value for the y axis."
377
+ }
378
+ }
395
379
  }
396
- }
380
+ ]
397
381
  },
398
382
  "links": [
399
383
  {
@@ -432,24 +416,19 @@
432
416
  "items": {
433
417
  "type": "object",
434
418
  "title": "Graph title",
435
- "properties": {
436
- "title": {
437
- "type": "string",
438
- "minLength": 1,
439
- "title": "Title",
440
- "description": "The graph title."
441
- },
442
- "unit": {
443
- "type": "string",
444
- "title": "Unit",
445
- "description": "The unit of measurement the title applies to."
446
- },
447
- "series": {
448
- "type": "string",
449
- "title": "Series",
450
- "description": "The series the title applies to."
419
+ "allOf": [
420
+ { "$ref": "#/definitions/series_unit_constraint" },
421
+ {
422
+ "properties": {
423
+ "title": {
424
+ "type": "string",
425
+ "minLength": 1,
426
+ "title": "Title",
427
+ "description": "The graph title."
428
+ }
429
+ }
451
430
  }
452
- }
431
+ ]
453
432
  }
454
433
  },
455
434
  "graph_type": {
@@ -464,6 +443,17 @@
464
443
  }
465
444
  ]
466
445
  },
446
+ "indicator_available": {
447
+ "type": "string",
448
+ "title": "Indicator available",
449
+ "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.",
450
+ "links": [
451
+ {
452
+ "rel": "More information on the indicator available setting",
453
+ "href": "https://open-sdg.readthedocs.io/en/latest/metadata-format/#recommended-special-fields"
454
+ }
455
+ ]
456
+ },
467
457
  "indicator_name": {
468
458
  "type": "string",
469
459
  "title": "Indicator name",
@@ -514,6 +504,28 @@
514
504
  }
515
505
  ]
516
506
  },
507
+ "precision": {
508
+ "options": {"collapsed": true},
509
+ "type": "array",
510
+ "title": "Precision rules",
511
+ "description": "Control the number of decimal places for data in this indicator.",
512
+ "items": {
513
+ "type": "object",
514
+ "title": "Precision rule",
515
+ "allOf": [
516
+ { "$ref": "#/definitions/series_unit_constraint" },
517
+ {
518
+ "properties": {
519
+ "decimals": {
520
+ "type": "number",
521
+ "title": "Decimals",
522
+ "description": "The number of decimal places"
523
+ }
524
+ }
525
+ }
526
+ ]
527
+ }
528
+ },
517
529
  "reporting_status": {
518
530
  "type": "string",
519
531
  "title": "Reporting status",
@@ -566,5 +578,22 @@
566
578
  ]
567
579
  }
568
580
  },
569
- "additionalProperties": true
581
+ "additionalProperties": true,
582
+ "definitions": {
583
+ "series_unit_constraint": {
584
+ "type": "object",
585
+ "properties": {
586
+ "series": {
587
+ "type": "string",
588
+ "title": "Series",
589
+ "description": "Limit to this particular series"
590
+ },
591
+ "unit": {
592
+ "type": "string",
593
+ "title": "Unit",
594
+ "description": "Limit to this particular unit"
595
+ }
596
+ }
597
+ }
598
+ }
570
599
  }
@@ -87,6 +87,25 @@
87
87
  }
88
88
  ]
89
89
  },
90
+ "contrast_type": {
91
+ "type": "string",
92
+ "title": "Contrast type",
93
+ "description": "The type of high-contrast toggle to use.",
94
+ "enum": ["default", "single", "long"],
95
+ "options": {
96
+ "enum_titles": [
97
+ "Default - two 'A' buttons side-by-side",
98
+ "Single - one 'A' button which toggles on/off",
99
+ "Long - text toggling between 'High contrast' and 'Default contrast'"
100
+ ]
101
+ },
102
+ "links": [
103
+ {
104
+ "rel": "More information on the contrast type setting",
105
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#contrast_type"
106
+ }
107
+ ]
108
+ },
90
109
  "country": {
91
110
  "options": {"collapsed": true},
92
111
  "type": "object",
@@ -113,35 +132,6 @@
113
132
  }
114
133
  ]
115
134
  },
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
135
  "create_goals": {
146
136
  "options": {"collapsed": true},
147
137
  "type": "object",
@@ -611,6 +601,34 @@
611
601
  }
612
602
  ]
613
603
  },
604
+ "graph_color_headline": {
605
+ "type": "string",
606
+ "format": "color",
607
+ "title": "Graph color for headline",
608
+ "default": "#004466",
609
+ "description": "This setting can be used to customize the color used in the chart 'headlines'.",
610
+ "examples": [],
611
+ "links": [
612
+ {
613
+ "rel": "More information on the graph color headline setting",
614
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#graph_color_headline"
615
+ }
616
+ ]
617
+ },
618
+ "graph_color_headline_high_contrast": {
619
+ "type": "string",
620
+ "format": "color",
621
+ "title": "Graph color for headline - high-contrast",
622
+ "default": "#55a6e5",
623
+ "description": "This setting can be used to customize the color used in the chart 'headlines' in high-contrast mode.",
624
+ "examples": [],
625
+ "links": [
626
+ {
627
+ "rel": "More information on the graph color headline high-contrast setting",
628
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#graph_color_headline_high_contrast"
629
+ }
630
+ ]
631
+ },
614
632
  "graph_color_set": {
615
633
  "type": "string",
616
634
  "title": "Graph color set",
@@ -653,6 +671,18 @@
653
671
  }
654
672
  ]
655
673
  },
674
+ "graph_title_from_series": {
675
+ "title": "Graph title from series",
676
+ "type": "boolean",
677
+ "description": "This setting can be set to `true` to use the selected series for the graph title, whenever possible.",
678
+ "format": "checkbox",
679
+ "links": [
680
+ {
681
+ "rel": "More information on the graph title from series setting",
682
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#graph_title_from_series"
683
+ }
684
+ ]
685
+ },
656
686
  "header": {
657
687
  "options": {"collapsed": true},
658
688
  "type": "object",
@@ -713,6 +743,69 @@
713
743
  "description": "Configuration of the indicator configuration form.",
714
744
  "$ref": "#/definitions/config_form_options"
715
745
  },
746
+ "indicator_data_form": {
747
+ "options": {"collapsed": true},
748
+ "type": "object",
749
+ "title": "Indicator data form",
750
+ "description": "Configuration of the indicator data form.",
751
+ "properties": {
752
+ "enabled": {
753
+ "type": "boolean",
754
+ "title": "Enable this type of form",
755
+ "description": "If enabled, the indicator data form will be available.",
756
+ "format": "checkbox"
757
+ },
758
+ "repository_link": {
759
+ "type": "string",
760
+ "title": "Repository link",
761
+ "description": "The URL pattern of the 'Go to repository' link on the configuration page."
762
+ }
763
+ }
764
+ },
765
+ "indicator_metadata_form": {
766
+ "options": {"collapsed": true},
767
+ "type": "object",
768
+ "title": "Indicator metadata form",
769
+ "description": "Configuration of the indicator metadata form.",
770
+ "allOf": [
771
+ { "$ref": "#/definitions/config_form_options" },
772
+ {
773
+ "properties": {
774
+ "language": {
775
+ "type": "string",
776
+ "title": "Language for editing",
777
+ "description": "Choose the language you prefer when editing metadata. This is used to translate the labels of the metadata fields."
778
+ },
779
+ "scopes": {
780
+ "options": {"collapsed": true},
781
+ "type": "array",
782
+ "title": "Metadata scopes",
783
+ "description": "Specify the 'scopes' of metadata to include on the form. Eg: 'national' or 'global'.",
784
+ "items": {
785
+ "type": "string",
786
+ "title": "Scope"
787
+ }
788
+ },
789
+ "exclude_fields": {
790
+ "options": {"collapsed": true},
791
+ "type": "array",
792
+ "title": "Exclude fields",
793
+ "description": "Specify any fields you would like to exclude from the form.",
794
+ "items": {
795
+ "type": "string",
796
+ "title": "Field"
797
+ }
798
+ },
799
+ "translated": {
800
+ "type": "boolean",
801
+ "title": "Display translated contents in the form",
802
+ "description": "This should only be enabled if you are using the 'subfolder' approach for your metadata.",
803
+ "format": "checkbox"
804
+ }
805
+ }
806
+ }
807
+ ]
808
+ },
716
809
  "languages": {
717
810
  "options": {"collapsed": true},
718
811
  "type": "array",
@@ -761,6 +854,41 @@
761
854
  }
762
855
  ]
763
856
  },
857
+ "logos": {
858
+ "options": {"collapsed": true},
859
+ "type": "array",
860
+ "title": "Logos",
861
+ "description": "This setting can be used to control the main logo (or logos).",
862
+ "items": {
863
+ "type": "object",
864
+ "title": "Logo",
865
+ "properties": {
866
+ "language": {
867
+ "type": "string",
868
+ "title": "Language",
869
+ "description": "The language on which this logo displays. Leave blank to show on all."
870
+ },
871
+ "src": {
872
+ "type": "string",
873
+ "minLength": 1,
874
+ "title": "Image file",
875
+ "description": "The image file (path or URL) for this logo"
876
+ },
877
+ "alt": {
878
+ "type": "string",
879
+ "minLength": 1,
880
+ "title": "Alt text",
881
+ "description": "The alt text for this logo"
882
+ }
883
+ }
884
+ },
885
+ "links": [
886
+ {
887
+ "rel": "More information on the logos setting",
888
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#logos"
889
+ }
890
+ ]
891
+ },
764
892
  "map_layers": {
765
893
  "options": {"collapsed": true},
766
894
  "type": "array",
@@ -1027,8 +1155,8 @@
1027
1155
  "remote_data_prefix": {
1028
1156
  "type": "string",
1029
1157
  "minLength": 1,
1030
- "title": "Remote data repository URL",
1031
- "description": "Specify the URL of your published data repository.",
1158
+ "title": "Remote data prefix",
1159
+ "description": "Specify the URL of the 'data service' that is generated from your data repository.",
1032
1160
  "links": [
1033
1161
  {
1034
1162
  "rel": "More information on the remote data prefix setting",
@@ -1061,6 +1189,28 @@
1061
1189
  }
1062
1190
  ]
1063
1191
  },
1192
+ "repository_url_data": {
1193
+ "type": "string",
1194
+ "title": "Repository URL - Data",
1195
+ "description": "The URL of your data repository, eg: https://github.com/my-github-org/data",
1196
+ "links": [
1197
+ {
1198
+ "rel": "More information on the data repository URL setting",
1199
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#repository_url_data"
1200
+ }
1201
+ ]
1202
+ },
1203
+ "repository_url_site": {
1204
+ "type": "string",
1205
+ "title": "Repository URL - Site",
1206
+ "description": "The URL of your site repository, eg: https://github.com/my-github-org/site",
1207
+ "links": [
1208
+ {
1209
+ "rel": "More information on the site repository URL setting",
1210
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#repository_url_site"
1211
+ }
1212
+ ]
1213
+ },
1064
1214
  "search_index_boost": {
1065
1215
  "options": {"collapsed": true},
1066
1216
  "type": "array",
@@ -1247,6 +1397,12 @@
1247
1397
  "config_form_options": {
1248
1398
  "type": "object",
1249
1399
  "properties": {
1400
+ "enabled": {
1401
+ "type": "boolean",
1402
+ "title": "Enable this type of form",
1403
+ "description": "If enabled, this type of configuration form will be available.",
1404
+ "format": "checkbox"
1405
+ },
1250
1406
  "dropdowns": {
1251
1407
  "type": "array",
1252
1408
  "title": "Dropdown lists",
@@ -1280,6 +1436,16 @@
1280
1436
  }
1281
1437
  }
1282
1438
  }
1439
+ },
1440
+ "repository_link": {
1441
+ "type": "string",
1442
+ "title": "Repository link",
1443
+ "description": "The URL pattern of the 'Go to repository' link on the configuration page."
1444
+ },
1445
+ "translation_link": {
1446
+ "type": "string",
1447
+ "title": "Translation link",
1448
+ "description": "The URL pattern for all 'Go to translation' links on the configuration page."
1283
1449
  }
1284
1450
  }
1285
1451
  }
@@ -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[0] + '.' + parts[1]
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?
@@ -64,7 +68,7 @@ module JekyllOpenSdgPlugins
64
68
  # The Jekyll baseurl is user-configured, and can be inconsistent. This
65
69
  # ensure it is consistent in whether it starts/ends with a slash.
66
70
  def normalize_baseurl(baseurl)
67
- if baseurl == ''
71
+ if baseurl == '' || baseurl.nil?
68
72
  baseurl = '/'
69
73
  end
70
74
  if !baseurl.start_with? '/'
@@ -272,7 +276,7 @@ module JekyllOpenSdgPlugins
272
276
  end
273
277
  end
274
278
 
275
- is_standalone = meta.has_key?('standalone') and meta['standalone']
279
+ is_standalone = (meta.has_key?('standalone') and meta['standalone'])
276
280
 
277
281
  # Set the goal for this language, once only.
278
282
  if !is_standalone && already_added[language].index(goal_number) == nil
@@ -383,8 +387,36 @@ module JekyllOpenSdgPlugins
383
387
  doc.data['remote_data_prefix'] = normalize_baseurl(baseurl)
384
388
  end
385
389
  if opensdg_translated_builds(site)
390
+ doc.data['remote_data_prefix_untranslated'] = File.join(doc.data['remote_data_prefix'], 'untranslated')
386
391
  doc.data['remote_data_prefix'] = File.join(doc.data['remote_data_prefix'], language)
392
+ else
393
+ doc.data['remote_data_prefix_untranslated'] = doc.data['remote_data_prefix']
394
+ end
395
+
396
+ # Set the logo for this page.
397
+ logo = {}
398
+ match = false
399
+ if site.config.has_key?('logos') && site.config['logos'].length > 0
400
+ match = site.config['logos'].find{ |item| item['language'] == language }
401
+ unless match
402
+ match = site.config['logos'].find{ |item| item.fetch('language', '') == '' }
403
+ end
404
+ end
405
+ if match
406
+ src = match['src']
407
+ unless src.start_with?('http')
408
+ src = normalize_baseurl(baseurl) + src
409
+ end
410
+ logo['src'] = src
411
+ logo['alt'] = opensdg_translate_key(match['alt'], translations, language)
412
+ else
413
+ logo['src'] = normalize_baseurl(baseurl) + 'assets/img/SDG_logo.png'
414
+ alt_text = opensdg_translate_key('general.sdg', translations, language)
415
+ alt_text += ' - '
416
+ alt_text += opensdg_translate_key('header.tag_line', translations, language)
417
+ logo['alt'] = alt_text
387
418
  end
419
+ doc.data['logo'] = logo
388
420
 
389
421
  if collection == 'indicators'
390
422
  # For indicators we also set the current indicator/target/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
- date = Time.at(date)
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.
@@ -1,3 +1,3 @@
1
1
  module JekyllOpenSdgPlugins
2
- VERSION = "1.3.0-beta1".freeze
2
+ VERSION = "1.4.0".freeze
3
3
  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.3.0.pre.beta1
4
+ version: 1.4.0
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-03-01 00:00:00.000000000 Z
11
+ date: 2021-07-15 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: 1.3.1
106
+ version: '0'
106
107
  requirements: []
107
108
  rubygems_version: 3.1.4
108
109
  signing_key: