jekyll-open-sdg-plugins 0.0.6 → 0.0.7

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: a65d32d0ddf87249e3ee4ffd1e8a1c50823f75d3e7824727c8d464dd54a44666
4
- data.tar.gz: ba85f18877187d68931a506b031596bf730b9a7035a03a191a736391df7c2ab3
3
+ metadata.gz: 87648f4556fee686eb7926015147d736d8d52081bbc8427c90b35c9bdced87b3
4
+ data.tar.gz: 228cc5b9614fb508ff1ebc85de543495ff1f0358bc12aad046946162ab3b4c7c
5
5
  SHA512:
6
- metadata.gz: 6d94b90b6db52c3ef3548e959f4fc3694720b332e20336990b66ed5c6db9907774df90b7c68abef2f67c5b0ca77c8f40fe2b4f52fbc9f8708707f3a154ee1048
7
- data.tar.gz: ec2060be58e31e4bb57b3d17a3c5a361ccc8110f87e30e8b9be34d349c6fb157d751636f41b5d30849768c152d333c75a5f8747cd55bf155532014525b6a5152
6
+ metadata.gz: 3a65a769b229b002fb44d389ca2ce043e9a2356b21129ff95b9f4df217c53b0256da30403fd0586cd77ed492cc131b38eb81ab5a08744513b4dcdda4b2d1e2bb
7
+ data.tar.gz: 8b43c92ef8aa602960da11a0a977fa6bb75bb014574f276a3c6495f2d47767dfb6740c8b19e99f812eecf5ea82b40644dd83ea22f8e0da265f2bc626a276cdf5
data/README.md CHANGED
@@ -1,3 +1,41 @@
1
1
  # jekyll-open-sdg-plugins
2
2
 
3
3
  > 💎 Jekyll plugins for use with the Open SDG platform
