9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/jekyll-open-sdg-plugins/create_goals.rb', line 9
def generate(site)
if site.config['languages'] and site.config['create_goals']
goals = {}
metadata = {}
default_language = site.config['languages'][0]
metadata = site.data[default_language]['meta']
metadata.each do |inid, indicator|
if indicator.has_key?('standalone') and indicator['standalone']
next
end
goal = inid.split('-')[0]
goals[goal] = true
end
layout = 'goal'
languages_public = Hash.new
if site.config['languages_public']
languages_public = opensdg_languages_public(site)
end
site.config['languages'].each_with_index do |language, index|
language_public = language
if languages_public[language]
language_public = languages_public[language]
end
goal_index = 0
begin
goals_sorted = goals.keys.sort_by { |k| k.to_i if Float(k) rescue k }
rescue
goals_sorted = goals.keys.sort
end
goals_sorted.each do |goal|
dir = index == 0 ? goal.to_s : File.join(language_public, goal.to_s)
site.collections['goals'].docs << GoalPage.new(site, site.source, dir, goal, language, layout, goal_index)
goal_index += 1
end
end
end
end
|