jekyll-open-sdg-plugins 2.1.0 → 2.2.0.pre.beta1

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: 84b88b5f39066164b92412735bb030d01c6dfc7210c2c543187aa0d7f53e253a
4
- data.tar.gz: 7d663912c4f8b4426f47615b4bce831da3422104a880e33c51276fb244d6de02
3
+ metadata.gz: 82e500677f2b7d28cf2f0ad5bd9559d0dd4ab91c873b4b2619d54ab83383cb2c
4
+ data.tar.gz: 136c1ab6c3b3c53592dbf5e411a72578ac504e014f83a3d56965c7e24dd72d5f
5
5
  SHA512:
6
- metadata.gz: 203de7cb85bee411542589d9c712384a4e1df0e87e12a62ace92f48d7ae35adde6bb3582a789ff95cd450a2fe0236d6436737a9259cdb2b7b7761aac061951db
7
- data.tar.gz: '0989f9bd7f936ad4f627ee0b0d6736ab6a96af59fc8edbac5b66f6b0f256f3ecc806d4a8004c3f8e359d2ec451a9d46999fa56471ad9454d9f8a45b211f157fa'
6
+ metadata.gz: 55fa1efb7c666a0fa4aa52fafa36d51f635a0fcfddd7171546170fbbf41c05ddb688585cabd84993d095f0891ed0e4d6250f5bbd5ea1004948f753183be961b0
7
+ data.tar.gz: c490a887fe8a56151831476563639e84a40216fca4be75485a49ff734041beaedfde287844faffcc80b38c73abd2bedac555c655359b39a82bc70df9094a0e1c
@@ -10,8 +10,8 @@ jobs:
10
10
  steps:
11
11
  - uses: actions/checkout@v1
12
12
  - name: Set up Ruby 2.6
13
- uses: actions/setup-ruby@v1
13
+ uses: ruby/setup-ruby@v1
14
14
  with:
15
- ruby-version: 2.6.x
15
+ ruby-version: '2.6'
16
16
  - name: Run all tests
17
17
  run: make test
@@ -63,7 +63,12 @@ module JekyllOpenSdgPlugins
63
63
  @dir = dir
64
64
  @name = 'index.html'
65
65
 
66
+ goal_heading = ''
66
67
  goal_content = ''
68
+ goal_content_heading = ''
69
+ if site.config['create_goals'].has_key?('goal_content_heading')
70
+ goal_content_heading = site.config['create_goals']['goal_content_heading']
71
+ end
67
72
  if site.config['create_goals'].has_key?('goals')
68
73
  # Try to find goal content by match the goal ID with a "goal" property on each item
69
74
  # in the create_goals.goals site config. Otherwise fallback to the order they appear
@@ -72,9 +77,21 @@ module JekyllOpenSdgPlugins
72
77
  goal_by_index = site.config['create_goals']['goals'][goal_index]
73
78
  if !goal_by_goal.nil?
74
79
  goal_content = goal_by_goal['content']
80
+ if goal_by_goal.has_key?('content_heading') && goal_by_goal['content_heading'] != ''
81
+ goal_content_heading = goal_by_goal['content_heading']
82
+ end
83
+ if goal_by_goal.has_key?('heading')
84
+ goal_heading = goal_by_goal['heading']
85
+ end
75
86
  elsif !goal_by_index.nil?
76
87
  if !goal_by_index.has_key?('goal') || goal_by_index['goal'].to_s == goal.to_s
77
88
  goal_content = goal_by_index['content']
89
+ if goal_by_index.has_key?('content_heading') && goal_by_index['content_heading'] != ''
90
+ goal_content_heading = goal_by_index['content_heading']
91
+ end
92
+ if goal_by_index.has_key?('heading')
93
+ goal_heading = goal_by_index['heading']
94
+ end
78
95
  end
79
96
  end
80
97
  end
@@ -85,6 +102,8 @@ module JekyllOpenSdgPlugins
85
102
  self.data['goal_number'] = goal.to_s
86
103
  self.data['language'] = language
87
104
  self.data['layout'] = layout
105
+ self.data['goal_content_heading'] = goal_content_heading
106
+ self.data['goal_heading'] = goal_heading
88
107
  end
89
108
  end
90
109
  end
@@ -55,7 +55,7 @@ module JekyllOpenSdgPlugins
55
55
  # Clone pages so that we don't edit the original.
56
56
  pages = pages.clone
57
57
 
58
- # Automate the frontpage and indicators.json if not already there.
58
+ # Automate some required pages if not already there.
59
59
  frontpage = pages.find { |page| page['folder'] == '/' && page['filename'] == nil }
60
60
  if frontpage == nil || frontpage['layout'] == 'frontpage-alt'
61
61
  pages.push({
@@ -71,6 +71,20 @@ module JekyllOpenSdgPlugins
71
71
  'filename' => 'indicators.json'
72
72
  })
73
73
  end
74
+ if site.config.has_key?('progressive_web_app')
75
+ if site.config['progressive_web_app'].is_a?(Hash)
76
+ if site.config['progressive_web_app']['enabled']
77
+ offline = pages.find { |page| page['layout'] == 'offline' }
78
+ if offline == nil
79
+ pages.push({
80
+ 'folder' => '/',
81
+ 'layout' => 'offline',
82
+ 'filename' => 'offline.html'
83
+ })
84
+ end
85
+ end
86
+ end
87
+ end
74
88
 
75
89
  # Hardcode the site configuration page if it's not already there.
76
90
  form_settings = site.config['site_config_form']
@@ -114,6 +128,22 @@ module JekyllOpenSdgPlugins
114
128
  end
115
129
  end
116
130
  end
131
+
132
+ if site.config.has_key?('progressive_web_app') and site.config['progressive_web_app']['enabled']
133
+ language = site.config['languages'][0]
134
+ manifest_page = {
135
+ 'filename' => 'manifest.json',
136
+ 'folder' => '/',
137
+ 'layout' => 'manifest',
138
+ }
139
+ service_worker_page = {
140
+ 'filename' => 'service-worker.js',
141
+ 'folder' => '/',
142
+ 'layout' => 'service-worker',
143
+ }
144
+ site.collections['pages'].docs << OpenSdgPage.new(site, site.source, '/', manifest_page, language)
145
+ site.collections['pages'].docs << OpenSdgPage.new(site, site.source, '/', service_worker_page, language)
146
+ end
117
147
  end
118
148
  end
119
149
 
@@ -0,0 +1,35 @@
1
+ require "jekyll"
2
+
3
+ module JekyllOpenSdgPlugins
4
+ class MetaTags < Jekyll::Generator
5
+ safe true
6
+ priority :lowest
7
+
8
+ def clean_path(path)
9
+ path.delete_prefix('/').delete_suffix('/')
10
+ end
11
+
12
+ def find_metatags_by_path(path, config)
13
+ config.select { |tag| clean_path(tag['path']) == path }
14
+ end
15
+
16
+ def generate(site)
17
+
18
+ # Some general variables needed below.
19
+ languages = site.config['languages']
20
+ default_language = languages[0]
21
+
22
+ if site.config.has_key?('meta_tags')
23
+ site.collections.keys.each do |collection|
24
+ if collection == 'pages'
25
+ site.collections[collection].docs.each do |doc|
26
+ cleaned_path = clean_path(doc.data['url_by_language'][default_language])
27
+ meta_tags = find_metatags_by_path(cleaned_path, site.config['meta_tags'])
28
+ doc.data['meta_tags'] = meta_tags
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,138 @@
1
+ require "jekyll"
2
+ require_relative "helpers"
3
+
4
+ module JekyllOpenSdgPlugins
5
+ class Routes < Jekyll::Generator
6
+ safe true
7
+ priority :lowest
8
+
9
+ def generate(site)
10
+
11
+ routes = {}
12
+ baseurl = ''
13
+ if site.config.has_key?('baseurl')
14
+ baseurl = site.config['baseurl']
15
+ end
16
+ unless baseurl.end_with?('/')
17
+ baseurl = baseurl + '/'
18
+ end
19
+
20
+ routes['pages'] = []
21
+ site.collections['pages'].docs.each do |doc|
22
+ route = baseurl + doc.url
23
+ route = route.gsub('//', '/')
24
+
25
+ unless route.end_with?('/') or route.end_with?('.html') or route.end_with?('.json')
26
+ route = route + '/'
27
+ end
28
+
29
+ unless doc.data['layout'] == 'config-builder' or doc.data['layout'] == 'data-editor'
30
+ routes['pages'].append(route)
31
+ end
32
+ end
33
+
34
+ routes['config'] = []
35
+ site.collections['pages'].docs.each do |doc|
36
+ route = baseurl + doc.url
37
+ route = route.gsub('//', '/')
38
+
39
+ unless route.end_with?('/') or route.end_with?('.html') or route.end_with?('.json')
40
+ route = route + '/'
41
+ end
42
+
43
+ if doc.data['layout'] == 'config-builder' or doc.data['layout'] == 'data-editor'
44
+ routes['config'].append(route)
45
+ end
46
+ end
47
+
48
+ routes['indicators'] = []
49
+ site.collections['indicators'].docs.each do |doc|
50
+ route = baseurl + doc.url
51
+ route = route.gsub('//', '/')
52
+
53
+ unless route.end_with?('/') or route.end_with?('.html') or route.end_with?('.json')
54
+ route = route + '/'
55
+ end
56
+ routes['indicators'].append(route)
57
+ end
58
+
59
+ routes['goals'] = []
60
+ site.collections['goals'].docs.each do |doc|
61
+ route = baseurl + doc.url
62
+ route = route.gsub('//', '/')
63
+
64
+ unless route.end_with?('/') or route.end_with?('.html') or route.end_with?('.json')
65
+ route = route + '/'
66
+ end
67
+ routes['goals'].append(route)
68
+ end
69
+
70
+ routes['posts'] = []
71
+ site.collections['posts'].docs.each do |doc|
72
+ route = baseurl + doc.url
73
+ route = route.gsub('//', '/')
74
+
75
+ unless route.end_with?('/') or route.end_with?('.html') or route.end_with?('.json')
76
+ route = route + '/'
77
+ end
78
+ routes['posts'].append(route)
79
+ end
80
+
81
+ routes['images'] = []
82
+ if site.config.has_key?('logos') and site.config['logos'].length > 0
83
+ site.config['logos'].each do |logo|
84
+ route = baseurl + logo['src']
85
+ routes['images'].append(route)
86
+ end
87
+ end
88
+
89
+ goal_image_base = 'https://open-sdg.org/sdg-translations/assets/img/goals'
90
+ if site.config.has_key?('goal_image_base')
91
+ goal_image_base = site.config['goal_image_base']
92
+ end
93
+ goal_image_extension = 'png'
94
+ if site.config.has_key?('goal_image_extension') && site.config['goal_image_extension'] != ''
95
+ goal_image_extension = site.config['goal_image_extension']
96
+ end
97
+ goal_image_base_contrast = goal_image_base.gsub('img/goals', 'img/high-contrast/goals')
98
+
99
+ site.collections['goals'].docs.each do |doc|
100
+ goal_number = doc.data['goal']['number']
101
+ language = doc.data['language']
102
+ if goal_number.is_a? Numeric
103
+ goal_number = goal_number.to_s
104
+ end
105
+ route = goal_image_base + '/' + language + '/' + goal_number + '.' + goal_image_extension
106
+ routes['images'].append(route)
107
+ unless goal_image_extension == 'svg'
108
+ route = goal_image_base_contrast + '/' + language + '/' + goal_number + '.' + goal_image_extension
109
+ routes['images'].append(route)
110
+ end
111
+ end
112
+
113
+ data_prefix = site.config['remote_data_prefix']
114
+ unless data_prefix.start_with?('http')
115
+ data_prefix = baseurl
116
+ end
117
+ unless data_prefix.end_with?('/')
118
+ data_prefix = data_prefix + '/'
119
+ end
120
+
121
+ routes['json'] = []
122
+ routes['csv'] = []
123
+ routes['zip'] = []
124
+ site.config['languages'].each do |language|
125
+ site.collections['indicators'].docs.each do |doc|
126
+ route = data_prefix + language + '/comb/' + doc.data['indicator']['slug'] + '.json'
127
+ routes['json'].append(route)
128
+ route = data_prefix + language + '/data/' + doc.data['indicator']['slug'] + '.csv'
129
+ routes['csv'].append(route)
130
+ end
131
+ route = data_prefix + language + '/zip/' + site.data[language]['zip']['filename']
132
+ routes['zip'].append(route)
133
+ end
134
+
135
+ site.data['routes'] = routes
136
+ end
137
+ end
138
+ end
@@ -690,6 +690,41 @@
690
690
  }
691
691
  ]
692
692
  },
693
+ "proxy": {
694
+ "title": "Proxy indicator",
695
+ "type": "string",
696
+ "description": "Whether the indicator is a 'proxy' (meaning that it is somehow different than the globally-defined SDG indicator).",
697
+ "enum": ["", "proxy", "both"],
698
+ "options": {
699
+ "enum_titles": [
700
+ "Not a proxy indicator (default)",
701
+ "Proxy indicator",
702
+ "Both (contains both a proxy series and a non-proxy series)"
703
+ ]
704
+ },
705
+ "links": [
706
+ {
707
+ "rel": "More information the proxy setting",
708
+ "href": "https://open-sdg.readthedocs.io/en/latest/indicator-configuration/#proxy"
709
+ }
710
+ ]
711
+ },
712
+ "proxy_series": {
713
+ "options": {"collapsed": true},
714
+ "type": "array",
715
+ "title": "Proxy indicator - per series",
716
+ "description": "A list of each series within this indicator that should be considered a proxy (meaning that it is different somehow from the globally-defined series). Only needed if you chose 'Mixed series' above.",
717
+ "items": {
718
+ "type": "string",
719
+ "title": "Series"
720
+ },
721
+ "links": [
722
+ {
723
+ "rel": "More information on the proxy_series setting",
724
+ "href": "https://open-sdg.readthedocs.io/en/latest/indicator-configuration/#proxy_series"
725
+ }
726
+ ]
727
+ },
693
728
  "publications": {
694
729
  "options": {"collapsed": true},
695
730
  "type": "array",
@@ -145,12 +145,22 @@
145
145
  "type": "object",
146
146
  "title": "Goal",
147
147
  "properties": {
148
+ "heading": {
149
+ "type": "string",
150
+ "title": "Page heading",
151
+ "description": "Optional heading to display in the goal banner (as an H1) for this goal. If left blank, the goal name will be used."
152
+ },
148
153
  "content": {
149
154
  "type": "string",
150
155
  "title": "Content",
151
156
  "format": "markdown",
152
157
  "description": "Markdown content or a translation key for this goal."
153
158
  },
159
+ "content_heading": {
160
+ "type": "string",
161
+ "title": "Content heading",
162
+ "description": "Optional heading to display above the content (as an H2) for this goal. If left blank, the site-wide 'Goal content heading' (above) will be used."
163
+ },
154
164
  "goal": {
155
165
  "type": "string",
156
166
  "title": "Goal",
@@ -1137,6 +1147,42 @@
1137
1147
  }
1138
1148
  ]
1139
1149
  },
1150
+ "meta_tags": {
1151
+ "options": {"collapsed": true},
1152
+ "type": "array",
1153
+ "title": "Meta tags",
1154
+ "description": "This setting can be used to add custom meta tags at any paths.",
1155
+ "items": {
1156
+ "type": "object",
1157
+ "title": "Meta tag",
1158
+ "properties": {
1159
+ "path": {
1160
+ "type": "string",
1161
+ "minLength": 1,
1162
+ "title": "Path",
1163
+ "description": "The path within the platform at which to place this tag."
1164
+ },
1165
+ "name": {
1166
+ "type": "string",
1167
+ "minLength": 1,
1168
+ "title": "Name",
1169
+ "description": "The 'name' attribute for the meta tag."
1170
+ },
1171
+ "src": {
1172
+ "type": "string",
1173
+ "minLength": 1,
1174
+ "title": "Content",
1175
+ "description": "The 'content' attribute for the meta tag. Translation keys can be used."
1176
+ }
1177
+ }
1178
+ },
1179
+ "links": [
1180
+ {
1181
+ "rel": "More information on the Meta Tags setting",
1182
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#meta_tags"
1183
+ }
1184
+ ]
1185
+ },
1140
1186
  "news": {
1141
1187
  "options": {"collapsed": true},
1142
1188
  "type": "object",
@@ -1214,6 +1260,60 @@
1214
1260
  }
1215
1261
  ]
1216
1262
  },
1263
+ "progressive_web_app": {
1264
+ "options": {"collapsed": true},
1265
+ "type": "object",
1266
+ "title": "Progressive Web App",
1267
+ "description": "Configuration for turning the platform into a progressive web app for offline usage.",
1268
+ "properties": {
1269
+ "enabled": {
1270
+ "type": "boolean",
1271
+ "title": "Enabled",
1272
+ "description": "If enabled, the platform will be a progressive web app for offline usage.",
1273
+ "format": "checkbox"
1274
+ },
1275
+ "name": {
1276
+ "type": "string",
1277
+ "title": "Name",
1278
+ "description": "The full name of the app (displays on splash screen)."
1279
+ },
1280
+ "short_name": {
1281
+ "type": "string",
1282
+ "title": "Short name",
1283
+ "description": "The short name of the app (displays under home screen icon)."
1284
+ },
1285
+ "precaching": {
1286
+ "type": "boolean",
1287
+ "title": "Precaching",
1288
+ "description": "If enabled, all indicator and goal pages will be precached when the app is installed.",
1289
+ "format": "checkbox"
1290
+ }
1291
+ },
1292
+ "links": [
1293
+ {
1294
+ "rel": "More information on the progressive_web_app setting",
1295
+ "href": "https://open-sdg.readthedocs.io/en/latest/configuration/#progressive_web_app"
1296
+ }
1297
+ ]
1298
+ },
1299
+ "proxy_indicators": {
1300
+ "options": {"collapsed": true},
1301
+ "type": "object",
1302
+ "title": "Proxy indicators",
1303
+ "description": "Configuration for the proxy indicator functionality.",
1304
+ "properties": {
1305
+ "label": {
1306
+ "type": "string",
1307
+ "title": "Label",
1308
+ "description": "The label to display when flagging a proxy indicator. Defaults to 'Proxy'."
1309
+ },
1310
+ "description": {
1311
+ "type": "string",
1312
+ "title": "Description",
1313
+ "description": "The description to display at the top of indicator pages, explaining what 'Proxy' means."
1314
+ }
1315
+ }
1316
+ },
1217
1317
  "remote_data_prefix": {
1218
1318
  "type": "string",
1219
1319
  "minLength": 1,
@@ -130,6 +130,17 @@ module JekyllOpenSdgPlugins
130
130
  baseurl + number
131
131
  end
132
132
 
133
+ # Compute a sub-page URL for an item, given it's number.
134
+ def get_subpage_url(baseurl, language, number, languages, languages_public)
135
+ url = get_url(baseurl, language, number, languages, languages_public)
136
+ # Becuase Open SDG is a static site, subpages should end with
137
+ # a slash if they are not actual files (with file extensions).
138
+ unless url.split('/').last().include?('.')
139
+ url = url + '/'
140
+ end
141
+ url
142
+ end
143
+
133
144
  # Get a Hash of all the URLs based on one particular one.
134
145
  def get_all_urls(url, language, languages, languages_public, baseurl)
135
146
 
@@ -368,7 +379,7 @@ module JekyllOpenSdgPlugins
368
379
  'slug' => goal_number.gsub('.', '-'),
369
380
  'name' => opensdg_translate_key(goal_translation_key + '-title', translations, language),
370
381
  'short' => opensdg_translate_key(goal_translation_key + '-short', translations, language),
371
- 'url' => get_url(baseurl, language, goal_number, languages, languages_public),
382
+ 'url' => get_subpage_url(baseurl, language, goal_number, languages, languages_public),
372
383
  'icon' => get_goal_image(goal_image_base, language, goal_number, goal_image_extension),
373
384
  'sort' => get_sort_order(goal_number),
374
385
  'global' => global_goal,
@@ -421,7 +432,7 @@ module JekyllOpenSdgPlugins
421
432
  'number' => indicator_number,
422
433
  'slug' => indicator_number.gsub('.', '-'),
423
434
  'name' => opensdg_translate_key(indicator_name, translations, language),
424
- 'url' => get_url(baseurl, language, indicator_path, languages, languages_public),
435
+ 'url' => get_subpage_url(baseurl, language, indicator_path, languages, languages_public),
425
436
  'sort' => indicator_sort,
426
437
  'goal_number' => goal_number,
427
438
  'target_number' => target_number,
@@ -1,3 +1,3 @@
1
1
  module JekyllOpenSdgPlugins
2
- VERSION = "2.1.0".freeze
2
+ VERSION = "2.2.0-beta1".freeze
3
3
  end
@@ -13,6 +13,8 @@ require_relative "jekyll-open-sdg-plugins/search_index"
13
13
  require_relative "jekyll-open-sdg-plugins/validate_indicator_config"
14
14
  require_relative "jekyll-open-sdg-plugins/metadata_schema_to_config"
15
15
  require_relative "jekyll-open-sdg-plugins/backwards_compatibility"
16
+ require_relative "jekyll-open-sdg-plugins/meta_tags"
17
+ require_relative "jekyll-open-sdg-plugins/routes"
16
18
 
17
19
  module JekyllOpenSdgPlugins
18
20
  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: 2.1.0
4
+ version: 2.2.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-11-07 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -73,7 +73,9 @@ files:
73
73
  - lib/jekyll-open-sdg-plugins/create_pages.rb
74
74
  - lib/jekyll-open-sdg-plugins/fetch_remote_data.rb
75
75
  - lib/jekyll-open-sdg-plugins/helpers.rb
76
+ - lib/jekyll-open-sdg-plugins/meta_tags.rb
76
77
  - lib/jekyll-open-sdg-plugins/metadata_schema_to_config.rb
78
+ - lib/jekyll-open-sdg-plugins/routes.rb
77
79
  - lib/jekyll-open-sdg-plugins/schema-indicator-config.json
78
80
  - lib/jekyll-open-sdg-plugins/schema-site-config.json
79
81
  - lib/jekyll-open-sdg-plugins/sdg_variables.rb
@@ -102,9 +104,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
104
  version: '0'
103
105
  required_rubygems_version: !ruby/object:Gem::Requirement
104
106
  requirements:
105
- - - ">="
107
+ - - ">"
106
108
  - !ruby/object:Gem::Version
107
- version: '0'
109
+ version: 1.3.1
108
110
  requirements: []
109
111
  rubygems_version: 3.1.4
110
112
  signing_key: