From 5c78192435210cdb7792ed56b04c2ef24a2d2127 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 12 Oct 2009 14:19:04 -0400 Subject: [PATCH] year calendar: only link to months that have posts This does mean the year calendars depend on existence of all posts made in the year and have to be updated. --- IkiWiki/Plugin/calendar.pm | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index d5a80795a..ddcd1a823 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -242,6 +242,20 @@ EOF sub format_year (@) { my %params=@_; + + my @post_months; + foreach my $p (pagespec_match_list($params{page}, + "creation_year($params{year}) and ($params{pages})", + # add presence dependencies to update + # year calendar's links to months when + # pages are added/removed + deptype => deptype("presence"))) { + my $mtime = $IkiWiki::pagectime{$p}; + my @date = localtime($mtime); + my $month = $date[4] + 1; + + $post_months[$month]++; + } my $calendar="\n"; @@ -313,7 +327,8 @@ EOF $tag = 'year-calendar-month-nolink'; } - if ($pagesources{"$archivebase/$params{year}/$mtag"}) { + if ($pagesources{"$archivebase/$params{year}/$mtag"} && + $post_months[$mtag]) { $murl = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}/$mtag", noimageinline => 1, -- 2.45.2