forked from ZeusWPI/zeus.ugent.be
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rules
289 lines (230 loc) · 4.98 KB
/
Rules
1
2
3
4
5
6
7
8
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'json'
require 'icalendar'
require 'kramdown'
require 'kramdown-math-katex'
# Important!!!
# First ignore the node_modules, we do not need any of it on the site directly.
ignore '/node_modules/**/*'
#
#
# PREPROCESS
#
#
preprocess do
`yarn`
# We don't want to compile old blogposts in development
ignore_old_content('blog', 'events', 'about/verslagen') if development?
update_blog_attributes
convert_tags('Blog')
convert_tags('Events')
create_yearly_items('Blog')
create_yearly_items('Events')
create_tagly_items('Blog')
create_tagly_items('Events')
convert_event_time_to_timestamps
all_events.each do |event|
check_schema(:event, event)
end
all_privacy_items.each do |project|
check_schema(:privacy, project)
end
add_report_metadata
add_project_metadata
convert_locations
create_banner_items
end
#
#
# COMPILATION
#
#
compile '/*.xml' do
filter :erb
end
#
# ARCHIVES
#
compile '/blog/*' do
layout '/blogs.*'
layout '/generic.*'
layout '/default.*'
filter :erb
filter :html_press if production?
end
#
# EVENTS
#
# Overview page
compile '/events/*' do
layout '/events.*'
layout '/generic.*'
layout '/default.*'
filter :erb
filter :html_press if production?
end
compile '/events/*/*' do
filter :erb
filter :kramdown, {math_engine: :katex}
layout '/eventpost.*'
layout '/default.*'
filter :erb
filter :html_press if production?
end
compile '/events/*/*', rep: :text do
filter :kramdown
filter :strip_html
end
compile '/events/*/*', rep: :ical do
filter :ical
write ext: 'ics'
end
# Generate a banner page for each event.
# This could be filtered by only using the upcoming events,
# but we cannot have dynamic compile directives, and generating
# HTML is fast, so there is no need.
compile '/events/*/*', rep: :banner do
layout '/banner.*'
filter :erb
filter :kramdown, { math_engine: :katex }
# Needed to render the resulting page in puppeteer
filter :relativize_paths, type: :html
write "#{item.identifier.without_exts}/banner.html"
end
postprocess do
# For the next upcoming event, open the banner representation in
# puppeteer and create an image of that page.
# This is used for the WINA image API.
upcoming_events.first(1).each do |item|
generate_screenshot(item)
end
end
#
# POSTS
#
compile '/blog/*/*.md' do
filter :erb
layout '/blogpost.md'
filter :kramdown, {math_engine: :katex}
filter :colorize_syntax
filter :typogruby_custom
layout '/blogpost.erb'
layout '/generic.*'
layout '/default.*'
filter :erb
filter :html_press if production?
end
compile '/blog/*/*.md', rep: :text do
filter :erb
filter :kramdown
filter :strip_html
end
compile '/blog/*/*.md', rep: :html do
filter :erb
filter :kramdown
end
#
# PROJECTS
#
compile '/projects/*' do
filter :kramdown
# Don't write out the projects themselves for now
write nil
end
compile '/*_search.json' do
filter :erb
end
compile '/wina_image_api.json' do
filter :erb
end
compile '/**/*.ics' do
filter :erb
end
#
# PRIVACY
#
compile '/about/privacy/*' do
filter :kramdown
# Don't write out the privacy items themselves for now
nil
end
#
# REPORTS
#
# Note drive/verslagen is 'linked' as a data source to /about/verslagen/
compile '/about/verslagen/*/*.md', rep: :pdf do
filter :pandoc_pdf, args: { f: :markdown, 'pdf-engine': 'xelatex', template: 'templates/report.tex' } if production?
write ext: (production? ? 'pdf' : 'md')
end
#
# GENERIC ERB PAGES
#
compile '/**/*.erb' do
filter :erb
# Apply typographic improvements if required by the page. Use this on text-heavy pages,
# such as the history page.
if @item[:typography]
filter :typogruby_custom
end
layout '/generic.*'
layout '/default.*'
filter :html_press if production?
end
compile '/**/*.md' do
filter :erb
filter :kramdown
layout '/generic.*'
layout '/default.*'
end
#
# ASSETS
#
compile '/assets/scripts/**/*.js' do
filter :uglify_js, harmony: true if production?
end
ignore '/data/**/*'
ignore '/assets/stylesheets/includes/**/*'
compile '/assets/stylesheets/**/*.scss' do
# This filter is necessary for the workaround present in main.scss and deals with out of date dependencies
filter :erb
sass_opts = {
syntax: :scss,
load_paths: ['content/assets/stylesheets']
}
sass_opts[:style] = :compressed if production?
filter :sassc, sass_opts
filter :autoprefixer if production?
write ext: 'css'
end
compile '/assets/stylesheets/**/*.css' do
if production?
filter :rainpress
filter :autoprefixer
end
write ext: 'css'
end
#
#
# ROUTES
#
#
# Google verification file
passthrough '/google6f2e77d0228abc35.html'
route '/**/index.{erb,html,md}' do
"#{item.identifier.without_ext}.html"
end
route '/**/*.{erb,html,md}' do
"#{item.identifier.without_ext}/index.html"
end
route %r[/well-known/(.+)] do |rest|
"/.well-known/#{rest[0]}"
end
# Let anything else simply pass through
passthrough '/**/*'
#
#
# LAYOUTS
#
#
layout '/**/*', :erb