2016-07-23 21:17:24 +02:00
|
|
|
module ArchiveHelper
|
|
|
|
def academic_years
|
2017-09-30 17:42:52 +02:00
|
|
|
# Set.to_a to prevent duplicates
|
|
|
|
Set.new(items
|
|
|
|
.find_all('/blog/*/*')
|
|
|
|
.map { |i| i.identifier.to_s[/\d\d-\d\d/] })
|
|
|
|
.to_a
|
|
|
|
.sort
|
2019-08-17 15:09:27 +02:00
|
|
|
.push(@config[:academic_year])
|
|
|
|
.uniq
|
2016-07-23 21:17:24 +02:00
|
|
|
end
|
|
|
|
|
2017-06-07 10:23:02 +02:00
|
|
|
def academic_years_blog_items
|
2017-02-09 02:31:56 +01:00
|
|
|
academic_years.reverse.map { |y| [y, items["/blog/#{y}.html"]] }
|
2016-07-23 21:17:24 +02:00
|
|
|
end
|
|
|
|
|
2016-07-23 22:06:06 +02:00
|
|
|
def pretty_year(year)
|
2017-02-09 02:31:56 +01:00
|
|
|
year = year.scan(/\d\d/)
|
|
|
|
"'#{year[0]} - '#{year[1]}"
|
2016-07-23 22:06:06 +02:00
|
|
|
end
|
|
|
|
|
2017-02-09 02:31:56 +01:00
|
|
|
def posts_in_year(y)
|
|
|
|
items.find_all("/blog/#{y}/*").sort_by { |x| x[:created_at] }.reverse
|
2016-07-23 21:17:24 +02:00
|
|
|
end
|
|
|
|
end
|