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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
# File 'lib/jekyll-open-sdg-plugins/create_pages.rb', line 9
def generate(site)
if (site.config['languages'] and site.config['create_pages'])
default_pages = [
{
'folder' => '/reporting-status',
'layout' => 'reportingstatus',
'title' => 'status.reporting_status',
},
{
'folder' => '/search',
'layout' => 'search',
'title' => 'search.search',
}
]
pages = default_pages
if (site.config['create_pages'].is_a?(Hash) and site.config['create_pages'].key?('pages'))
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')
end
if site.config['create_pages'].is_a?(Array)
pages = site.config['create_pages']
end
pages = pages.clone
frontpage = pages.find { |page| page['folder'] == '/' && page['filename'] == nil }
if frontpage == nil || frontpage['layout'] == 'frontpage-alt'
pages.push({
'folder' => '/',
'layout' => 'frontpage',
})
end
indicatorjson = pages.find { |page| page['layout'] == 'indicator-json' }
if indicatorjson == nil
pages.push({
'folder' => '/',
'layout' => 'indicator-json',
'filename' => 'indicators.json'
})
end
if site.config.has_key?('progressive_web_app')
if site.config['progressive_web_app'].is_a?(Hash)
if site.config['progressive_web_app']['enabled']
offline = pages.find { |page| page['layout'] == 'offline' }
if offline == nil
pages.push({
'folder' => '/',
'layout' => 'offline',
'filename' => 'offline.html'
})
end
end
end
end
form_settings = site.config['site_config_form']
config_page = pages.find { |page| page['layout'] == 'config-builder' }
config_builder_layout = 'config-builder'
if site.config['use_new_config_forms']
config_builder_layout = 'config-builder-2'
end
if config_page == nil
if form_settings && form_settings['enabled']
pages.push({
'folder' => '/config',
'layout' => config_builder_layout,
'title' => 'Open SDG site configuration',
'config_type' => 'site',
'config_filename' => 'site_config.yml',
})
end
end
config_page = pages.find { |page| page['layout'] == config_builder_layout }
if config_page != nil && form_settings && form_settings['enabled']
config_page['form_settings'] = form_settings
end
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
pages.each do |page|
dir = index == 0 ? page['folder'] : File.join(language_public, page['folder'])
site.collections['pages'].docs << OpenSdgPage.new(site, site.source, dir, page, language)
end
end
end
if site.config.has_key?('progressive_web_app') and site.config['progressive_web_app']['enabled']
language = site.config['languages'][0]
manifest_page = {
'filename' => 'manifest.json',
'folder' => '/',
'layout' => 'manifest',
}
service_worker_page = {
'filename' => 'service-worker.js',
'folder' => '/',
'layout' => 'service-worker',
}
site.collections['pages'].docs << OpenSdgPage.new(site, site.source, '/', manifest_page, language)
site.collections['pages'].docs << OpenSdgPage.new(site, site.source, '/', service_worker_page, language)
end
end
|