2016-07-23 21:17:24 +02:00
|
|
|
module ArchiveHelper
|
|
|
|
def academic_years
|
|
|
|
academic_years = Set.new
|
|
|
|
|
2016-10-31 13:48:39 +01:00
|
|
|
items.find_all('/blog/*/*').each do |i|
|
2016-07-23 21:17:24 +02:00
|
|
|
academic_year = %r{/(\d\d)-\d\d/}.match(i.identifier).captures[0]
|
|
|
|
academic_years << academic_year.to_i
|
|
|
|
end
|
|
|
|
|
|
|
|
academic_years
|
|
|
|
end
|
|
|
|
|
|
|
|
def academic_years_items
|
2016-09-22 21:23:40 +02:00
|
|
|
academic_years.to_a.reverse.map { |y| [y, items["/blog/#{y}-#{y + 1}.html"]] }.to_h
|
2016-07-23 21:17:24 +02:00
|
|
|
end
|
|
|
|
|
2016-07-23 22:06:06 +02:00
|
|
|
def pretty_year(year)
|
|
|
|
"'#{year} - '#{year + 1}"
|
|
|
|
end
|
|
|
|
|
|
|
|
def posts_in_year(academic_year)
|
2016-10-31 13:48:39 +01:00
|
|
|
items.find_all('/blog/*/*').sort_by { |x| Date.parse x[:created_at] }.select do |post|
|
2016-07-23 22:06:06 +02:00
|
|
|
post[:academic_year] == academic_year
|
2016-10-10 01:31:22 +02:00
|
|
|
end.reverse
|
2016-07-23 21:17:24 +02:00
|
|
|
end
|
|
|
|
end
|