173 lines
2.4 KiB
Ruby
173 lines
2.4 KiB
Ruby
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require 'json'
|
|
require 'icalendar'
|
|
|
|
#
|
|
#
|
|
# PREPROCESS
|
|
#
|
|
#
|
|
|
|
preprocess do
|
|
@items.find_all('/posts/**/*').each do |i|
|
|
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 },
|
|
"/archives/#{year}-#{year + 1}.html",
|
|
binary: false
|
|
)
|
|
end
|
|
end
|
|
|
|
#
|
|
#
|
|
# COMPILATION
|
|
#
|
|
#
|
|
compile '/feed.xml' do
|
|
filter :erb
|
|
write '/feed.xml'
|
|
end
|
|
|
|
#
|
|
# ARCHIVES
|
|
#
|
|
compile '/archives/*' do
|
|
layout '/archive_page.*'
|
|
layout '/generic.*'
|
|
layout '/default.*'
|
|
filter :erb
|
|
|
|
filter :relativize_paths, type: :html
|
|
end
|
|
|
|
#
|
|
# EVENTS
|
|
#
|
|
compile '/events/**/*' do
|
|
filter :kramdown
|
|
|
|
layout '/eventpost.*'
|
|
layout '/default.*'
|
|
filter :erb
|
|
|
|
filter :relativize_paths, type: :html
|
|
end
|
|
|
|
compile '/events/**/*', rep: :text do
|
|
filter :kramdown
|
|
filter :strip_html
|
|
end
|
|
|
|
compile '/events/**/main.md', rep: :ical do
|
|
end
|
|
|
|
compile '/events/**/*', rep: :ical do
|
|
filter :ical
|
|
end
|
|
|
|
#
|
|
# POSTS
|
|
#
|
|
compile '/posts/**/*' do
|
|
filter :kramdown
|
|
|
|
layout '/blogpost.*'
|
|
layout '/generic.*'
|
|
layout '/default.*'
|
|
|
|
filter :relativize_paths, type: :html
|
|
end
|
|
|
|
compile '/posts/**/*', rep: :text do
|
|
filter :kramdown
|
|
filter :strip_html
|
|
end
|
|
|
|
#
|
|
# GENERIC ERB PAGES
|
|
#
|
|
compile '/tipuesearch_content.js' do
|
|
filter :erb
|
|
end
|
|
|
|
compile '/**/*.ics' do
|
|
filter :erb
|
|
end
|
|
|
|
compile '/*.erb' do
|
|
layout '/generic.*'
|
|
layout '/default.*'
|
|
filter :erb
|
|
|
|
filter :relativize_paths, type: :html
|
|
end
|
|
|
|
#
|
|
# ASSETS
|
|
#
|
|
compile '/assets/scripts/**/*.coffee' do
|
|
filter :coffeescript
|
|
end
|
|
|
|
ignore '/assets/stylesheets/includes/**/*'
|
|
|
|
compile '/assets/stylesheets/**/*.scss' do
|
|
filter :sass, syntax: :scss
|
|
end
|
|
|
|
passthrough '/assets/images/*.{png,svg}'
|
|
|
|
#
|
|
#
|
|
# ROUTES
|
|
#
|
|
#
|
|
|
|
#
|
|
# ASSETS
|
|
#
|
|
route '/assets/stylesheets/**/*' do
|
|
"#{item.identifier.without_ext}.css"
|
|
end
|
|
|
|
route '/assets/scripts/**/*' do
|
|
"#{item.identifier.without_ext}.js"
|
|
end
|
|
|
|
# POSTS
|
|
route '/events/**/*', rep: :ical do
|
|
"#{item.identifier.without_ext}.ics"
|
|
end
|
|
|
|
route '/**/*.{erb,html,md}' do
|
|
"#{item.identifier.without_ext}.html"
|
|
end
|
|
|
|
route '/**/*' do
|
|
item.identifier.to_s
|
|
end
|
|
|
|
#
|
|
#
|
|
# LAYOUTS
|
|
#
|
|
#
|
|
|
|
layout '/**/*', :erb
|