zeus.ugent.be/lib/helpers/archives.rb

27 lines
590 B
Ruby
Raw Normal View History

2016-07-23 21:17:24 +02:00
module ArchiveHelper
def academic_years
academic_years = Set.new
2016-07-23 23:05:52 +02:00
items.find_all('/posts/**/*').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
academic_years.map { |y| [y, items["/archives/#{y}-#{y + 1}.html"]] }.to_h
end
2016-07-23 22:06:06 +02:00
def pretty_year(year)
"'#{year} - '#{year + 1}"
end
def posts_in_year(academic_year)
items.find_all('/posts/**/*').select do |post|
post[:academic_year] == academic_year
end
2016-07-23 21:17:24 +02:00
end
end