jekyll-open-sdg-plugins 1.8.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a8c796bf7b90b41f1d9258be2f52a3cb3fb80604ca580ef592cf5bf7a7acf59
4
- data.tar.gz: 961d18d17a15e41591547046e76fcf48e6c12ea226dfcee8c9378be019ccdb00
3
+ metadata.gz: 223b4a55da18c4e20ce1e07823c71ea9e12a935598dcbefe39eb37c4246f2757
4
+ data.tar.gz: 377bc37c6b248fd74f7762bfea0d26ca54ec023d5359da05ade3ce4385fdb204
5
5
  SHA512:
6
- metadata.gz: e78a4af21623402d3a363f4af61e1c6e3ca9d1e0731f2758b0163be9c9e35df9cea52b9fc3fb2a3830d676ef27b0eb042db60fbb4b680a1717248007f55bee55
7
- data.tar.gz: 3f31ee6e9d6ef944fa62b9f1ea1b5e7aea1a9179ab988d60277872c0d0ddd4fc6133c2405e1779ccd3a928d9ed96ec3bcef038e65701549f58fc5436b1015033
6
+ metadata.gz: 79d8089c8c040c0bd4fdff209e95ffd54adffa8b929dc1f4804a0c0c1a5b471728f73104d784ce50ed94af12f861764706823d01386ed4aa561a4b462dfa719a
7
+ data.tar.gz: 33fe8ac6009c5807c5036fdc539ec60300548560e4f8d09dd05560cb06e11ea038ea183c18f8e15ff3ed63ed9960999fb2cd4cbeac6ecdc002c0bc5b2bd1c061
@@ -25,6 +25,11 @@ module JekyllOpenSdgPlugins
25
25
  # as the Open SDG API changes over time.
26
26
  def generate(site)
27
27
 
28
+ # Abort if some configurations from 1.x are still being used.
29
+ if (site.config.has_key?('metadata_tabs') && site.config['metadata_tabs'].is_a?(Hash))
30
+ opensdg_error('The metadata_tabs setting is not in the correct format. Please consult the latest documentation: https://open-sdg.readthedocs.io/en/latest/configuration/#metadata_tabs')
31
+ end
32
+
28
33
  # Handle legacy treatment of reporting status types.
29
34
  unless (site.config.has_key?('reporting_status') &&
30
35
  site.config['reporting_status'].has_key?('status_types') &&
@@ -59,39 +64,6 @@ module JekyllOpenSdgPlugins
59
64
  add_translation_keys(goal['statuses'], site)
60
65
  end
61
66
  end
62
-
63
- # Print warnings for settings that are deprecated
64
- # and will be removed in version 2.0.0.
65
- if !site.config.has_key?('accessible_charts') || !site.config['accessible_charts']
66
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the accessible_charts setting will be automatically set to true.')
67
- end
68
- if !site.config.has_key?('accessible_tabs') || !site.config['accessible_tabs']
69
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the accessible_tabs setting will be automatically set to true.')
70
- end
71
- if !site.config.has_key?('contrast_type') || site.config['contrast_type'] != 'single'
72
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the contrast_type setting will be automatically set to "single".')
73
- end
74
- if site.config.has_key?('create_goals') && site.config['create_goals']['layout'] != 'goal-with-progress'
75
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the create_goals.layout setting will be removed, because there will only be a single option for goal layouts. To see a preview, set "bootstrap_5" to "true".')
76
- end
77
- if !site.config.has_key?('favicons') || site.config['favicons'] != 'favicon.io'
78
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the favicons setting will be automatically set to "favicon.io".')
79
- end
80
- if site.config.has_key?('frontpage_heading') && site.config['frontpage_heading'] != ''
81
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the "frontpage_heading" setting will no longer be used.')
82
- end
83
- if site.config.has_key?('frontpage_instructions') && site.config['frontpage_instructions'] != ''
84
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the "frontpage_instructions" setting will no longer be used.')
85
- end
86
- if site.config.has_key?('header') && site.config['header']['include'] != 'header-menu-left-aligned.html'
87
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the "header.include" setting will no longer be used because there will only be a single option for headers. To see what this will look like, set "bootstrap_5" to "true".')
88
- end
89
- if site.config.has_key?('non_global_metadata') && site.config['non_global_metadata'] != ''
90
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the "non_global_metadata" setting will be removed. Please use the "metadata_tabs" setting to control the labels of the metadata tabs.')
91
- end
92
- if !site.config.has_key?('series_toggle') || !site.config['series_toggle']
93
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the "series_toggle" will be automatically set to "true". In order to keep the "false" behavior, please rename your "Series" column to something else.')
94
- end
95
67
  end
96
68
  end
97
69
  end
@@ -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,11 +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
- if site.config['bootstrap_5']
82
- self.data['layout'] = 'goal-bootstrap5'
83
- end
84
- # Backwards compatibility:
85
- self.data['sdg_goal'] = self.data['goal_number']
86
73
  end
87
74
  end
88
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
@@ -158,12 +144,7 @@ module JekyllOpenSdgPlugins
158
144
  self.data = {}
159
145
  self.data['indicator_number'] = inid.gsub('-', '.')
160
146
  self.data['layout'] = layout
161
- if site.config['bootstrap_5']
162
- self.data['layout'] = 'indicator-bootstrap5'
163
- end
164
147
  self.data['language'] = language
165
- # Backwards compatibility:
166
- self.data['indicator'] = self.data['indicator_number']
167
148
  end
168
149
  end
169
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,21 +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)
61
- pages = site.config['create_pages']
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')
62
50
  end
