zeus.ugent.be/Rules

205 lines
3 KiB
Plaintext
Raw Normal View History

2016-06-09 12:27:23 +00:00
#!/usr/bin/env ruby
2016-07-19 06:39:52 +00:00
# frozen_string_literal: true
2016-06-09 12:27:23 +00:00
2016-07-20 12:38:50 +00:00
require 'json'
2016-07-26 22:13:36 +00:00
require 'icalendar'
2016-07-20 12:38:50 +00:00
2016-07-23 20:43:46 +00:00
#
#
# PREPROCESS
#
#
2016-07-20 12:38:50 +00:00
preprocess do
`npm install`
# We don't want to compile old blogposts in development
if development?
@items.delete_if do |item|
ident = item.identifier.to_s
next unless ident.to_s.start_with?('/posts/')
!ident.start_with?('/posts/16-17/')
end
end
2016-07-20 15:52:56 +00:00
@items.find_all('/posts/**/*').each do |i|
2016-07-23 19:17:24 +00:00
year_str = %r{/(\d\d)-\d\d/}.match(i.identifier).captures[0]
academic_year = year_str.to_i
attr_hash = {
# Tag all posts with article (for Blogging helper)
kind: 'article',
academic_year: academic_year
}
i.update_attributes(attr_hash)
end
# academic_years is defined in archives.rb
academic_years.each do |year|
@items.create(
'',
{ academic_year: year, title: 'Blog' },
2016-09-22 19:23:40 +00:00
"/blog/#{year}-#{year + 1}.html",
2016-07-23 19:17:24 +00:00
binary: false
)
2016-07-20 12:38:50 +00:00
end
2016-09-21 15:53:32 +00:00
2016-10-03 20:33:52 +00:00
academic_years_items[academic_years.max].update_attributes(
navigable: true,
order: 10
)
2016-10-03 13:15:48 +00:00
all_events.each do |event|
event[:time] = DateTime.parse(event[:time])
2016-10-03 13:15:48 +00:00
end
2016-07-20 12:38:50 +00:00
end
2016-07-23 20:43:46 +00:00
#
#
# COMPILATION
#
#
2016-08-04 18:57:25 +00:00
compile '/feed.xml' do
2016-07-26 18:08:42 +00:00
filter :erb
2016-08-04 18:57:25 +00:00
write '/feed.xml'
2016-07-26 18:08:42 +00:00
end
2016-07-23 20:43:46 +00:00
2016-10-03 20:33:52 +00:00
passthrough '/quotes.json'
2016-07-23 20:43:46 +00:00
#
# ARCHIVES
#
2016-09-22 19:23:40 +00:00
compile '/blog/*' do
2016-07-23 20:06:06 +00:00
layout '/archive_page.*'
2016-07-23 19:17:24 +00:00
layout '/generic.*'
layout '/default.*'
2016-07-19 08:27:27 +00:00
filter :erb
2016-06-09 12:27:23 +00:00
end
2016-07-23 20:43:46 +00:00
#
2016-08-23 18:21:02 +00:00
# EVENTS
2016-07-23 20:43:46 +00:00
#
2016-08-23 18:21:02 +00:00
compile '/events/**/*' do
2016-06-09 13:04:10 +00:00
filter :kramdown
2016-07-18 07:24:24 +00:00
2016-07-19 08:27:27 +00:00
layout '/eventpost.*'
layout '/default.*'
2016-07-12 21:58:08 +00:00
filter :erb
2016-06-09 13:04:10 +00:00
end
2016-06-09 12:27:23 +00:00
2016-08-23 18:21:02 +00:00
compile '/events/**/*', rep: :text do
2016-07-20 15:52:56 +00:00
filter :kramdown
filter :strip_html
end
2016-08-23 18:21:02 +00:00
compile '/events/**/main.md', rep: :ical do
end
compile '/events/**/*', rep: :ical do
2016-07-26 22:13:36 +00:00
filter :ical
end
2016-08-23 18:21:02 +00:00
#
# POSTS
#
compile '/posts/**/*' do
filter :kramdown
layout '/blogpost.*'
layout '/generic.*'
layout '/default.*'
end
compile '/posts/**/*', rep: :text do
filter :kramdown
filter :strip_html
end
2016-10-03 19:56:08 +00:00
#
# PROJECTS
#
compile '/projects/*' do
filter :kramdown
end
2016-10-15 19:43:29 +00:00
# Don't create specific project pages for now
route '/projects/*' do; end
2016-07-23 20:43:46 +00:00
#
# GENERIC ERB PAGES
#
2016-10-04 14:25:03 +00:00
compile '/*_search.json' do
2016-07-24 11:09:37 +00:00
filter :erb
2016-10-04 14:25:03 +00:00
write @item.identifier.to_s
2016-07-24 11:09:37 +00:00
end
2016-08-04 18:57:25 +00:00
compile '/**/*.ics' do
2016-07-26 22:13:36 +00:00
filter :erb
write @item.identifier.to_s
2016-07-26 22:13:36 +00:00
end
2016-07-23 20:06:06 +00:00
compile '/*.erb' do
layout '/generic.*'
layout '/default.*'
filter :erb
end
2016-07-23 20:43:46 +00:00
#
# ASSETS
#
compile '/assets/scripts/**/*.coffee' do
filter :coffeescript
end
2016-08-02 16:31:40 +00:00
ignore '/assets/stylesheets/includes/**/*'
2016-07-23 20:43:46 +00:00
compile '/assets/stylesheets/**/*.scss' do
filter :sass, syntax: :scss
filter :autoprefixer if production?
2016-07-23 20:43:46 +00:00
end
2016-08-30 21:20:15 +00:00
passthrough '/assets/images/*.{png,svg}'
2016-10-04 14:25:03 +00:00
passthrough '/assets/**/*.js'
2016-07-23 20:43:46 +00:00
#
#
# ROUTES
#
#
#
# ASSETS
#
2016-07-18 21:34:38 +00:00
route '/assets/stylesheets/**/*' do
"#{item.identifier.without_ext}.css"
end
route '/assets/scripts/**/*' do
"#{item.identifier.without_ext}.js"
end
# EVENTS
2016-08-23 18:21:02 +00:00
route '/events/**/*', rep: :ical do
2016-07-26 22:13:36 +00:00
"#{item.identifier.without_ext}.ics"
end
2016-07-18 07:27:32 +00:00
route '/**/*.{erb,html,md}' do
2016-08-30 21:37:32 +00:00
if item.identifier.without_ext.to_s =~ %r{/index$}
"#{item.identifier.without_ext}.html"
else
"#{item.identifier.without_ext}/index.html"
end
2016-06-09 12:27:23 +00:00
end
2016-07-23 20:43:46 +00:00
#
#
# LAYOUTS
#
#
2016-06-09 12:27:23 +00:00
layout '/**/*', :erb