Yearly archive: Always create a page for current year

This commit is contained in:
Stefan Schlott 2013-08-26 08:26:14 +02:00
parent 5ad6fafb7a
commit 8afa1e6267
5 changed files with 16 additions and 1 deletions

View file

@ -1,7 +1,11 @@
require 'ostruct'
def generate_yearly_archive(articles, date_attribute, basepath, title, templatename = 'article_archive')
currentyear = Time.now.year
yearmap = articles.group_by { |item| item[date_attribute].year }
if !yearmap.has_key?(currentyear)
yearmap[currentyear] = []
end
yearlist = yearmap.keys.sort
yearlist.each_index { |i|
year = yearlist[i]