63
-
64
- pages.each do |page|
65
- if page['layout'] == 'frontpage'
66
- opensdg_notice('DEPRECATION NOTICE: In Open SDG 2.0.0, the "frontpage" layout will change. To see a preview, set "bootstrap_5" to "true".')
67
- end
51
+ if site.config['create_pages'].is_a?(Array)
52
+ pages = site.config['create_pages']
68
53
  end
69
54
 
70
55
  # Clone pages so that we don't edit the original.
71
56
  pages = pages.clone
72
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
+
73
75
  # Hardcode the site configuration page if it's not already there.
74
76
  form_settings = site.config['site_config_form']
75
77
  config_page = pages.find { |page| page['layout'] == 'config-builder' }
@@ -136,15 +138,6 @@ module JekyllOpenSdgPlugins
136
138
  self.data[key] = value
137
139
  end
138
140
  end
139
-
140
- if site.config['bootstrap_5']
141
- if page.has_key?('layout') && page['layout'] == 'reportingstatus'
142
- self.data['layout'] = 'reportingstatus-bootstrap5'
143
- end
144
- if page.has_key?('layout') && page['layout'] == 'frontpage'
145
- self.data['layout'] = 'frontpage-alt'
146
- end
147
- end
148
141
  end
149
142
  end
150
143
  end
@@ -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",
@@ -56,18 +32,6 @@
56
32
  }
57
33
  ]
58
34
  },
59
- "bootstrap_5": {
60
- "title": "Bootstrap 5",
61
- "type": "boolean",
62
- "description": "This setting can be set to `true` to enable Bootstrap 5. Importantly, this will automatically be set to 'true' in Open SDG 2.0.0.",
63
- "format": "checkbox",
64
- "links": [
65
- {
66
- "rel": "More information on the bootstrap_5 setting",
67
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#bootstrap_5"
68
- }
69
- ]
70
- },
71
35
  "breadcrumbs": {
72
36
  "options": {"collapsed": true},
73
37
  "type": "object",
@@ -109,37 +73,6 @@
109
73
  }
110
74
  ]
111
75
  },
112
- "chartjs_3": {
113
- "title": "Chart.js 3",
114
- "type": "boolean",
115
- "description": "This setting can be set to `true` to enable Chart.js 3. Importantly, this will automatically be set to 'true' in Open SDG 2.0.0.",
116
- "format": "checkbox",
117
- "links": [
118
- {
119
- "rel": "More information on the chartjs_3 setting",
120
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#chartjs_3"
121
- }
122
- ]
123
- },
124
- "contrast_type": {
125
- "type": "string",
126
- "title": "Contrast type",
127
- "description": "The type of high-contrast toggle to use.",
128
- "enum": ["default", "single", "long"],
129
- "options": {
130
- "enum_titles": [
131
- "Default - two 'A' buttons side-by-side",
132
- "Single - one 'A' button which toggles on/off",
133
- "Long - text toggling between 'High contrast' and 'Default contrast'"
134
- ]
135
- },
136
- "links": [
137
- {
138
- "rel": "More information on the contrast type setting",
139
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#contrast_type"
140
- }
141
- ]
142
- },
143
76
  "cookie_consent_form": {
144
77
  "options": {"collapsed": true},
145
78
  "type": "object",
@@ -192,27 +125,6 @@
192
125
  "title": "Create goals",
193
126
  "description": "This setting can be used to automatically create the goal pages.",
194
127
  "properties": {
195
- "layout": {
196
- "type": "string",
197
- "title": "Layout",
198
- "enum": [
199
- "",
200
- "goal",
201
- "goal-by-target",
202
- "goal-by-target-vertical",
203
- "goal-with-progress"
204
- ],
205
- "options": {
206
- "enum_titles": [
207
- "Do not automatically create goals",
208
- "goal",
209
- "goal-by-target",
210
- "goal-by-target-vertical",
211
- "goal-with-progress"
212
- ]
213
- },
214
- "description": "The layout to use for the goal pages."
215
- },
216
128
  "previous_next_links": {
217
129
  "title": "Previous/next links",
218
130
  "type": "boolean",
@@ -251,21 +163,6 @@
251
163
  "title": "Create indicators",
252
164
  "description": "This setting can be used to automatically create the indicator pages.",
253
165
  "properties": {
254
- "layout": {
255
- "type": "string",
256
- "title": "Layout",
257
- "enum": [
258
- "",
259
- "indicator"
260
- ],
261
- "options": {
262
- "enum_titles": [
263
- "Do not automatically create indicators",
264
- "indicator"
265
- ]
266
- },
267
- "description": "The layout to use for the indicator pages."
268
- },
269
166
  "previous_next_links": {
270
167
  "title": "Previous/next links",
271
168
  "type": "boolean",
@@ -501,24 +398,6 @@
501
398
  }
502
399
  ]
503
400
  },
504
- "favicons": {
505
- "type": "string",
506
- "title": "Favicons",
507
- "description": "The type of favicons to use.",
508
- "enum": ["legacy", "favicon.io"],
509
- "options": {
510
- "enum_titles": [
511
- "Legacy",
512
- "Favicon.io (recommended)"
513
- ]
514
- },
515
- "links": [
516
- {
517
- "rel": "More information on the favicons setting",
518
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#favicons"
519
- }
520
- ]
521
- },
522
401
  "footer_language_toggle": {
523
402
  "type": "string",
524
403
  "title": "Footer language toggle",
@@ -609,28 +488,6 @@
609
488
  }
610
489
  ]
611
490
  },
