jekyll-open-sdg-plugins 1.7.0 → 2.0.0.pre.beta1

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: 3a89cf02d816079a37d7a46f926a77b8e084ea6521b9a8dbe2a6616b8fbddb0f
4
- data.tar.gz: 62d0c38503090c81c54e7d15bc32dbf50f87b9257f659829bf98b2c6a4658e67
3
+ metadata.gz: f6de9152fa38e922c20c0a0ad30146daf4fa4366dcd3d7adfdf40f2c2db47485
4
+ data.tar.gz: 3b667053f64fac03603e2510fc7d64129d4693975aa88673d2b98e191df305d7
5
5
  SHA512:
6
- metadata.gz: a289cf63df4aae969859ef27dfcb357a56286c1fcbb81598332ff9ad20eea765f62b87e7e03eb60682852b8fca3055a8dc18956a45112843c4bd1dc1a12ef323
7
- data.tar.gz: 32c575404cddbc955955ce28845853424580f639c8d8cfa003e83f43e9d6a42d048219273e6f367234391f5e23e14a75d575d9e21bf4e7f941a34ea87f9573f8
6
+ metadata.gz: 47e4c01c0e3a26dadc816e509eb4fe7256357f627a2ad37a5cc4cfe0825bc59a017b157a798654aa2e3a810c213c2f376a731fa3e089e4e7cf01c222d133270b
7
+ data.tar.gz: 321ff77fc2b09632bb75e41f2a13cca2ac6fbe4b85e487539ebeb13e7181e3c199b95f00d30d9203b21148cb13b5b0ccd1e3a3191ff4450172fe226e36e05d0c
@@ -8,20 +8,12 @@ module JekyllOpenSdgPlugins
8
8
 
9
9
  def generate(site)
10
10
  # If site.create_goals is set, create goals per the metadata.
11
- if site.config['languages'] and site.config['create_goals'] and site.config['create_goals'].key?('layout') and site.config['create_goals']['layout'] != ''
11
+ if site.config['languages'] and site.config['create_goals']
12
12
  # Compile the list of goals.
13
13
  goals = {}
14
- # Are we using translated builds?
15
14
  metadata = {}
16
- if opensdg_translated_builds(site)
17
- # If we are using translated builds, the 'meta' data is underneath
18
- # language codes. We just use the first language.
19
- default_language = site.config['languages'][0]
20
- metadata = site.data[default_language]['meta']
21
- else
22
- # Otherwise the 'meta' data is not underneath any language code.
23
- metadata = site.data['meta']
24
- end
15
+ default_language = site.config['languages'][0]
16
+ metadata = site.data[default_language]['meta']
25
17
  metadata.each do |inid, indicator|
26
18
  if indicator.has_key?('standalone') and indicator['standalone']
27
19
  next
@@ -30,7 +22,7 @@ module JekyllOpenSdgPlugins
30
22
  goals[goal] = true
31
23
  end
32
24
  # Decide what layout to use for the goal pages.
33
- layout = site.config['create_goals']['layout']
25
+ layout = 'goal'
34
26
  # See if we need to "map" any language codes.
35
27
  languages_public = Hash.new
36
28
  if site.config['languages_public']
@@ -78,8 +70,6 @@ module JekyllOpenSdgPlugins
78
70
  self.data['goal_number'] = goal.to_s
79
71
  self.data['language'] = language
80
72
  self.data['layout'] = layout
81
- # Backwards compatibility:
82
- self.data['sdg_goal'] = self.data['goal_number']
83
73
  end
84
74
  end
85
75
  end
@@ -16,9 +16,9 @@ module JekyllOpenSdgPlugins
16
16
 
17
17
  translations = site.data['translations']
18
18
  # If site.create_indicators is set, create indicators per the metadata.
19
- if (language_config and indicator_config and indicator_config.key?('layout') and indicator_config['layout'] != '')
19
+ if (language_config and indicator_config)
20
20
  # Decide what layout to use for the indicator pages.
21
- layout = indicator_config['layout']
21
+ layout = 'indicator'
22
22
  # See if we need to "map" any language codes.
23
23
  languages_public = Hash.new
24
24
  if site.config['languages_public']
@@ -32,14 +32,7 @@ module JekyllOpenSdgPlugins
32
32
  language_public = languages_public[language]
33
33
  end
34
34
  metadata = {}
35
- if opensdg_translated_builds(site)
36
- # If we are using translated builds, the metadata is underneath a
37
- # language code.
38
- metadata = site.data[language]['meta']
39
- else
40
- # Otherwise the 'meta' data is not underneath any language code.
41
- metadata = site.data['meta']
42
- end
35
+ metadata = site.data[language]['meta']
43
36
  # Loop through the indicators (using metadata as a list).
44
37
  metadata.each do |inid, meta|
45
38
  permalink = inid
@@ -61,24 +54,17 @@ module JekyllOpenSdgPlugins
61
54
  if do_indicator_config_forms || do_indicator_meta_forms || do_indicator_data_forms
62
55
 
63
56
  metadata = {}
64
- if opensdg_translated_builds(site)
65
- if site.data.has_key?('untranslated')
66
- metadata = site.data['untranslated']['meta']
67
- else
68
- default_language = language_config[0]
69
- metadata = site.data[default_language]['meta']
70
- end
57
+
58
+ if site.data.has_key?('untranslated')
59
+ metadata = site.data['untranslated']['meta']
71
60
  else
72
- metadata = site.data['meta']
61
+ default_language = language_config[0]
62
+ metadata = site.data[default_language]['meta']
73
63
  end
74
64
 
75
65
  metadata_by_language = {}
76
66
  language_config.each do |language|
77
- if opensdg_translated_builds(site)
78
- metadata_by_language[language] = site.data[language]['meta']
79
- else
80
- metadata_by_language[language] = site.data['meta']
81
- end
67
+ metadata_by_language[language] = site.data[language]['meta']
82
68
  end
83
69
 
84
70
  # Because we have config forms for indicator config or meta/data, we
@@ -159,8 +145,6 @@ module JekyllOpenSdgPlugins
159
145
  self.data['indicator_number'] = inid.gsub('-', '.')
160
146
  self.data['layout'] = layout
161
147
  self.data['language'] = language
162
- # Backwards compatibility:
163
- self.data['indicator'] = self.data['indicator_number']
164
148
  end
165
149
  end
166
150
 
@@ -33,20 +33,11 @@ module JekyllOpenSdgPlugins
33
33
  if (site.config['languages'] and site.config['create_pages'])
34
34
 
35
35
  default_pages = [
36
- {
37
- 'folder' => '/',
38
- 'layout' => 'frontpage'
39
- },
40
36
  {
41
37
  'folder' => '/reporting-status',
42
38
  'layout' => 'reportingstatus',
43
39
  'title' => 'status.reporting_status',
44
40
  },
45
- {
46
- 'filename' => 'indicators.json',
47
- 'folder' => '/',
48
- 'layout' => 'indicator-json',
49
- },
50
41
  {
51
42
  'folder' => '/search',
52
43
  'layout' => 'search',
@@ -55,15 +46,32 @@ module JekyllOpenSdgPlugins
55
46
  ]
56
47
  pages = default_pages
57
48
  if (site.config['create_pages'].is_a?(Hash) and site.config['create_pages'].key?('pages'))
58
- # Backwards compatability to support the deprecated "pages" key.
59
- pages = site.config['create_pages']['pages']
60
- elsif site.config['create_pages'].is_a?(Array)
49
+ opensdg_error('The create_pages setting is not in the correct format. Please consult the latest documentation: https://open-sdg.readthedocs.io/en/latest/configuration/#create_pages')
50
+ end
51
+ if site.config['create_pages'].is_a?(Array)
61
52
  pages = site.config['create_pages']
62
53
  end
63
54
 
64
55
  # Clone pages so that we don't edit the original.
65
56
  pages = pages.clone
66
57
 
58
+ # Automate the frontpage and indicators.json if not already there.
59
+ frontpage = pages.find { |page| page['folder'] == '/' && page['filename'] == nil }
60
+ if frontpage == nil || frontpage['layout'] == 'frontpage-alt'
61
+ pages.push({
62
+ 'folder' => '/',
63
+ 'layout' => 'frontpage',
64
+ })
65
+ end
66
+ indicatorjson = pages.find { |page| page['layout'] == 'indicator-json' }
67
+ if indicatorjson == nil
68
+ pages.push({
69
+ 'folder' => '/',
70
+ 'layout' => 'indicator-json',
71
+ 'filename' => 'indicators.json'
72
+ })
73
+ end
74
+
67
75
  # Hardcode the site configuration page if it's not already there.
68
76
  form_settings = site.config['site_config_form']
69
77
  config_page = pages.find { |page| page['layout'] == 'config-builder' }
@@ -59,27 +59,6 @@ module JekyllOpenSdgPlugins
59
59
  return build
60
60
  end
61
61
 
62
- # Predict (before data has been fetched) whether the site is using
63
- # translated builds or not.
64
- def site_uses_translated_builds(path)
65
-
66
- is_remote = opensdg_is_path_remote(path)
67
- endpoints = get_endpoints()
68
- # For a quick test, we just use 'meta'.
69
- meta = endpoints['meta']
70
- endpoint = is_remote ? path + '/' + meta : File.join(path, fix_path(meta))
71
-
72
- begin
73
- json_file = is_remote ? open(endpoint) : File.open(endpoint)
74
- rescue StandardError => e
75
- # If we didn't find an untranslated 'meta', we assume translated builds.
76
- return true
77
- end
78
-
79
- # Other wise assume untranslated builds.
80
- return false
81
- end
82
-
83
62
  def generate(site)
84
63
 
85
64
  # For below, make sure there is at least an empty hash at
@@ -99,85 +78,47 @@ module JekyllOpenSdgPlugins
99
78
  is_remote = opensdg_is_path_remote(build_location)
100
79
 
101
80
  build_location = is_remote ? build_location : File.join(Dir.pwd, build_location)
102
- translated_builds = site_uses_translated_builds(build_location)
103
81
 
104
- if translated_builds
105
- # For translated builds, we get a build for each language, and
106
- # place them in "subfolders" (so to speak) of site.data.
107
- subfolders = site.config['languages'].clone
108
- subfolders.append('untranslated')
109
- subfolders.each do |language|
110
- data_target = site.data[language]
111
- translated_build = is_remote ? build_location + '/' + language : File.join(build_location, language)
112
- data_source = fetch_build(translated_build)
113
- if !data_source.empty?
114
- if data_target
115
- data_target.deep_merge(data_source)
116
- else
117
- site.data[language] = data_source
118
- end
119
- end
120
- end
121
- # We move the language-specific translations to the
122
- # site.data.translations location, where all translations are kept.
123
- site.config['languages'].each do |language|
124
- translation_target = site.data['translations'][language]
125
- translation_source = site.data[language]['translations']
126
- if translation_target
127
- translation_target.deep_merge(translation_source)
82
+ # We get a build for each language, and place them in "subfolders"
83
+ # (so to speak) of site.data.
84
+ subfolders = site.config['languages'].clone
85
+ subfolders.append('untranslated')
86
+ subfolders.each do |language|
87
+ data_target = site.data[language]
88
+ translated_build = is_remote ? build_location + '/' + language : File.join(build_location, language)
89
+ data_source = fetch_build(translated_build)
90
+ if !data_source.empty?
91
+ if data_target
92
+ data_target.deep_merge(data_source)
128
93
  else
129
- site.data['translations'][language] = translation_source
94
+ site.data[language] = data_source
130
95
  end
131
96
  end
132
- # And there are some parts of the build that don't need to be translated
133
- # and should be moved to the top level.
134
- first_language = site.config['languages'][0]
135
- site.data['reporting'] = site.data[first_language]['reporting']
136
- site.data['schema'] = site.data[first_language]['schema']
137
- site.data['zip'] = site.data[first_language]['zip']
138
- else
139
- # For untranslated builds, we download one build only, and place it
140
- # in the "root" (so to speak) of site.data. Nothing else is needed.
141
- target = site.data
142
- source = fetch_build(build_location)
143
- if !source.empty?
144
- target.deep_merge(source)
145
- end
146
97
  end
147
-
148
- # Finally support the deprecated 'remote_translations' option.
149
- # This is deprecated because translations should now be in the
150
- # data repository, where they will be fetched in fetch_build().
151
- if site.config['remote_translations']
152
- key = 'translations'
153
- target = site.data[key]
154
- site.config['remote_translations'].each do |endpoint|
155
- begin
156
- source = JSON.load(open(endpoint))
157
- if target
158
- target.deep_merge(source)
159
- else
160
- site.data[key] = source
161
- end
162
- rescue StandardError => e
163
- puts e.message
164
- abort 'Unable to fetch remote translation from: ' + endpoint
165
- end
98
+ # We move the language-specific translations to the
99
+ # site.data.translations location, where all translations are kept.
100
+ site.config['languages'].each do |language|
101
+ translation_target = site.data['translations'][language]
102
+ translation_source = site.data[language]['translations']
103
+ if translation_target
104
+ translation_target.deep_merge(translation_source)
105
+ else
106
+ site.data['translations'][language] = translation_source
166
107
  end
167
108
  end
109
+ # And there are some parts of the build that don't need to be translated
110
+ # and should be moved to the top level.
111
+ first_language = site.config['languages'][0]
112
+ site.data['reporting'] = site.data[first_language]['reporting']
113
+ site.data['schema'] = site.data[first_language]['schema']
114
+ site.data['zip'] = site.data[first_language]['zip']
168
115
  end
169
116
  end
170
117
 
171
- # This makes sure that the contents of the "local_data_folder" get copied
118
+ # This makes sure that the contents of any local data build get copied
172
119
  # into the Jekyll build, so that they can be served from the website.
173
120
  Jekyll::Hooks.register :site, :post_write do |site|
174
- if site.config['local_data_folder']
175
- source = File.join(Dir.pwd, site.config['local_data_folder'], '.')
176
- destination = site.config['destination']
177
- FileUtils.cp_r(source, destination)
178
- # Do the same in the case that "remote_data_prefix" is being used for a local
179
- # data folder (since "local_data_folder" is deprecated and undocumented).
180
- elsif site.config['remote_data_prefix']
121
+ if site.config['remote_data_prefix']
181
122
  if !opensdg_is_path_remote(site.config['remote_data_prefix'])
182
123
  source = File.join(Dir.pwd, site.config['remote_data_prefix'], '.')
183
124
  destination = site.config['destination']
@@ -2,6 +2,56 @@
2
2
 
3
3
  require "jekyll"
4
4
 
5
+ # Takes a string that might be a textual representation of a
6
+ # site configuration, such as "baseurl" or "country.name".
7
+ def opensdg_parse_site_config(key, site)
8
+
9
+ # Safety code - abort now if key is nil.
10
+ if key.nil?
11
+ return ""
12
+ end
13
+
14
+ # Also make sure it is a string, and other just return it.
15
+ if not key.is_a? String
16
+ return key
17
+ end
18
+
19
+ # More safety code - abort now if key is empty.
20
+ if key.empty?
21
+ return ""
22
+ end
23
+
24
+ # Keep track of the last thing we drilled to.
25
+ drilled = site.config
26
+
27
+ # Keep track of how many levels we have drilled.
28
+ levels_drilled = 0
29
+ levels = key.split('.')
30
+
31
+ # Loop through each level.
32
+ levels.each do |level|
33
+
34
+ # If we have drilled down to a scalar value too soon, abort.
35
+ break if drilled.class != Hash and drilled.class != Jekyll::Configuration
36
+
37
+ if drilled.has_key? level
38
+ # If we find something, continue drilling.
39
+ drilled = drilled[level]
40
+ levels_drilled += 1
41
+ end
42
+
43
+ end
44
+
45
+ # If we didn't drill the right number of levels, return the
46
+ # original string.
47
+ if levels.length != levels_drilled
48
+ return key
49
+ end
50
+
51
+ # Otherwise we must have drilled all they way.
52
+ return drilled
53
+ end
54
+
5
55
  # Takes a translation key and returns a translated string according to the
6
56
  # language of the current page. Or if none is found, returns the original
7
57
  # key.
@@ -49,29 +99,26 @@ def opensdg_translate_key(key, translations, language)
49
99
  return key
50
100
  end
51
101
 
102
+ # If the result is still not a string, return the original string.
103
+ if drilled.class != String
104
+ return key
105
+ end
106
+
52
107
  # Otherwise we must have drilled all they way.
53
108
  return drilled
54
109
  end
55
110
 
56
- # Takes a site object and decides whether it is using translated builds.
57
- def opensdg_translated_builds(site)
58
- # Assume the site is using translated builds.
59
- translated_builds = true
60
- site.config['languages'].each do |language|
61
- # If any languages don't have a key in site.data, the site is not using
62
- # translated builds.
63
- if !site.data.has_key? language
64
- translated_builds = false
65
- end
66
- end
67
- return translated_builds
68
- end
69
-
70
111
  # Print a notice during compilation.
71
112
  def opensdg_notice(message)
72
113
  Jekyll.logger.warn message.yellow
73
114
  end
74
115
 
116
+ # Print an error that should halt the build.
117
+ def opensdg_error(message)
118
+ Jekyll.logger.error message.red
119
+ exit 1
120
+ end
121
+
75
122
  # Get the public language codes for a site, keyed by the actual language codes.
76
123
  def opensdg_languages_public(site)
77
124
  languages_public = site.config['languages_public']
@@ -3,30 +3,6 @@
3
3
  "title": "Open SDG site configuration",
4
4
  "description": "This form will produce the site configuration for your Open SDG implementation.",
5
5
  "properties": {
6
- "accessible_charts": {
7
- "title": "Accessible charts",
8
- "type": "boolean",
9
- "description": "This setting can be set to `true` to enable chart functionality that is intended to increase accessibility by adding support for screenreaders and keyboard navigation.",
10
- "format": "checkbox",
11
- "links": [
12
- {
13
- "rel": "More information on the accessible charts setting",
14
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#accessible_charts"
15
- }
16
- ]
17
- },
18
- "accessible_tabs": {
19
- "title": "Accessible tabs",
20
- "type": "boolean",
21
- "description": "This setting can be set to `true` to enable tab functionality that is compliant with the WAI-ARIA best practices. This adds improved keyboard navigation of the tabs.",
22
- "format": "checkbox",
23
- "links": [
24
- {
25
- "rel": "More information on the accessible tabs setting",
26
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#accessible_tabs"
27
- }
28
- ]
29
- },
30
6
  "analytics": {
31
7
  "options": {"collapsed": true},
32
8
  "type": "object",
@@ -97,25 +73,6 @@
97
73
  }
98
74
  ]
99
75
  },
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
76
  "cookie_consent_form": {
120
77
  "options": {"collapsed": true},
121
78
  "type": "object",
@@ -168,27 +125,6 @@
168
125
  "title": "Create goals",
169
126
  "description": "This setting can be used to automatically create the goal pages.",
170
127
  "properties": {
171
- "layout": {
172
- "type": "string",
173
- "title": "Layout",
174
- "enum": [
175
- "",
176
- "goal",
177
- "goal-by-target",
178
- "goal-by-target-vertical",
179
- "goal-with-progress"
180
- ],
181
- "options": {
182
- "enum_titles": [
183
- "Do not automatically create goals",
184
- "goal",
185
- "goal-by-target",
186
- "goal-by-target-vertical",
187
- "goal-with-progress"
188
- ]
189
- },
190
- "description": "The layout to use for the goal pages."
191
- },
192
128
  "previous_next_links": {
193
129
  "title": "Previous/next links",
194
130
  "type": "boolean",
@@ -227,21 +163,6 @@
227
163
  "title": "Create indicators",
228
164
  "description": "This setting can be used to automatically create the indicator pages.",
229
165
  "properties": {
230
- "layout": {
231
- "type": "string",
232
- "title": "Layout",
233
- "enum": [
234
- "",
235
- "indicator"
236
- ],
237
- "options": {
238
- "enum_titles": [
239
- "Do not automatically create indicators",
240
- "indicator"
241
- ]
242
- },
243
- "description": "The layout to use for the indicator pages."
244
- },
245
166
  "previous_next_links": {
246
167
  "title": "Previous/next links",
247
168
  "type": "boolean",
@@ -414,6 +335,12 @@
414
335
  "type": "string",
415
336
  "title": "Message",
416
337
  "description": "A short disclaimer message."
338
+ },
339
+ "hidden": {
340
+ "type": "boolean",
341
+ "title": "Hidden",
342
+ "description": "Hide the disclaimer.",
343
+ "format": "checkbox"
417
344
  }
418
345
  },
419
346
  "links": [
@@ -471,24 +398,6 @@
471
398
  }
472
399
  ]
473
400
  },
474
- "favicons": {
475
- "type": "string",
476
- "title": "Favicons",
477
- "description": "The type of favicons to use.",
478
- "enum": ["legacy", "favicon.io"],
479
- "options": {
480
- "enum_titles": [
481
- "Legacy",
482
- "Favicon.io (recommended)"
483
- ]
484
- },
485
- "links": [
486
- {
487
- "rel": "More information on the favicons setting",
488
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#favicons"
489
- }
490
- ]
491
- },
492
401
  "footer_language_toggle": {
493
402
  "type": "string",
494
403
  "title": "Footer language toggle",
@@ -579,28 +488,6 @@
579
488
  }
580
489
  ]
581
490
  },
582
- "frontpage_heading": {
583
- "type": "string",
584
- "title": "Frontpage heading",
585
- "description": "This setting can control the heading that appears on the front page. This setting is only used in the frontpage layout.",
586
- "links": [
587
- {
588
- "rel": "More information on the frontpage heading setting",
589
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#frontpage_heading"
590
- }
591
- ]
592
- },
593
- "frontpage_instructions": {
594
- "type": "string",
595
- "title": "Frontpage instructions",
596
- "description": "This setting can control the instructions that appear on the front page. This setting is only used in the frontpage layout.",
597
- "links": [
598
- {
599
- "rel": "More information on the frontpage instructions setting",
600
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#frontpage_instructions"
601
- }
602
- ]
603
- },
604
491
  "frontpage_introduction_banner": {
605
492
  "options": {"collapsed": true},
606
493
  "type": "object",
@@ -732,35 +619,6 @@
732
619
  }
733
620
  ]
734
621
  },
735
- "header": {
736
- "options": {"collapsed": true},
737
- "type": "object",
738
- "title": "Header",
739
- "description": "This setting can be used to customise the header.",
740
- "properties": {
741
- "include": {
742
- "type": "string",
743
- "title": "Include file",
744
- "enum": [
745
- "header-default.html",
746
- "header-menu-left-aligned.html"
747
- ],
748
- "options": {
749
- "enum_titles": [
750
- "Default header",
751
- "Menu left-aligned"
752
- ]
753
- },
754
- "description": "The header style to use on all pages."
755
- }
756
- },
757
- "links": [
758
- {
759
- "rel": "More information on the header setting",
760
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#header"
761
- }
762
- ]
763
- },
764
622
  "header_language_toggle": {
765
623
  "type": "string",
766
624
  "title": "Header language toggle",
@@ -1044,6 +902,12 @@
1044
902
  "title": "Map options",
1045
903
  "description": "Site-wide configuration of map behavior and style.",
1046
904
  "properties": {
905
+ "disaggregation_controls": {
906
+ "title": "Disaggregation controls",
907
+ "type": "boolean",
908
+ "description": "Whether the map should provide a button and form for changing the displayed disaggregation.",
909
+ "format": "checkbox"
910
+ },
1047
911
  "minZoom": {
1048
912
  "title": "Minimum zoom",
1049
913
  "type": "integer",
@@ -1245,17 +1109,6 @@
1245
1109
  }
1246
1110
  ]
1247
1111
  },
1248
- "non_global_metadata": {
1249
- "type": "string",
1250
- "title": "Non-global metadata",
1251
- "description": "This setting can be used to control the text of the tab containing non-global metadata.",
1252
- "links": [
1253
- {
1254
- "rel": "More information on the non-global metadata setting",
1255
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#non_global_metadata"
1256
- }
1257
- ]
1258
- },
1259
1112
  "progress_status": {
1260
1113
  "options": {"collapsed": true},
1261
1114
  "type": "object",
@@ -1443,18 +1296,6 @@
1443
1296
  }
1444
1297
  ]
1445
1298
  },
1446
- "series_toggle": {
1447
- "title": "Series toggle",
1448
- "type": "boolean",
1449
- "description": "This setting enables the special treatment of the 'Series' column in the data. If set to true, when an indicator's data includes a 'Series' column, it will be displayed above 'Units' as radio buttons.",
1450
- "format": "checkbox",
1451
- "links": [
1452
- {
1453
- "rel": "More information on the series toggle setting",
1454
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#series_toggle"
1455
- }
1456
- ]
1457
- },
1458
1299
  "site_config_form": {
1459
1300
  "options": {"collapsed": true},
1460
1301
  "type": "object",
@@ -1462,6 +1303,36 @@
1462
1303
  "description": "Configuration of the site configuration form.",
1463
1304
  "$ref": "#/definitions/config_form_options"
1464
1305
  },
1306
+ "time_series_attributes": {
1307
+ "options": {"collapsed": true},
1308
+ "type": "array",
1309
+ "title": "Time-series attributes",
1310
+ "description": "This setting can be used to specify data columns to be considered 'time-series attributes' and displayed in the footer.",
1311
+ "items": {
1312
+ "type": "object",
1313
+ "title": "Time-series attribute",
1314
+ "properties": {
1315
+ "field": {
1316
+ "type": "string",
1317
+ "minLength": 1,
1318
+ "title": "Field",
1319
+ "description": "Column name in the data."
1320
+ },
1321
+ "label": {
1322
+ "type": "string",
1323
+ "minLength": 1,
1324
+ "title": "Label",
1325
+ "description": "Label when displayed in the footer."
1326
+ }
1327
+ }
1328
+ },
1329
+ "links": [
1330
+ {
1331
+ "rel": "More information on the time series attributes setting",
1332
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#time_series_attributes"
1333
+ }
1334
+ ]
1335
+ },
1465
1336
  "validate_indicator_config": {
1466
1337
  "title": "Validate indicator config",
1467
1338
  "type": "boolean",
@@ -294,7 +294,7 @@ module JekyllOpenSdgPlugins
294
294
  # country-specific metadata doesn't use any of these fields.
295
295
  protected_keys = ['goals', 'goal', 'targets', 'target', 'indicators',
296
296
  'indicator', 'language', 'name', 'number', 'sort', 'global', 'url',
297
- 'goal_number', 'target_number'
297
+ 'goal_number', 'target_number', 'indicator_number'
298
298
  ]
299
299
 
300
300
  # Figure out from our translations the global indicator numbers.
@@ -304,7 +304,7 @@ module JekyllOpenSdgPlugins
304
304
 
305
305
  # For available indicators, we simply map the "indicators" collection.
306
306
  available_inids = site.collections['indicators'].docs.select { |x| x.data['language'] == default_language }
307
- available_inids = available_inids.map { |x| x.data['indicator'] }
307
+ available_inids = available_inids.map { |x| x.data['indicator_number'] }
308
308
  available_indicators = {}
309
309
  available_targets = {}
310
310
  available_goals = {}
@@ -355,20 +355,7 @@ module JekyllOpenSdgPlugins
355
355
  # arbitrary (it's because they came from filenames) and could maybe
356
356
  # be changed eventually to dot-delimited for consistency.
357
357
  meta_key = indicator_number.gsub('.', '-')
358
- # The location of the metadata is different depending on whether we are
359
- # using "translated_builds" or not.
360
- if opensdg_translated_builds(site)
361
- meta = site.data[language]['meta'][meta_key]
362
- else
363
- meta = site.data['meta'][meta_key]
364
- # Also for untranslated builds, we need to support the "subfolder"
365
- # approach for metadata translation. (This is handled at build-time
366
- # for translated builds.)
367
- if meta.has_key? language
368
- meta = meta.merge(meta[language])
369
- meta.delete(language)
370
- end
371
- end
358
+ meta = site.data[language]['meta'][meta_key]
372
359
 
373
360
  is_standalone = (meta.has_key?('standalone') and meta['standalone'])
374
361
  is_placeholder = (meta.has_key?('placeholder') and meta['placeholder'] != '')
@@ -489,12 +476,8 @@ module JekyllOpenSdgPlugins
489
476
  else
490
477
  doc.data['remote_data_prefix'] = normalize_baseurl(baseurl)
491
478
  end
492
- if opensdg_translated_builds(site)
493
- doc.data['remote_data_prefix_untranslated'] = File.join(doc.data['remote_data_prefix'], 'untranslated')
494
- doc.data['remote_data_prefix'] = File.join(doc.data['remote_data_prefix'], language)
495
- else
496
- doc.data['remote_data_prefix_untranslated'] = doc.data['remote_data_prefix']
497
- end
479
+ doc.data['remote_data_prefix_untranslated'] = File.join(doc.data['remote_data_prefix'], 'untranslated')
480
+ doc.data['remote_data_prefix'] = File.join(doc.data['remote_data_prefix'], language)
498
481
 
499
482
  # Set the logo for this page.
500
483
  logo = {}
@@ -525,11 +508,8 @@ module JekyllOpenSdgPlugins
525
508
  # For indicators we also set the current indicator/target/goal.
526
509
  if doc.data.has_key? 'indicator_number'
527
510
  indicator_number = doc.data['indicator_number']
528
- elsif doc.data.has_key? 'indicator'
529
- # Backwards compatibility.
530
- indicator_number = doc.data['indicator']
531
511
  else
532
- raise "Error: An indicator does not have 'indicator_number' property."
512
+ opensdg_error("Error: An indicator does not have 'indicator_number' property.")
533
513
  end
534
514
  # Force the indicator number to be a string.
535
515
  if indicator_number.is_a? Numeric
@@ -551,11 +531,8 @@ module JekyllOpenSdgPlugins
551
531
  # For goals we also set the current goal.
552
532
  if doc.data.has_key? 'goal_number'
553
533
  goal_number = doc.data['goal_number']
554
- elsif doc.data.has_key? 'sdg_goal'
555
- # Backwards compatibility.
556
- goal_number = doc.data['sdg_goal']
557
534
  else
558
- raise "Error: A goal does not have 'goal_number' property."
535
+ opensdg_error("Error: A goal does not have 'goal_number' property.")
559
536
  end
560
537
  # Force the goal number to be a string.
561
538
  if goal_number.is_a? Numeric
@@ -41,6 +41,11 @@ module JekyllOpenSdgPlugins
41
41
  end
42
42
  end
43
43
 
44
+ # Abort early if some required settings are not there.
45
+ unless site.config.has_key?('languages') && site.config['languages'].length > 0
46
+ opensdg_error('The "languages" site configuration must have at least one language. See the documentation here: https://open-sdg.readthedocs.io/en/latest/configuration/#languages')
47
+ end
48
+
44
49
  # Hardcode some variables.
45
50
  site.config['disaggregation_status'] = {}
46
51
  site.config['disaggregation_status']['status_types'] = [
@@ -61,6 +66,20 @@ module JekyllOpenSdgPlugins
61
66
  'label' => 'status.disaggregation_status_notapplicable',
62
67
  },
63
68
  ]
69
+
70
+ # Provide some defaults.
71
+ if !site.config.has_key?('time_series_attributes') or site.config['time_series_attributes'].length == 0
72
+ site.config['time_series_attributes'] = [
73
+ {
74
+ 'field' => 'COMMENT_TS',
75
+ 'label' => 'indicator.footnote',
76
+ },
77
+ {
78
+ 'field' => 'DATA_LAST_UPDATE',
79
+ 'label' => 'metadata_fields.national_data_update_url'
80
+ },
81
+ ]
82
+ end
64
83
  end
65
84
 
66
85
  # Copy properties from a hash onto another hash.
@@ -26,25 +26,13 @@ module Jekyll
26
26
  # language: es
27
27
  # format: "%d de %b de %Y"
28
28
  #
29
- # However the following deprecated structure is also supported:
30
- #
31
- # date_formats:
32
- # standard:
33
- # en: "%b %d, %Y"
34
- # es: "%d de %b de %Y"
35
- # etc...
36
29
  date_format = '%b %d, %Y'
37
30
  if config.has_key?('date_formats')
38
-
39
- # @deprecated start
40
- # In a deprecated form of date_formats, it was a nested hash keyed first
41
- # by the format type and then by the language.
42
- if config['date_formats'].is_a?(Hash) && config['date_formats'].has_key?(format_type)
43
- if config['date_formats'][format_type].has_key?(language)
44
- date_format = config['date_formats'][format_type][language]
45
- end
31
+
32
+ # Abort if this setting is using an old format.
33
+ if config['date_formats'].is_a?(Hash)
34
+ opensdg_error('The "date_formats" site configuration must be in a list format. See the documentation here: https://open-sdg.readthedocs.io/en/latest/configuration/#date_formats')
46
35
  end
47
- # @deprecated end
48
36
 
49
37
  # In the current form of data_formats, it is an array of hashes, each
50
38
  # containing "type", "language", and "format" keys.
@@ -9,10 +9,36 @@ module Jekyll
9
9
  def t(key)
10
10
 
11
11
  # Determine the language of the current page.
12
- translations = @context.registers[:site].data['translations']
12
+ site = @context.registers[:site]
13
+ translations = site.data['translations']
13
14
  language = @context.environments.first["page"]['language']
15
+ translated = opensdg_translate_key(key, translations, language)
16
+ # Also look for references to site configuration within the translation,
17
+ # as "%" parameters.
18
+ translated = translated.gsub(/%([a-zA-Z0-9_.\-]+)/) do |match|
19
+ # Special case for trailing dots.
20
+ trailing_dot = match.end_with?('.')
21
+ key_candidate = match.delete_suffix('.').delete_prefix('%')
22
+ # Check to see if it is a site configuration.
23
+ translated_word = opensdg_parse_site_config(key_candidate, site)
24
+ # Check to see if the value of the site config may have been
25
+ # a translation key itself. But do a safety check to avoid
26
+ # infinite loops.
27
+ if translated_word != key
28
+ translated_word = opensdg_translate_key(translated_word, translations, language)
29
+ end
30
+ # Replace the word if something changed.
31
+ if key_candidate != translated_word
32
+ match = translated_word
33
+ # Making sure to add back any trailing dots.
34
+ if trailing_dot
35
+ match = match + '.'
36
+ end
37
+ end
38
+ match
39
+ end
14
40
 
15
- return opensdg_translate_key(key, translations, language)
41
+ return translated
16
42
  end
17
43
  end
18
44
  end
@@ -23,11 +23,7 @@ module JekyllOpenSdgPlugins
23
23
  language = site.config['languages'][0]
24
24
  end
25
25
  metadata = {}
26
- if opensdg_translated_builds(site)
27
- metadata = site.data[language]['meta']
28
- else
29
- metadata = site.data['meta']
30
- end
26
+ metadata = site.data[language]['meta']
31
27
  # Loop through the indicators (using metadata as a list).
32
28
  validation_failed = false
33
29
  metadata.each do |inid, meta|
@@ -1,3 +1,3 @@
1
1
  module JekyllOpenSdgPlugins
2
- VERSION = "1.7.0".freeze
2
+ VERSION = "2.0.0-beta1".freeze
3
3
  end
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.7.0
4
+ version: 2.0.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: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -102,9 +102,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  requirements:
105
- - - ">="
105
+ - - ">"
106
106
  - !ruby/object:Gem::Version
107
- version: '0'
107
+ version: 1.3.1
108
108
  requirements: []
109
109
  rubygems_version: 3.0.9
110
110
  signing_key: