Yearly archive: Always create a page for current year
This commit is contained in:
parent
5ad6fafb7a
commit
8afa1e6267
5 changed files with 16 additions and 1 deletions
|
|
@ -7,3 +7,12 @@ def generate_event_pages()
|
|||
generate_yearly_archive(articles, :startdate, '/events', 'Veranstaltungen des CCC Stuttgart', 'event_archive')
|
||||
end
|
||||
|
||||
def get_activities()
|
||||
items.select { |i| (i[:kind]=='event') && i.identifier.start_with?('/activities') }
|
||||
end
|
||||
|
||||
def generate_activity_pages()
|
||||
articles = get_activities()
|
||||
generate_yearly_archive(articles, :startdate, '/activities', 'Aktionen und Aktivitäten', 'event_archive')
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue