122 lines
2.2 KiB
Ruby
122 lines
2.2 KiB
Ruby
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
require 'json'
|
|
|
|
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
|
|
|
|
@items.create('', {}, '/tipuesearch_content.js', binary: false)
|
|
end
|
|
|
|
# This makes sure this tipuesearch_content doesn't get deleted
|
|
passthrough '/tipuesearch_content.js'
|
|
|
|
# ERB
|
|
compile '/cammie.*' do
|
|
layout '/default.*'
|
|
filter :erb
|
|
|
|
filter :relativize_paths, type: :html
|
|
end
|
|
|
|
compile '/archives/*' do
|
|
layout '/archive_page.*'
|
|
layout '/generic.*'
|
|
layout '/default.*'
|
|
filter :erb
|
|
|
|
filter :relativize_paths, type: :html
|
|
end
|
|
|
|
# Coffeescript
|
|
compile '/assets/scripts/**/*.coffee' do
|
|
filter :coffeescript
|
|
end
|
|
|
|
# SCSS
|
|
compile '/assets/stylesheets/**/*.scss' do
|
|
filter :sass, syntax: :scss
|
|
end
|
|
|
|
# Compile all posts
|
|
compile '/posts/**/*' do
|
|
filter :kramdown
|
|
|
|
layout '/eventpost.*'
|
|
layout '/default.*'
|
|
filter :erb
|
|
|
|
filter :relativize_paths, type: :html
|
|
end
|
|
|
|
compile '/posts/**/*', rep: :text do
|
|
filter :kramdown
|
|
filter :strip_html
|
|
end
|
|
|
|
compile '/*.erb' do
|
|
layout '/generic.*'
|
|
layout '/default.*'
|
|
filter :erb
|
|
|
|
filter :relativize_paths, type: :html
|
|
end
|
|
|
|
route '/index.*' do
|
|
'/index.html'
|
|
end
|
|
|
|
route '/assets/stylesheets/**/*' do
|
|
"#{item.identifier.without_ext}.css"
|
|
end
|
|
|
|
route '/assets/scripts/**/*' do
|
|
"#{item.identifier.without_ext}.js"
|
|
end
|
|
|
|
passthrough '/assets/images/*.{png}'
|
|
|
|
route '/**/*.{erb,html,md}' do
|
|
"#{item.identifier.without_ext}/index.html"
|
|
end
|
|
|
|
layout '/**/*', :erb
|
|
|
|
postprocess do
|
|
tmp = articles.map do |e|
|
|
{
|
|
title: e[:title],
|
|
url: url_for(e),
|
|
text: excerptize(e.reps[:text].compiled_content, length: 200),
|
|
tags: ''
|
|
}
|
|
end
|
|
|
|
tmp = { pages: tmp }
|
|
|
|
File.open('output/tipuesearch_content.js', 'w') do |f|
|
|
f.write("var tipuesearch = #{tmp.to_json};")
|
|
end
|
|
end
|