2016-12-11 00:55:11 +01:00
|
|
|
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|
|
2017-02-09 02:37:43 +01:00
|
|
|
i.update_attributes(
|
2016-12-11 00:55:11 +01:00
|
|
|
# Tag all posts with article (for Blogging helper)
|
|
|
|
kind: 'article',
|
2017-02-09 02:36:29 +01:00
|
|
|
academic_year: i.identifier.to_s[/\d\d-\d\d/],
|
2017-02-09 02:31:56 +01:00
|
|
|
created_at: Date.parse(i[:created_at])
|
2017-02-09 02:37:43 +01:00
|
|
|
)
|
2016-12-11 00:55:11 +01:00
|
|
|
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' },
|
2017-02-09 02:31:56 +01:00
|
|
|
"/blog/#{year}.html"
|
2016-12-11 00:55:11 +01:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2017-02-09 02:31:56 +01:00
|
|
|
academic_years_items[0][1].update_attributes(
|
2016-12-11 00:55:11 +01:00
|
|
|
navigable: true,
|
|
|
|
order: 10
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def convert_event_time_to_timestamps
|
|
|
|
all_events.each do |event|
|
|
|
|
event[:time] = DateTime.parse(event[:time])
|
2017-02-08 17:05:48 +01:00
|
|
|
event[:end] = DateTime.parse(event[:end]) if event[:end]
|
2016-12-11 00:55:11 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|