diff --git a/content/htaccess.txt b/content/htaccess.txt index 1ac47526..9cc9f3d6 100644 --- a/content/htaccess.txt +++ b/content/htaccess.txt @@ -2,7 +2,7 @@ ErrorDocument 404 /404/index.html RedirectMatch 303 ^/events/$ /events/<%= Time.now.year %>/ RedirectMatch 303 ^/activities/$ /activities/<%= Time.now.year %>/ -RedirectMatch 303 ^/archives/articles/$ /archives/articles/<%= Time.now.year %>/ +RedirectMatch 303 ^/archives/articles/$ /archives/articles/<%= latest_articles(1,0)[0][:created_at].year %>/ RedirectMatch 303 ^/archives/twitter/$ /archives/twitter/<%= twitter_grouped_by_month.keys.sort.last %>/ RedirectMatch 301 ^/wiki$ / diff --git a/content/index.html b/content/index.html index 9098829f..b3b4e86a 100644 --- a/content/index.html +++ b/content/index.html @@ -94,7 +94,7 @@ feed: <% end %> -

Weitere Artikel

+

Weitere Artikel

Letzte Tweets

diff --git a/lib/articlehelpers.rb b/lib/articlehelpers.rb index 11a9584b..67f03aea 100644 --- a/lib/articlehelpers.rb +++ b/lib/articlehelpers.rb @@ -33,14 +33,17 @@ def sanitize_path(path) result end -def latest_articles(max=nil) - threshold = Date.today - 90 # Show articles for 90 days +def latest_articles(max=nil, threshold_days=90) @cache_latest_art ||= @site.items.select do |p| - p.attributes[:kind] == 'article' and p.attributes[:created_at] > threshold + p.attributes[:kind] == 'article' and ((threshold_days <= 0) end.sort do |a, b| a.attributes[:created_at] <=> b.attributes[:created_at] end.reverse - @cache_latest_art[0..(max ? max-1 : @cache_latest_art.length-1)] + + threshold = Date.today - threshold_days + @cache_latest_art[0..(max ? max-1 : @cache_latest_art.length-1)].select do |p| + (threshold_days <= 0) or (p.attributes[:created_at] > threshold) + end end def latest_articles_referred_to(refers_to, max=nil)