3 Here's a patch to the calendar plugin. If you specify an event preprocessor in a post, such as:
5 [[event time="2008-06-24"]]
7 That date will be used instead of the post creation time when displaying the calendar.
9 --- calendar.pm.orig 2008-06-24 22:36:09.000000000 -0400
10 +++ calendar.pm 2008-06-24 22:51:11.000000000 -0400
21 hook(type => "needsbuild", id => "version", call => \&needsbuild);
22 hook(type => "preprocess", id => "calendar", call => \&preprocess);
23 + hook(type => "preprocess", id => "event", call => \&preprocess_event);
26 sub is_leap_year (@) { #{{{
31 +sub preprocess_event (@) { #{{{
33 + # if now time is given, use now
34 + $params{time} = localtime unless defined $params{time};
36 + my $timestamp = str2time($params{time});
37 + if ( defined $timestamp) {
38 + $pagestate{$params{page}}{event}{mtime}=$timestamp;
40 + # remove the event block entirely
44 sub preprocess (@) { #{{{
46 $params{pages} = "*" unless defined $params{pages};
48 if (! defined $cache{$pagespec}) {
49 foreach my $p (keys %pagesources) {
50 next unless pagespec_match($p, $pagespec);
51 - my $mtime = $IkiWiki::pagectime{$p};
53 + # use time defined by event preprocessor if it's available
54 + if (defined $pagestate{$p}{event}{mtime}) {
55 + $mtime = $pagestate{$p}{event}{mtime};
57 + $mtime = $IkiWiki::pagectime{$p};
59 my $src = $pagesources{$p};
60 my @date = localtime($mtime);