jekyll-open-sdg-plugins 1.3.1 → 1.4.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: 2b8207e00fee9b06651b035048a46ebf9c3feaa83c34a389411b11d9b1f5c859
4
- data.tar.gz: 6f36f1ce30f97de9228082af5aede9750b0155caace3c92dd44bd11f89107f1b
3
+ metadata.gz: 6ba22fd994d04edb16b31b864db8b6538e2a996cfbf98c16f0eaee128fa8117c
4
+ data.tar.gz: 70d64a4098ecc895aac3f8690617bf34c019b743cff279734cf81b71c015d5de
5
5
  SHA512:
6
- metadata.gz: 5857e831f608586fa54ddde293d6a127c6907361c2f758837c8cba7f78802fca1da1df9d7a5ab8ba69774cb8f242b0297a905db8bea8f4ca7a479c909492575a
7
- data.tar.gz: f5b4950adf873e5a1db34452430fc87b23ae5cf189748e17ea6a3e03a236a3292a6b7029b4a80267281017a7030e5e81085d2658d302bb07286c59af9e721b7f
6
+ metadata.gz: f9440c732b7ecb4ea1cbe223abd96288ffbbc647c4e4ab102009a3887643dfa6f0270c6171cbb7636e816385865ceebee7f840dfb09e454c0d38968779b9d720
7
+ data.tar.gz: 920503070bad04e792f6ec01815236a50edc5a5556f611da5640d867416eb0dd5bbcb52dfde684db521af5156f59490ce84ff64b234c2d6b0103b5b9ef038858
@@ -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
@@ -443,6 +443,17 @@
443
443
  }
444
444
  ]
445
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
+ },
446
457
  "indicator_name": {
447
458
  "type": "string",
448
459
  "title": "Indicator name",
@@ -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",
@@ -615,6 +605,7 @@
615
605
  "type": "string",
616
606
  "format": "color",
617
607
  "title": "Graph color for headline",
608
+ "default": "#004466",
618
609
  "description": "This setting can be used to customize the color used in the chart 'headlines'.",
619
610
  "examples": [],
620
611
  "links": [
@@ -628,6 +619,7 @@
628
619
  "type": "string",
629
620
  "format": "color",
630
621
  "title": "Graph color for headline - high-contrast",
622
+ "default": "#55a6e5",
631
623
  "description": "This setting can be used to customize the color used in the chart 'headlines' in high-contrast mode.",
632
624
  "examples": [],
633
625
  "links": [
@@ -679,6 +671,18 @@
679
671
  }
680
672
  ]
681
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
+ },
682
686
  "header": {
683
687
  "options": {"collapsed": true},
684
688
  "type": "object",
@@ -739,6 +743,69 @@
739
743
  "description": "Configuration of the indicator configuration form.",
740
744
  "$ref": "#/definitions/config_form_options"
741
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
+ },
742
809
  "languages": {
743
810
  "options": {"collapsed": true},
744
811
  "type": "array",
@@ -787,6 +854,41 @@
787
854
  }
788
855
  ]
789
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
+ },
790
892
  "map_layers": {
791
893
  "options": {"collapsed": true},
792
894
  "type": "array",
@@ -1053,8 +1155,8 @@
1053
1155
  "remote_data_prefix": {
1054
1156
  "type": "string",
1055
1157
  "minLength": 1,
1056
- "title": "Remote data repository URL",
1057
- "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.",
1058
1160
  "links": [
1059
1161
  {
1060
1162
  "rel": "More information on the remote data prefix setting",
@@ -1087,6 +1189,28 @@
1087
1189
  }
1088
1190
  ]
1089
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
+ },
1090
1214
  "search_index_boost": {
1091
1215
  "options": {"collapsed": true},
1092
1216
  "type": "array",
@@ -1273,6 +1397,12 @@
1273
1397
  "config_form_options": {
1274
1398
  "type": "object",
1275
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
+ },
1276
1406
  "dropdowns": {
1277
1407
  "type": "array",
1278
1408
  "title": "Dropdown lists",
@@ -1306,6 +1436,16 @@
1306
1436
  }
1307
1437
  }
1308
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."
1309
1449
  }
1310
1450
  }
1311
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.1".freeze
2
+ VERSION = "1.4.0-beta1".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.1
4
+ version: 1.4.0.pre.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brock Fanning
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-18 00:00:00.000000000 Z
11
+ date: 2021-06-11 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: '0'
106
+ version: 1.3.1
106
107
  requirements: []
107
108
  rubygems_version: 3.1.4
108
109
  signing_key: