2016-06-09 14:27:23 +02:00
|
|
|
#!/usr/bin/env ruby
|
2016-07-19 08:39:52 +02:00
|
|
|
# frozen_string_literal: true
|
2016-06-09 14:27:23 +02:00
|
|
|
|
2016-07-20 14:38:50 +02:00
|
|
|
require 'json'
|
|
|
|
|
|
|
|
preprocess do
|
2016-07-20 17:52:56 +02:00
|
|
|
@items.find_all('/posts/**/*').each do |i|
|
2016-07-23 21:17:24 +02: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 },
|
|
|
|
"/archives/#{year}-#{year + 1}.html",
|
|
|
|
binary: false
|
|
|
|
)
|
2016-07-20 14:38:50 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
@items.create('', {}, '/tipuesearch_content.js', binary: false)
|
|
|
|
end
|
|
|
|
|
|
|
|
# This makes sure this tipuesearch_content doesn't get deleted
|
|
|
|
passthrough '/tipuesearch_content.js'
|
|
|
|
|
2016-07-18 23:34:38 +02:00
|
|
|
# ERB
|
2016-07-19 10:27:27 +02:00
|
|
|
compile '/*.erb' do
|
2016-07-23 21:17:24 +02:00
|
|
|
layout '/generic.*'
|
2016-07-19 10:27:27 +02:00
|
|
|
layout '/default.*'
|
2016-07-23 21:17:24 +02:00
|
|
|
filter :erb
|
|
|
|
|
|
|
|
filter :relativize_paths, type: :html
|
|
|
|
end
|
|
|
|
|
|
|
|
compile '/archives/*' do
|
|
|
|
posts = items.find_all('/posts/**/*').select do |post|
|
|
|
|
post[:academic_year] == item[:academic_year]
|
|
|
|
end
|
2016-07-18 09:24:24 +02:00
|
|
|
|
2016-07-23 21:17:24 +02:00
|
|
|
layout '/generic.*'
|
|
|
|
layout '/default.*'
|
2016-07-19 10:27:27 +02:00
|
|
|
filter :erb
|
2016-07-23 21:17:24 +02:00
|
|
|
|
2016-07-18 09:24:24 +02:00
|
|
|
filter :relativize_paths, type: :html
|
2016-06-09 14:27:23 +02:00
|
|
|
end
|
|
|
|
|
2016-07-18 23:34:38 +02:00
|
|
|
# Coffeescript
|
2016-07-19 10:27:27 +02:00
|
|
|
compile '/assets/scripts/**/*.coffee' do
|
2016-06-09 17:57:40 +02:00
|
|
|
filter :coffeescript
|
|
|
|
end
|
|
|
|
|
2016-07-18 23:34:38 +02:00
|
|
|
# SCSS
|
2016-07-19 10:27:27 +02:00
|
|
|
compile '/assets/stylesheets/**/*.scss' do
|
2016-06-29 21:38:57 +02:00
|
|
|
filter :sass, syntax: :scss
|
|
|
|
end
|
|
|
|
|
2016-07-18 23:34:38 +02:00
|
|
|
# Compile all posts
|
2016-07-20 17:52:56 +02:00
|
|
|
compile '/posts/**/*' do
|
2016-06-09 15:04:10 +02:00
|
|
|
filter :kramdown
|
2016-07-18 09:24:24 +02:00
|
|
|
|
2016-07-19 10:27:27 +02:00
|
|
|
layout '/eventpost.*'
|
|
|
|
layout '/default.*'
|
2016-07-12 23:58:08 +02:00
|
|
|
filter :erb
|
2016-07-18 09:24:24 +02:00
|
|
|
|
|
|
|
filter :relativize_paths, type: :html
|
2016-06-09 15:04:10 +02:00
|
|
|
end
|
2016-06-09 14:27:23 +02:00
|
|
|
|
2016-07-20 17:52:56 +02:00
|
|
|
compile '/posts/**/*', rep: :text do
|
|
|
|
filter :kramdown
|
|
|
|
filter :strip_html
|
|
|
|
end
|
|
|
|
|
2016-07-18 23:34:38 +02:00
|
|
|
route '/index.*' do
|
2016-07-18 09:34:01 +02:00
|
|
|
'/index.html'
|
2016-07-18 09:27:32 +02:00
|
|
|
end
|
|
|
|
|
2016-07-18 23:34:38 +02:00
|
|
|
route '/assets/stylesheets/**/*' do
|
|
|
|
"#{item.identifier.without_ext}.css"
|
|
|
|
end
|
|
|
|
|
|
|
|
route '/assets/scripts/**/*' do
|
|
|
|
"#{item.identifier.without_ext}.js"
|
|
|
|
end
|
|
|
|
|
2016-07-19 10:27:27 +02:00
|
|
|
passthrough '/assets/images/*.{png}'
|
2016-07-18 23:34:38 +02:00
|
|
|
|
2016-07-18 09:27:32 +02:00
|
|
|
route '/**/*.{erb,html,md}' do
|
2016-06-09 16:08:43 +02:00
|
|
|
"#{item.identifier.without_ext}/index.html"
|
2016-06-09 14:27:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
layout '/**/*', :erb
|
2016-07-20 14:38:50 +02:00
|
|
|
|
|
|
|
postprocess do
|
|
|
|
tmp = articles.map do |e|
|
|
|
|
{
|
|
|
|
title: e[:title],
|
|
|
|
url: url_for(e),
|
2016-07-20 18:23:38 +02:00
|
|
|
text: excerptize(e.reps[:text].compiled_content, length: 200),
|
2016-07-20 14:38:50 +02:00
|
|
|
tags: ''
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
tmp = { pages: tmp }
|
|
|
|
|
|
|
|
File.open('output/tipuesearch_content.js', 'w') do |f|
|
|
|
|
f.write("var tipuesearch = #{tmp.to_json};")
|
|
|
|
end
|
|
|
|
end
|