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
1
Rules
1
Rules
|
|
@ -3,6 +3,7 @@
|
|||
preprocess do
|
||||
merge_location_data
|
||||
generate_event_pages
|
||||
generate_activity_pages
|
||||
generate_archive_pages
|
||||
generate_twitter_archive_pages
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
ErrorDocument 404 /404/index.html
|
||||
|
||||
RedirectMatch 301 ^/events/$ /events/<%= Time.now.year %>/
|
||||
RedirectMatch 301 ^/activities/$ /activities/<%= Time.now.year %>/
|
||||
RedirectMatch 301 ^/archives/articles/$ /archives/articles/<%= latest_articles(1)[0][:created_at].year %>/
|
||||
RedirectMatch 301 ^/archives/twitter/$ /archives/twitter/<%= twitter_grouped_by_month.keys.sort.last %>/
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
<li><a<%= menu_active_if("main")%> href="/"><i class="icon-home"></i></a>
|
||||
<li><a<%= menu_active_if("about")%> href="/about/">Wir über uns</a>
|
||||
<li><a<%= menu_active_if("events")%> href="/events/">Veranstaltungen</a>
|
||||
<li><a<%= menu_active_if("activities")%> href="#">Aktivitäten</a>
|
||||
<li><a<%= menu_active_if("activities")%> href="/activities/">Aktivitäten</a>
|
||||
<li><a<%= menu_active_if("projects")%> href="/projects/">Projekte</a>
|
||||
<li><a<%= menu_active_if("members")%> href="/members/">Members</a>
|
||||
<li><a<%= menu_active_if("planet-cccs")%> href="/planet-cccs/">Planet CCCS</a>
|
||||
|
|
|
|||
|
|
@ -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