This commit is contained in:
Lorin Werthen 2016-12-11 00:55:11 +01:00
parent f05f17219d
commit 4409393527
No known key found for this signature in database
GPG key ID: F11FFC921E0E08E0
3 changed files with 52 additions and 51 deletions

58
Rules
View file

@ -14,47 +14,10 @@ preprocess do
`npm install` `npm install`
# We don't want to compile old blogposts in development # We don't want to compile old blogposts in development
if development? ignore_old_blogposts if development?
@items.delete_if do |item| update_blog_attributes
ident = item.identifier.to_s create_blog_items
convert_event_time_to_timestamps
next unless ident.to_s.start_with?('/blog/')
!ident.start_with?('/blog/16-17/')
end
end
@items.find_all('/blog/**/*').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, title: 'Blog' },
"/blog/#{year}-#{year + 1}.html",
binary: false
)
end
academic_years_items[academic_years.max].update_attributes(
navigable: true,
order: 10
)
all_events.each do |event|
event[:time] = DateTime.parse(event[:time])
end
end end
# #
@ -67,8 +30,6 @@ compile '/feed.xml' do
write '/feed.xml' write '/feed.xml'
end end
passthrough '/quotes.json'
# #
# ARCHIVES # ARCHIVES
# #
@ -95,9 +56,6 @@ compile '/events/**/*', rep: :text do
filter :strip_html filter :strip_html
end end
compile '/events/**/main.md', rep: :ical do
end
compile '/events/**/*', rep: :ical do compile '/events/**/*', rep: :ical do
filter :ical filter :ical
end end
@ -135,12 +93,10 @@ route '/projects/*' do; end
# #
compile '/*_search.json' do compile '/*_search.json' do
filter :erb filter :erb
write @item.identifier.to_s
end end
compile '/**/*.ics' do compile '/**/*.ics' do
filter :erb filter :erb
write @item.identifier.to_s
end end
compile '/**/*.erb' do compile '/**/*.erb' do
@ -163,9 +119,6 @@ compile '/assets/stylesheets/**/*.scss' do
filter :autoprefixer if production? filter :autoprefixer if production?
end end
passthrough '/assets/images/*.{png,svg}'
passthrough '/assets/**/*.js'
# #
# #
# ROUTES # ROUTES
@ -196,6 +149,9 @@ route '/**/*.{erb,html,md}' do
end end
end end
# Let anything else simply pass through
passthrough '/**/*'
# #
# #
# LAYOUTS # LAYOUTS

44
lib/helpers/preprocess.rb Normal file
View file

@ -0,0 +1,44 @@
module PreprocessHelper
def ignore_old_blogposts
@items.delete_if do |item|
next unless item.identifier.to_s.start_with?('/blog/')
!item.identifier.to_s.start_with?('/blog/16-17/')
end
end
def update_blog_attributes
@items.find_all('/blog/**/*').each do |i|
year_str = %r{/(\d\d)-\d\d/}.match(i.identifier).captures[0]
attr_hash = {
# Tag all posts with article (for Blogging helper)
kind: 'article',
academic_year: year_str.to_i
}
i.update_attributes(attr_hash)
end
end
def create_blog_items
# academic_years is defined in archives.rb
academic_years.each do |year|
@items.create(
'',
{ academic_year: year, title: 'Blog' },
"/blog/#{year}-#{year + 1}.html"
)
end
academic_years_items[academic_years.max].update_attributes(
navigable: true,
order: 10
)
end
def convert_event_time_to_timestamps
all_events.each do |event|
event[:time] = DateTime.parse(event[:time])
end
end
end

View file

@ -15,3 +15,4 @@ include FontAwesomeHelper
include ProjectsHelper include ProjectsHelper
include SearchHelper include SearchHelper
include BlogHelper include BlogHelper
include PreprocessHelper