diff options
author | Joey Hess <joey@gnu.kitenet.net> | 2009-10-12 14:19:04 -0400 |
---|---|---|
committer | Joey Hess <joey@gnu.kitenet.net> | 2009-10-12 14:19:04 -0400 |
commit | 5c78192435210cdb7792ed56b04c2ef24a2d2127 (patch) | |
tree | 6663d933ea81918a32c410491e28900084a2ad22 /IkiWiki | |
parent | 22737e53f1b0367bc9bfb8d7bcbfc4dcc08a81ae (diff) | |
download | ikiwiki-5c78192435210cdb7792ed56b04c2ef24a2d2127.tar ikiwiki-5c78192435210cdb7792ed56b04c2ef24a2d2127.tar.gz |
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.
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/calendar.pm | 17 |
1 files changed, 16 insertions, 1 deletions
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, |