4
+
5
+ This plugin provides some Jekyll functionality for the [Open SDG](https://github.com/open-sdg/open-sdg) platform.
6
+
7
+ The functionality provided consists of:
8
+
9
+ ## 1. A "t" Liquid filter for translating strings.
10
+
11
+ Usage example:
12
+
13
+ ```
14
+ {{ my_variable | t }}
15
+ ```
16
+
17
+ ## 2. Fill in missing fields to allow partially translated metadata.
18
+
19
+ This allows metadata to be translated, field-by-field as needed, in subfolders in the data repository.
20
+
21
+ ## 3. Automatically create goal pages based on data.
22
+
23
+ This creates goal pages automatically based on the data, so that the site repository does not need to maintain a `_goals` folder. It depends on a `_config.yml` setting.
24
+
25
+ Usage example (in `_config.yml`):
26
+ ```
27
+ create_goals:
28
+ # This determines which layout is used to render the pages.
29
+ layout: goal
30
+ ```
31
+
32
+ ## 4. Automatically create indicator pages based on data.
33
+
34
+ This creates indicator pages automatically based on the data, so that the site repository does not need to maintain a `_indicators` folder. It depends on a `_config.yml` setting.
35
+
36
+ Usage example (in `_config.yml`):
37
+ ```
38
+ create_indicators:
39
+ # This determines which layout is used to render the pages.
40
+ layout: indicator
41
+ ```
@@ -0,0 +1,51 @@
1
+ require "jekyll"
2
+
3
+ module JekyllOpenSdgPlugins
4
+ class CreateGoals < Jekyll::Generator
5
+ safe true
6
+ priority :low
7
+
8
+ def generate(site)
9
+ # If site.create_goals is set, create goals per the metadata.
10
+ if site.config['languages'] and site.config['create_goals']
11
+ # Compile the list of goals.
12
+ goals = {}
13
+ site.data['meta'].each do |inid, meta|
14
+ goal = inid.split('-')[0].to_i
15
+ goals[goal] = true
16
+ end
17
+ # Decide what layout to use for the goal pages.
18
+ layout = 'goal'
19
+ if site.config['create_goals'].key?('layout')
20
+ layout = site.config['create_goals']['layout']
21
+ end
22
+ # Loop through the languages.
23
+ site.config['languages'].each_with_index do |language, index|
24
+ # Loop through the goals.
25
+ goals.sort.each do |goal, value|
26
+ # Add the language subfolder for all except the default (first) language.
27
+ dir = index == 0 ? goal.to_s : File.join(language, goal.to_s)
28
+ # Create the goal page.
29
+ site.collections['goals'].docs << GoalPage.new(site, site.source, dir, goal, language, layout)
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ # A Page subclass used in the `CreateGoals` class.
37
+ class GoalPage < Jekyll::Page
38
+ def initialize(site, base, dir, goal, language, layout)
39
+ @site = site
40
+ @base = base
41
+ @dir = dir
42
+ @name = 'index.html'
43
+
44
+ self.process(@name)
45
+ self.data = {}
46
+ self.data['sdg_goal'] = goal.to_s
47
+ self.data['language'] = language
48
+ self.data['layout'] = layout
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,45 @@
1
+ require "jekyll"
2
+
3
+ module JekyllOpenSdgPlugins
4
+ class CreateIndicators < Jekyll::Generator
5
+ safe true
6
+ priority :low
7
+
8
+ def generate(site)
9
+ # If site.create_indicators is set, create indicators per the metadata.
10
+ if site.config['languages'] and site.config['create_indicators']
11
+ # Decide what layout to use for the indicator pages.
12
+ layout = 'indicator'
13
+ if site.config['create_indicators'].key?('layout')
14
+ layout = site.config['create_indicators']['layout']
15
+ end
16
+ # Loop through the languages.
17
+ site.config['languages'].each_with_index do |language, index|
18
+ # Loop through the indicators (using metadata as a list).
19
+ site.data['meta'].each do |inid, meta|
20
+ # Add the language subfolder for all except the default (first) language.
21
+ dir = index == 0 ? inid : File.join(language, inid)
22
+ # Create the indicator page.
23
+ site.collections['indicators'].docs << IndicatorPage.new(site, site.source, dir, inid, language, layout)
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ # A Page subclass used in the `CreateIndicators` class.
31
+ class IndicatorPage < Jekyll::Page
32
+ def initialize(site, base, dir, inid, language, layout)
33
+ @site = site
34
+ @base = base
35
+ @dir = dir
36
+ @name = 'index.html'
37
+
38
+ self.process(@name)
39
+ self.data = {}
40
+ self.data['indicator'] = inid.gsub('-', '.')
41
+ self.data['layout'] = layout
42
+ self.data['language'] = language
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module JekyllOpenSdgPlugins
2
- VERSION = "0.0.6".freeze
2
+ VERSION = "0.0.7".freeze
3
3
  end
@@ -1,6 +1,8 @@
1
1
  require_relative "jekyll-open-sdg-plugins/version"
2
2
  require_relative "jekyll-open-sdg-plugins/multilingual_metadata"
3
3
  require_relative "jekyll-open-sdg-plugins/translate_key"
4
+ require_relative "jekyll-open-sdg-plugins/create_indicators"
5
+ require_relative "jekyll-open-sdg-plugins/create_goals"
4
6
 
5
7
  module JekyllOpenSdgPlugins
6
8
  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: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brock Fanning
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-09 00:00:00.000000000 Z
11
+ date: 2019-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -37,6 +37,8 @@ files:
37
37
  - README.md
38
38
  - jekyll-open-sdg-plugins.gemspec
39
39
  - lib/jekyll-open-sdg-plugins.rb
40
+ - lib/jekyll-open-sdg-plugins/create_goals.rb
41
+ - lib/jekyll-open-sdg-plugins/create_indicators.rb
40
42
  - lib/jekyll-open-sdg-plugins/multilingual_metadata.rb
41
43
  - lib/jekyll-open-sdg-plugins/translate_key.rb
42
44
  - lib/jekyll-open-sdg-plugins/version.rb