612
- "frontpage_heading": {
613
- "type": "string",
614
- "title": "Frontpage heading",
615
- "description": "This setting can control the heading that appears on the front page. This setting is only used in the frontpage layout.",
616
- "links": [
617
- {
618
- "rel": "More information on the frontpage heading setting",
619
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#frontpage_heading"
620
- }
621
- ]
622
- },
623
- "frontpage_instructions": {
624
- "type": "string",
625
- "title": "Frontpage instructions",
626
- "description": "This setting can control the instructions that appear on the front page. This setting is only used in the frontpage layout.",
627
- "links": [
628
- {
629
- "rel": "More information on the frontpage instructions setting",
630
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#frontpage_instructions"
631
- }
632
- ]
633
- },
634
491
  "frontpage_introduction_banner": {
635
492
  "options": {"collapsed": true},
636
493
  "type": "object",
@@ -713,7 +570,7 @@
713
570
  "title": "Graph color set",
714
571
  "description": "This setting can be used to customize the color set used in the charts.",
715
572
  "examples": [],
716
- "enum": ["default", "accessible", "sdg", "goal", "custom"],
573
+ "enum": ["accessible", "classic", "sdg", "goal", "custom"],
717
574
  "links": [
718
575
  {
719
576
  "rel": "More information on the graph color set setting",
@@ -762,35 +619,6 @@
762
619
  }
763
620
  ]
764
621
  },
765
- "header": {
766
- "options": {"collapsed": true},
767
- "type": "object",
768
- "title": "Header",
769
- "description": "This setting can be used to customise the header.",
770
- "properties": {
771
- "include": {
772
- "type": "string",
773
- "title": "Include file",
774
- "enum": [
775
- "header-default.html",
776
- "header-menu-left-aligned.html"
777
- ],
778
- "options": {
779
- "enum_titles": [
780
- "Default header",
781
- "Menu left-aligned"
782
- ]
783
- },
784
- "description": "The header style to use on all pages."
785
- }
786
- },
787
- "links": [
788
- {
789
- "rel": "More information on the header setting",
790
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#header"
791
- }
792
- ]
793
- },
794
622
  "header_language_toggle": {
795
623
  "type": "string",
796
624
  "title": "Header language toggle",
@@ -1074,6 +902,12 @@
1074
902
  "title": "Map options",
1075
903
  "description": "Site-wide configuration of map behavior and style.",
1076
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
+ },
1077
911
  "minZoom": {
1078
912
  "title": "Minimum zoom",
1079
913
  "type": "integer",
@@ -1275,17 +1109,6 @@
1275
1109
  }
1276
1110
  ]
1277
1111
  },
1278
- "non_global_metadata": {
1279
- "type": "string",
1280
- "title": "Non-global metadata",
1281
- "description": "This setting can be used to control the text of the tab containing non-global metadata.",
1282
- "links": [
1283
- {
1284
- "rel": "More information on the non-global metadata setting",
1285
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#non_global_metadata"
1286
- }
1287
- ]
1288
- },
1289
1112
  "progress_status": {
1290
1113
  "options": {"collapsed": true},
1291
1114
  "type": "object",
@@ -1473,18 +1296,6 @@
1473
1296
  }
1474
1297
  ]
1475
1298
  },
1476
- "series_toggle": {
1477
- "title": "Series toggle",
1478
- "type": "boolean",
1479
- "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.",
1480
- "format": "checkbox",
1481
- "links": [
1482
- {
1483
- "rel": "More information on the series toggle setting",
1484
- "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#series_toggle"
1485
- }
1486
- ]
1487
- },
1488
1299
  "site_config_form": {
1489
1300
  "options": {"collapsed": true},
1490
1301
  "type": "object",
@@ -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'] = [
@@ -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.8.0".freeze
2
+ VERSION = "2.0.0".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.8.0
4
+ version: 2.0.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: 2022-03-31 00:00:00.000000000 Z
11
+ date: 2022-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll