From 6a2f3ef4bd0649608592331ae52ca6895abdd2c4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 15 Aug 2009 13:58:04 -0400 Subject: indentation --- IkiWiki/Plugin/calendar.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index fe4b16072..c25893f72 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -211,8 +211,8 @@ EOF # matching the pagespec are added or removed. add_depends($params{page}, $params{pages}); # Explicitly add all currently linked pages as dependencies, so - # that if they are removed, the calendar will be sure to be updated. - add_depends($params{page}, join(" or ", @list)); + # that if they are removed, the calendar will be sure to be updated. + add_depends($params{page}, join(" or ", @list)); return $calendar; } -- cgit v1.2.3 From b6fcb1cb0ef27e5a63184440675d465fad652acf Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 18 Jun 2009 15:55:55 +0100 Subject: calendar, inline, map: don't pre-join dependencies The new dependency handling works better (eliminates more duplicates) if dependencies are split up. On the same wiki mentioned in the previous commit, this saves about a second (i.e. 4%) on the same test. --- IkiWiki/Plugin/calendar.pm | 4 +++- IkiWiki/Plugin/inline.pm | 4 +++- IkiWiki/Plugin/map.pm | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index c25893f72..5d16dff75 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -212,7 +212,9 @@ EOF add_depends($params{page}, $params{pages}); # Explicitly add all currently linked pages as dependencies, so # that if they are removed, the calendar will be sure to be updated. - add_depends($params{page}, join(" or ", @list)); + foreach my $p (@list) { + add_depends($params{page}, $p); + } return $calendar; } diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 3a2f4b7bc..a501566b5 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -251,7 +251,9 @@ sub preprocess_inline (@) { # Explicitly add all currently displayed pages as dependencies, so # that if they are removed or otherwise changed, the inline will be # sure to be updated. - add_depends($params{page}, join(" or ", $#list >= $#feedlist ? @list : @feedlist)); + foreach my $p ($#list >= $#feedlist ? @list : @feedlist) { + add_depends($params{page}, $p); + } if ($feeds && exists $params{feedpages}) { @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page}); diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 826dbbd66..54146dc46 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -73,7 +73,9 @@ sub preprocess (@) { add_depends($params{page}, $params{pages}); # Explicitly add all currently shown pages, to detect when pages # are removed. - add_depends($params{page}, join(" or ", keys %mapitems)); + foreach my $item (keys %mapitems) { + add_depends($params{page}, $item); + } # Create the map. my $parent=""; -- cgit v1.2.3 From e4cd168ebedd95585290c97ff42234344bfed46c Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 24 Aug 2009 23:16:15 +0100 Subject: Allow add_depends to take an arrayref --- IkiWiki.pm | 9 +++++++++ IkiWiki/Plugin/calendar.pm | 4 +--- IkiWiki/Plugin/inline.pm | 4 +--- IkiWiki/Plugin/map.pm | 4 +--- 4 files changed, 12 insertions(+), 9 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 21a74adce..35fee1aa7 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1730,6 +1730,15 @@ sub add_depends ($$) { my $page=shift; my $pagespec=shift; + if (ref $pagespec eq 'ARRAY') { + foreach my $ps (@$pagespec) { + if (pagespec_valid($ps)) { + $depends{$page}{$ps} = 1; + } + } + return; + } + return unless pagespec_valid($pagespec); $depends{$page}{$pagespec} = 1; diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 5d16dff75..ce0719404 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -212,9 +212,7 @@ EOF add_depends($params{page}, $params{pages}); # Explicitly add all currently linked pages as dependencies, so # that if they are removed, the calendar will be sure to be updated. - foreach my $p (@list) { - add_depends($params{page}, $p); - } + add_depends($params{page}, \@list); return $calendar; } diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index a501566b5..b566d960f 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -251,9 +251,7 @@ sub preprocess_inline (@) { # Explicitly add all currently displayed pages as dependencies, so # that if they are removed or otherwise changed, the inline will be # sure to be updated. - foreach my $p ($#list >= $#feedlist ? @list : @feedlist) { - add_depends($params{page}, $p); - } + add_depends($params{page}, $#list >= $#feedlist ? \@list : \@feedlist); if ($feeds && exists $params{feedpages}) { @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page}); diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 54146dc46..cc977024d 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -73,9 +73,7 @@ sub preprocess (@) { add_depends($params{page}, $params{pages}); # Explicitly add all currently shown pages, to detect when pages # are removed. - foreach my $item (keys %mapitems) { - add_depends($params{page}, $item); - } + add_depends($params{page}, [keys %mapitems]); # Create the map. my $parent=""; -- cgit v1.2.3 From 5bcdc39999025062d201ae16babc0eabc2f4d976 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 25 Aug 2009 17:11:29 -0400 Subject: Revert "Allow add_depends to take an arrayref" This reverts commit e4cd168ebedd95585290c97ff42234344bfed46c. There was no benefit to this change. --- IkiWiki.pm | 9 --------- IkiWiki/Plugin/calendar.pm | 4 +++- IkiWiki/Plugin/inline.pm | 4 +++- IkiWiki/Plugin/map.pm | 4 +++- 4 files changed, 9 insertions(+), 12 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 8a8695768..871170992 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1738,15 +1738,6 @@ sub add_depends ($$) { my $page=shift; my $pagespec=shift; - if (ref $pagespec eq 'ARRAY') { - foreach my $ps (@$pagespec) { - if (pagespec_valid($ps)) { - $depends{$page}{$ps} = 1; - } - } - return; - } - return unless pagespec_valid($pagespec); $depends{$page}{$pagespec} = 1; diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index ce0719404..5d16dff75 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -212,7 +212,9 @@ EOF add_depends($params{page}, $params{pages}); # Explicitly add all currently linked pages as dependencies, so # that if they are removed, the calendar will be sure to be updated. - add_depends($params{page}, \@list); + foreach my $p (@list) { + add_depends($params{page}, $p); + } return $calendar; } diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index b566d960f..a501566b5 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -251,7 +251,9 @@ sub preprocess_inline (@) { # Explicitly add all currently displayed pages as dependencies, so # that if they are removed or otherwise changed, the inline will be # sure to be updated. - add_depends($params{page}, $#list >= $#feedlist ? \@list : \@feedlist); + foreach my $p ($#list >= $#feedlist ? @list : @feedlist) { + add_depends($params{page}, $p); + } if ($feeds && exists $params{feedpages}) { @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page}); diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index cc977024d..54146dc46 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -73,7 +73,9 @@ sub preprocess (@) { add_depends($params{page}, $params{pages}); # Explicitly add all currently shown pages, to detect when pages # are removed. - add_depends($params{page}, [keys %mapitems]); + foreach my $item (keys %mapitems) { + add_depends($params{page}, $item); + } # Create the map. my $parent=""; -- cgit v1.2.3 From a6689f9c7a1ecad02b51962c0858df47352c4648 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 4 Oct 2009 16:05:41 -0400 Subject: calendar: all dependencies are contentless --- IkiWiki/Plugin/calendar.pm | 21 ++++++++++++--------- debian/changelog | 6 +++--- 2 files changed, 15 insertions(+), 12 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 5d16dff75..a5cc20882 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -104,19 +104,22 @@ sub format_month (@) { "$archivebase/$year/".sprintf("%02d", $month), linktext => " $monthname "); } - add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month)); + add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month), + content => 0); if (exists $cache{$pagespec}{"$pyear/$pmonth"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/" . sprintf("%02d", $pmonth), linktext => " $pmonthname "); } - add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth)); + add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth), + content => 0); if (exists $cache{$pagespec}{"$nyear/$nmonth"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/" . sprintf("%02d", $nmonth), linktext => " $nmonthname "); } - add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth)); + add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth), + content => 0); # Start producing the month calendar $calendar=< 0); # Explicitly add all currently linked pages as dependencies, so # that if they are removed, the calendar will be sure to be updated. foreach my $p (@list) { - add_depends($params{page}, $p); + add_depends($params{page}, $p, content => 0); } return $calendar; @@ -246,19 +249,19 @@ sub format_year (@) { "$archivebase/$year", linktext => "$year"); } - add_depends($params{page}, "$archivebase/$year"); + add_depends($params{page}, "$archivebase/$year", content => 0); if (exists $cache{$pagespec}{"$pyear"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear", linktext => "\←"); } - add_depends($params{page}, "$archivebase/$pyear"); + add_depends($params{page}, "$archivebase/$pyear", content => 0); if (exists $cache{$pagespec}{"$nyear"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear", linktext => "\→"); } - add_depends($params{page}, "$archivebase/$nyear"); + add_depends($params{page}, "$archivebase/$nyear", content => 0); # Start producing the year calendar $calendar=<$monthabbr\n}; } - add_depends($params{page}, "$archivebase/$year/$mtag"); + add_depends($params{page}, "$archivebase/$year/$mtag", content => 0); $calendar.=qq{\t\n} if ($month % $params{months_per_row} == 0); } diff --git a/debian/changelog b/debian/changelog index 9d03ae990..1a76303b1 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,9 +13,9 @@ ikiwiki (3.14159266) UNRELEASED; urgency=low * Added support framework for multiple types of dependencies. * Allow declaring that a dependency does not encompass the content of a page. (By passing content => 0 to add_depends.) - * pagecount: Use a contentless dependency, which makes this - directive much less expensive to use, since page edits will - no longer trigger an unnecessary update of the page count. + * pagecount, calendar: Use a contentless dependency, which makes these + directives much less expensive to use, since page edits will + no longer trigger an unnecessary update. * map: Use a contentless dependency unless show= is specified. This makes simple maps efficient enough that they can be used on sidebars! * inline: Use a contentless dependency in quick mode. -- cgit v1.2.3 From be032a7b87d1080f1a54327346cb5b40432a056c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 4 Oct 2009 20:30:21 -0400 Subject: rework dependency types code Simplify, change default content depends number to 1, change interface to make more sense. --- IkiWiki.pm | 35 +++++++++++++++-------------------- IkiWiki/Plugin/calendar.pm | 18 +++++++++--------- IkiWiki/Plugin/edittemplate.pm | 2 +- IkiWiki/Plugin/listdirectives.pm | 2 +- IkiWiki/Plugin/meta.pm | 2 +- IkiWiki/Plugin/pagecount.pm | 4 ++-- IkiWiki/Plugin/postsparkline.pm | 2 +- IkiWiki/Plugin/progress.pm | 4 ++-- IkiWiki/Render.pm | 28 +++++++++++++--------------- doc/plugins/write.mdwn | 15 +++++++++------ ikiwiki-transition | 2 +- 11 files changed, 55 insertions(+), 59 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 5e5dc739d..c1d07531e 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -29,8 +29,8 @@ our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE our $installdir='/usr'; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE # Page dependency types. -our $DEPEND_EXISTS=1; -our $DEPEND_CONTENT=2; +our $DEPEND_CONTENT=1; +our $DEPEND_PRESENCE=2; # Optimisation. use Memoize; @@ -1540,13 +1540,13 @@ sub loadindex () { if (exists $d->{dependslist}) { # old format $depends{$page}={ - map { $_ => $DEPEND_CONTENT | $DEPEND_EXISTS } + map { $_ => $DEPEND_CONTENT } @{$d->{dependslist}} }; } elsif (exists $d->{depends} && ! ref $d->{depends}) { # old format - $depends{$page}={$d->{depends} => $DEPEND_CONTENT | $DEPEND_EXISTS}; + $depends{$page}={$d->{depends} => $DEPEND_CONTENT }; } elsif (exists $d->{depends}) { $depends{$page}=$d->{depends}; @@ -1771,16 +1771,23 @@ sub add_depends ($$;@) { my $page=shift; my $pagespec=shift; + # Is the pagespec a simple page name? my $simple=$pagespec =~ /$config{wiki_file_regexp}/ && $pagespec !~ /[\s*?()!]/; - my $deptype=$DEPEND_CONTENT | $DEPEND_EXISTS; + my $deptype=$DEPEND_CONTENT; if (@_) { my %params=@_; - if (defined $params{content} && $params{content} == 0 && - ($simple || pagespec_contentless($pagespec))) { - $deptype=$deptype & ~$DEPEND_CONTENT; + + # Is the pagespec limited to terms that will continue + # to match pages as long as those pages exist? + my $limited=1; + while ($limited && $pagespec=~m/(\w+)\([^\)]*\)/g) { + $limited = $1 =~ /^(glob|internal|creation_month|creation_day|creation_year|created_before|created_after)$/; } + + $deptype=$deptype & ~$DEPEND_CONTENT & $DEPEND_PRESENCE + if $params{presence} && $limited; } if ($simple) { @@ -1976,18 +1983,6 @@ sub pagespec_valid ($) { return ! $@; } -sub pagespec_contentless ($) { - my $spec=shift; - - while ($spec=~m{ - (\w+)\([^\)]*\) # only match pagespec functions - }igx) { - return 0 unless $1=~/^(glob|internal|creation_month|creation_day|creation_year|created_before|created_after)$/; - } - - return 1; -} - sub glob2re ($) { my $re=quotemeta(shift); $re=~s/\\\*/.*/g; diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index a5cc20882..a1117992a 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -105,21 +105,21 @@ sub format_month (@) { linktext => " $monthname "); } add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month), - content => 0); + presence => 1); if (exists $cache{$pagespec}{"$pyear/$pmonth"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/" . sprintf("%02d", $pmonth), linktext => " $pmonthname "); } add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth), - content => 0); + presence => 1); if (exists $cache{$pagespec}{"$nyear/$nmonth"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/" . sprintf("%02d", $nmonth), linktext => " $nmonthname "); } add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth), - content => 0); + presence => 1); # Start producing the month calendar $calendar=< 0); + add_depends($params{page}, $params{pages}, presence => 1); # Explicitly add all currently linked pages as dependencies, so # that if they are removed, the calendar will be sure to be updated. foreach my $p (@list) { - add_depends($params{page}, $p, content => 0); + add_depends($params{page}, $p, presence => 1); } return $calendar; @@ -249,19 +249,19 @@ sub format_year (@) { "$archivebase/$year", linktext => "$year"); } - add_depends($params{page}, "$archivebase/$year", content => 0); + add_depends($params{page}, "$archivebase/$year", presence => 1); if (exists $cache{$pagespec}{"$pyear"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear", linktext => "\←"); } - add_depends($params{page}, "$archivebase/$pyear", content => 0); + add_depends($params{page}, "$archivebase/$pyear", presence => 1); if (exists $cache{$pagespec}{"$nyear"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear", linktext => "\→"); } - add_depends($params{page}, "$archivebase/$nyear", content => 0); + add_depends($params{page}, "$archivebase/$nyear", presence => 1); # Start producing the year calendar $calendar=<$monthabbr\n}; } - add_depends($params{page}, "$archivebase/$year/$mtag", content => 0); + add_depends($params{page}, "$archivebase/$year/$mtag", presence => 1); $calendar.=qq{\t\n} if ($month % $params{months_per_row} == 0); } diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 89d450725..2dd1dbe68 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -58,7 +58,7 @@ sub preprocess (@) { $pagestate{$params{page}}{edittemplate}{$params{match}}=$link; return "" if ($params{silent} && IkiWiki::yesno($params{silent})); - add_depends($params{page}, $link, content => 0); + add_depends($params{page}, $link, presence => 1); return sprintf(gettext("edittemplate %s registered for %s"), htmllink($params{page}, $params{destpage}, $link), $params{match}); diff --git a/IkiWiki/Plugin/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm index 96150f986..4023ed7d7 100644 --- a/IkiWiki/Plugin/listdirectives.pm +++ b/IkiWiki/Plugin/listdirectives.pm @@ -84,7 +84,7 @@ sub preprocess (@) { foreach my $plugin (@pluginlist) { $result .= '
  • '; my $link=linkpage($config{directive_description_dir}."/".$plugin); - add_depends($params{page}, $link, content => 0); + add_depends($params{page}, $link, presence => 1); $result .= htmllink($params{page}, $params{destpage}, $link); $result .= '
  • '; } diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index eef3013a0..9b041a748 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -195,7 +195,7 @@ sub preprocess (@) { if (! length $link) { error gettext("redir page not found") } - add_depends($page, $link, content => 0); + add_depends($page, $link, presence => 1); $value=urlto($link, $page); $value.='#'.$redir_anchor if defined $redir_anchor; diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm index 17eda0618..80561350b 100644 --- a/IkiWiki/Plugin/pagecount.pm +++ b/IkiWiki/Plugin/pagecount.pm @@ -23,8 +23,8 @@ sub preprocess (@) { $params{pages}="*" unless defined $params{pages}; # Needs to update count whenever a page is added or removed, so - # register a contentless dependency. - add_depends($params{page}, $params{pages}, content => 0); + # register a presence dependency. + add_depends($params{page}, $params{pages}, presence => 1); my @pages; if ($params{pages} eq "*") { diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm index 694d39575..3205958d4 100644 --- a/IkiWiki/Plugin/postsparkline.pm +++ b/IkiWiki/Plugin/postsparkline.pm @@ -48,7 +48,7 @@ sub preprocess (@) { error gettext("unknown formula"); } - add_depends($params{page}, $params{pages}, content => 0); + add_depends($params{page}, $params{pages}, presence => 1); my @list=sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} } pagespec_match_list( diff --git a/IkiWiki/Plugin/progress.pm b/IkiWiki/Plugin/progress.pm index 3b664f4cb..26c537a84 100644 --- a/IkiWiki/Plugin/progress.pm +++ b/IkiWiki/Plugin/progress.pm @@ -36,8 +36,8 @@ sub preprocess (@) { $fill.="%"; } elsif (defined $params{totalpages} and defined $params{donepages}) { - add_depends($params{page}, $params{totalpages}, content => 0); - add_depends($params{page}, $params{donepages}, content => 0); + add_depends($params{page}, $params{totalpages}, presence => 1); + add_depends($params{page}, $params{donepages}, presence => 1); my @pages=keys %pagesources; my $totalcount=0; diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 3fc750925..cf0c3fe08 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -473,13 +473,11 @@ sub refresh () { if (exists $depends_simple{$p}) { foreach my $d (keys %{$depends_simple{$p}}) { - if ($depends_simple{$p}{$d} == $IkiWiki::DEPEND_EXISTS) { - if (exists $lc_exists_changed{$d}) { - $reason = $d; - last; - } - } - elsif (exists $lc_changed{$d}) { + if (($depends_simple{$p}{$d} & $IkiWiki::DEPEND_CONTENT && + exists $lc_changed{$d}) + || + ($depends_simple{$p}{$d} & $IkiWiki::DEPEND_PRESENCE && + exists $lc_exists_changed{$d})) { $reason = $d; last; } @@ -492,22 +490,22 @@ sub refresh () { next if $@ || ! defined $sub; my @candidates; - if ($depends{$p}{$d} == $IkiWiki::DEPEND_EXISTS) { - @candidates=@exists_changed; - } - else { + if ($depends_simple{$p}{$d} & $IkiWiki::DEPEND_CONTENT) { @candidates=@changed; } + elsif ($depends{$p}{$d} & $IkiWiki::DEPEND_PRESENCE) { + @candidates=@exists_changed; + } # only consider internal files # if the page explicitly depends # on such files if ($d =~ /internal\(/) { - if ($depends{$p}{$d} == $IkiWiki::DEPEND_EXISTS) { - push @candidates, @internal; - } - else { + if ($depends_simple{$p}{$d} & $IkiWiki::DEPEND_CONTENT) { push @candidates, @internal, @internal_change; } + elsif ($depends{$p}{$d} & $IkiWiki::DEPEND_PRESENCE) { + push @candidates, @internal; + } } foreach my $file (@candidates) { diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index c244c1f2f..73db6f12a 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -613,12 +613,15 @@ generating a link to a page. Makes the specified page depend on the specified [[ikiwiki/PageSpec]]. -Additional named parameters can be passed, to indicate what type of -dependency this is. - -Currently, only a "content" parameter is specified. If set to 0, the -dependency does not involve the content of pages matching the PageSpec, but -only their existence. +By default, dependencies are full content dependencies, meaning that the +page will be updated whenever anything matching the PageSpec is modified. +This default can be overridden by additional named parameters, which can be +used to indicate weaker types of dependencies: + +* `presence` if set to true, only the presence of a matching page triggers + the dependency. +* `links` if set to true, any change in the text of links on a matching page + triggers the dependency #### `pagespec_match($$;@)` diff --git a/ikiwiki-transition b/ikiwiki-transition index c50a748e8..1bebb1176 100755 --- a/ikiwiki-transition +++ b/ikiwiki-transition @@ -299,7 +299,7 @@ sub oldloadindex { $pagemtime{$page}=$items{mtime}[0]; $oldlinks{$page}=[@{$items{link}}]; $links{$page}=[@{$items{link}}]; - $depends{$page}={ $items{depends}[0] => $IkiWiki::DEPEND_CONTENT | $IkiWiki::DEPEND_EXISTS } if exists $items{depends}; + $depends{$page}={ $items{depends}[0] => $IkiWiki::DEPEND_CONTENT } if exists $items{depends}; $destsources{$_}=$page foreach @{$items{dest}}; $renderedfiles{$page}=[@{$items{dest}}]; $pagecase{lc $page}=$page; -- cgit v1.2.3 From 957ded9d64ca6abf0127c5c49e24177685bac5ae Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 7 Oct 2009 21:57:31 -0400 Subject: remove explicit addition of dependencies for displayed pages that hack is not needed, thanks to pagespec influences calculation --- IkiWiki/Plugin/calendar.pm | 5 ----- IkiWiki/Plugin/inline.pm | 6 ------ IkiWiki/Plugin/map.pm | 5 ----- 3 files changed, 16 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index a1117992a..ec8e232e1 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -213,11 +213,6 @@ EOF # Add dependencies to update the calendar whenever pages # matching the pagespec are added or removed. add_depends($params{page}, $params{pages}, presence => 1); - # Explicitly add all currently linked pages as dependencies, so - # that if they are removed, the calendar will be sure to be updated. - foreach my $p (@list) { - add_depends($params{page}, $p, presence => 1); - } return $calendar; } diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index cebd9037c..fc4e00a83 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -247,12 +247,6 @@ sub preprocess_inline (@) { @list=@list[0..$params{show} - 1]; } - # Explicitly add all currently displayed pages as dependencies, so - # that if they are removed, the inline will be sure to be updated. - foreach my $p ($#list >= $#feedlist ? @list : @feedlist) { - add_depends($params{page}, $p, presence => $quick); - } - if ($feeds && exists $params{feedpages}) { @feedlist=pagespec_match_list(\@feedlist, $params{feedpages}, location => $params{page}); } diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 625cfdfca..46f11dc89 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -71,11 +71,6 @@ sub preprocess (@) { # cases, when its content changes, if show= is specified), so # register a dependency. add_depends($params{page}, $params{pages}, presence => ! exists $params{show}); - # Explicitly add all currently shown pages, to detect when pages - # are removed. - foreach my $item (keys %mapitems) { - add_depends($params{page}, $item, presence => ! exists $params{show}); - } # Create the map. my $parent=""; -- cgit v1.2.3 From c57908b9d073500608d656adaf2bd3048c8cef67 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 8 Oct 2009 16:49:03 -0400 Subject: change how dependency types are specified to add_depends Also, this fixes 2 bugs in dependency info. --- IkiWiki/Plugin/brokenlinks.pm | 2 +- IkiWiki/Plugin/calendar.pm | 17 +++++++++-------- IkiWiki/Plugin/edittemplate.pm | 2 +- IkiWiki/Plugin/inline.pm | 7 ++++++- IkiWiki/Plugin/linkmap.pm | 2 +- IkiWiki/Plugin/listdirectives.pm | 2 +- IkiWiki/Plugin/map.pm | 3 ++- IkiWiki/Plugin/meta.pm | 2 +- IkiWiki/Plugin/orphans.pm | 4 ++-- IkiWiki/Plugin/pagecount.pm | 2 +- IkiWiki/Plugin/pagestats.pm | 4 ++-- IkiWiki/Plugin/postsparkline.pm | 2 +- IkiWiki/Plugin/progress.pm | 4 ++-- 13 files changed, 30 insertions(+), 23 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/brokenlinks.pm b/IkiWiki/Plugin/brokenlinks.pm index 9e65f52c6..62a0a42f4 100644 --- a/IkiWiki/Plugin/brokenlinks.pm +++ b/IkiWiki/Plugin/brokenlinks.pm @@ -24,7 +24,7 @@ sub preprocess (@) { $params{pages}="*" unless defined $params{pages}; # Needs to update whenever the links on a page change. - add_depends($params{page}, $params{pages}, links => 1); + add_depends($params{page}, $params{pages}, deptype("links")); my @broken; foreach my $link (keys %IkiWiki::brokenlinks) { diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index ec8e232e1..c99170f92 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -105,21 +105,21 @@ sub format_month (@) { linktext => " $monthname "); } add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month), - presence => 1); + deptype("presence")); if (exists $cache{$pagespec}{"$pyear/$pmonth"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/" . sprintf("%02d", $pmonth), linktext => " $pmonthname "); } add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth), - presence => 1); + deptype("presence")); if (exists $cache{$pagespec}{"$nyear/$nmonth"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/" . sprintf("%02d", $nmonth), linktext => " $nmonthname "); } add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth), - presence => 1); + deptype("presence")); # Start producing the month calendar $calendar=< 1); + add_depends($params{page}, $params{pages}, deptype("presence")); return $calendar; } @@ -244,19 +244,19 @@ sub format_year (@) { "$archivebase/$year", linktext => "$year"); } - add_depends($params{page}, "$archivebase/$year", presence => 1); + add_depends($params{page}, "$archivebase/$year", deptype("presence"); if (exists $cache{$pagespec}{"$pyear"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear", linktext => "\←"); } - add_depends($params{page}, "$archivebase/$pyear", presence => 1); + add_depends($params{page}, "$archivebase/$pyear", deptype("presence")); if (exists $cache{$pagespec}{"$nyear"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear", linktext => "\→"); } - add_depends($params{page}, "$archivebase/$nyear", presence => 1); + add_depends($params{page}, "$archivebase/$nyear", deptype("presence")); # Start producing the year calendar $calendar=<$monthabbr\n}; } - add_depends($params{page}, "$archivebase/$year/$mtag", presence => 1); + add_depends($params{page}, "$archivebase/$year/$mtag", + deptype("presence")); $calendar.=qq{\t\n} if ($month % $params{months_per_row} == 0); } diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 2dd1dbe68..7d2eba194 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -58,7 +58,7 @@ sub preprocess (@) { $pagestate{$params{page}}{edittemplate}{$params{match}}=$link; return "" if ($params{silent} && IkiWiki::yesno($params{silent})); - add_depends($params{page}, $link, presence => 1); + add_depends($params{page}, $link, deptype("presence")); return sprintf(gettext("edittemplate %s registered for %s"), htmllink($params{page}, $params{destpage}, $link), $params{match}); diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index fc4e00a83..be1781520 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -195,9 +195,14 @@ sub preprocess_inline (@) { @list = map { bestlink($params{page}, $_) } split ' ', $params{pagenames}; + + foreach my $p (@list) { + add_depends($params{page}, $p, deptype($quick ? "presence" : "content")); + } } else { - add_depends($params{page}, $params{pages}, presence => $quick); + add_depends($params{page}, $params{pages}, + deptype($quick ? "presence" : "content")); @list = pagespec_match_list( [ grep { $_ ne $params{page} } keys %pagesources ], diff --git a/IkiWiki/Plugin/linkmap.pm b/IkiWiki/Plugin/linkmap.pm index 3d20a6521..28e4cfa13 100644 --- a/IkiWiki/Plugin/linkmap.pm +++ b/IkiWiki/Plugin/linkmap.pm @@ -30,7 +30,7 @@ sub preprocess (@) { # Needs to update whenever a relevant page is added, or removed, or # its links change. - add_depends($params{page}, $params{pages}, presence => 1, links => 1); + add_depends($params{page}, $params{pages}, deptype("presence", "links")); # Can't just return the linkmap here, since the htmlscrubber # scrubs out all tags (with good reason!) diff --git a/IkiWiki/Plugin/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm index 4023ed7d7..09f08c567 100644 --- a/IkiWiki/Plugin/listdirectives.pm +++ b/IkiWiki/Plugin/listdirectives.pm @@ -84,7 +84,7 @@ sub preprocess (@) { foreach my $plugin (@pluginlist) { $result .= '
  • '; my $link=linkpage($config{directive_description_dir}."/".$plugin); - add_depends($params{page}, $link, presence => 1); + add_depends($params{page}, $link, deptype("presence")); $result .= htmllink($params{page}, $params{destpage}, $link); $result .= '
  • '; } diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 46f11dc89..19872e51c 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -70,7 +70,8 @@ sub preprocess (@) { # Needs to update whenever a page is added or removed (or in some # cases, when its content changes, if show= is specified), so # register a dependency. - add_depends($params{page}, $params{pages}, presence => ! exists $params{show}); + add_depends($params{page}, $params{pages}, + deptype(exists $params{show} ? "content" : "presence"); # Create the map. my $parent=""; diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index da3e62233..c675880b3 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -195,7 +195,7 @@ sub preprocess (@) { if (! length $link) { error gettext("redir page not found") } - add_depends($page, $link, presence => 1); + add_depends($page, $link, deptype("presence")); $value=urlto($link, $page); $value.='#'.$redir_anchor if defined $redir_anchor; diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index ae330b23b..93b8ec440 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -26,10 +26,10 @@ sub preprocess (@) { # Needs to update whenever a link changes, on any page # since any page could link to one of the pages we're # considering as orphans. - add_depends($params{page}, "*", links => 1); + add_depends($params{page}, "*", deptype("links")); # Also needs to update whenever potential orphans are added or # removed. - add_depends($params{page}, $params{pages}, presence => 1); + add_depends($params{page}, $params{pages}, deptype("presence")); my @orphans; foreach my $page (pagespec_match_list( diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm index 80561350b..419f2d535 100644 --- a/IkiWiki/Plugin/pagecount.pm +++ b/IkiWiki/Plugin/pagecount.pm @@ -24,7 +24,7 @@ sub preprocess (@) { # Needs to update count whenever a page is added or removed, so # register a presence dependency. - add_depends($params{page}, $params{pages}, presence => 1); + add_depends($params{page}, $params{pages}, deptype("presence")); my @pages; if ($params{pages} eq "*") { diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index afe4eeaf2..cd0bdb085 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -36,12 +36,12 @@ sub preprocess (@) { my $style = ($params{style} or 'cloud'); # Needs to update whenever a page is added or removed. - add_depends($params{page}, $params{pages}, exists => 1); + add_depends($params{page}, $params{pages}, deptype("presence")); # Also needs to update when any page with links changes, # in case the links point to our displayed pages. # (Among limits this further.) add_depends($params{page}, exists $params{among} ? $params{among} : "*", - links => 1); + deptype("links")); my %counts; my $max = 0; diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm index 3205958d4..ea73e9180 100644 --- a/IkiWiki/Plugin/postsparkline.pm +++ b/IkiWiki/Plugin/postsparkline.pm @@ -48,7 +48,7 @@ sub preprocess (@) { error gettext("unknown formula"); } - add_depends($params{page}, $params{pages}, presence => 1); + add_depends($params{page}, $params{pages}, deptype("presence")); my @list=sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} } pagespec_match_list( diff --git a/IkiWiki/Plugin/progress.pm b/IkiWiki/Plugin/progress.pm index 26c537a84..6da3e4f71 100644 --- a/IkiWiki/Plugin/progress.pm +++ b/IkiWiki/Plugin/progress.pm @@ -36,8 +36,8 @@ sub preprocess (@) { $fill.="%"; } elsif (defined $params{totalpages} and defined $params{donepages}) { - add_depends($params{page}, $params{totalpages}, presence => 1); - add_depends($params{page}, $params{donepages}, presence => 1); + add_depends($params{page}, $params{totalpages}, deptype("presence")); + add_depends($params{page}, $params{donepages}, deptype("presence")); my @pages=keys %pagesources; my $totalcount=0; -- cgit v1.2.3 From 332821144b33f42b3674240d28159124ee1a5334 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 8 Oct 2009 23:24:03 -0400 Subject: calendar: rework so it can use use_pagespec This was tricky because of the caching, and because use_pagespec always adds a dependency. That would have made year calendars depend on the whole pagespec, which is overly broad. So I removed the caching, format_month, and in format_year just look at %pagesources to see if month pages are available. In format_month, I make it always call use_pagespec, so each month calendar gets the right dependency and any influcences added. This means a bit more work, but the added work is fairly minimal, and presence dependencies remove a *lot* of work it used to do. (100% untested!) --- IkiWiki/Plugin/calendar.pm | 65 ++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 37 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index c99170f92..a89175cfb 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -24,8 +24,6 @@ use IkiWiki 3.00; use Time::Local; use POSIX; -my %cache; -my %linkcache; my $time=time; my @now=localtime($time); @@ -75,6 +73,23 @@ sub format_month (@) { my $pyear = $params{pyear}; my $nyear = $params{nyear}; + my %linkcache; + foreach my $p (use_pagespec($params{page}, $params{pagespec}, + # add presence dependencies to update + # month calendar when pages are added/removed + deptype => deptype("presence"))) { + my $mtime = $IkiWiki::pagectime{$p}; + my $src = $pagesources{$p}; + my @date = localtime($mtime); + my $mday = $date[3]; + my $month = $date[4] + 1; + my $year = $date[5] + 1900; + my $mtag = sprintf("%02d", $month); + + # Only one posting per day is being linked to. + $linkcache{"$year/$mtag/$mday"} = "$src"; + } + my @list; my $calendar="\n"; @@ -99,21 +114,21 @@ sub format_month (@) { # Calculate URL's for monthly archives. my ($url, $purl, $nurl)=("$monthname",'',''); - if (exists $cache{$pagespec}{"$year/$month"}) { + if (exists $pagesources{"$archivebase/$year/$month"}) { $url = htmllink($params{page}, $params{destpage}, "$archivebase/$year/".sprintf("%02d", $month), linktext => " $monthname "); } add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month), deptype("presence")); - if (exists $cache{$pagespec}{"$pyear/$pmonth"}) { + if (exists $pagesources{"$archivebase/$pyear/$pmonth"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/" . sprintf("%02d", $pmonth), linktext => " $pmonthname "); } add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth), deptype("presence")); - if (exists $cache{$pagespec}{"$nyear/$nmonth"}) { + if (exists $pagesources{"$archivebase/$nyear/$nmonth"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/" . sprintf("%02d", $nmonth), linktext => " $nmonthname "); @@ -173,7 +188,7 @@ EOF my $tag; my $mtag = sprintf("%02d", $month); - if (defined $cache{$pagespec}{"$year/$mtag/$day"}) { + if (defined $pagesources{"$archivebase/$year/$mtag/$day"}) { if ($day == $today) { $tag='month-calendar-day-this-day'; } @@ -210,10 +225,6 @@ EOF EOF - # Add dependencies to update the calendar whenever pages - # matching the pagespec are added or removed. - add_depends($params{page}, $params{pages}, deptype("presence")); - return $calendar; } @@ -239,19 +250,19 @@ sub format_year (@) { # calculate URL's for previous and next years my ($url, $purl, $nurl)=("$year",'',''); - if (exists $cache{$pagespec}{"$year"}) { + if (exists $pagesources{"$archivebase/$year"}) { $url = htmllink($params{page}, $params{destpage}, "$archivebase/$year", linktext => "$year"); } - add_depends($params{page}, "$archivebase/$year", deptype("presence"); - if (exists $cache{$pagespec}{"$pyear"}) { + add_depends($params{page}, "$archivebase/$year", deptype("presence")); + if (exists $pagesources{"$archivebase/$pyear"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear", linktext => "\←"); } add_depends($params{page}, "$archivebase/$pyear", deptype("presence")); - if (exists $cache{$pagespec}{"$nyear"}) { + if (exists $pagesources{"$archivebase/$nyear"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear", linktext => "\→"); @@ -280,14 +291,14 @@ EOF my $tag; my $mtag=sprintf("%02d", $month); if ($month == $params{month}) { - if ($cache{$pagespec}{"$year/$mtag"}) { + if ($pagesources{"$archivebase/$year/$mtag"}) { $tag = 'this_month_link'; } else { $tag = 'this_month_nolink'; } } - elsif ($cache{$pagespec}{"$year/$mtag"}) { + elsif ($pagesources{"$archivebase/$year/$mtag"}) { $tag = 'month_link'; } elsif ($future_month && $month >= $future_month) { @@ -297,7 +308,7 @@ EOF $tag = 'month_nolink'; } - if ($cache{$pagespec}{"$year/$mtag"}) { + if ($pagesources{"$archivebase/$year/$mtag"}) { $murl = htmllink($params{page}, $params{destpage}, "$archivebase/$year/$mtag", linktext => "$monthabbr"); @@ -366,26 +377,6 @@ sub preprocess (@) { $params{nyear} =$nyear; my $calendar="\n"; - my $pagespec=$params{pages}; - my $page =$params{page}; - - if (! defined $cache{$pagespec}) { - foreach my $p (pagespec_match_list([keys %pagesources], $pagespec)) { - my $mtime = $IkiWiki::pagectime{$p}; - my $src = $pagesources{$p}; - my @date = localtime($mtime); - my $mday = $date[3]; - my $month = $date[4] + 1; - my $year = $date[5] + 1900; - my $mtag = sprintf("%02d", $month); - - # Only one posting per day is being linked to. - $linkcache{"$year/$mtag/$mday"} = "$src"; - $cache{$pagespec}{"$year"}++; - $cache{$pagespec}{"$year/$mtag"}++; - $cache{$pagespec}{"$year/$mtag/$mday"}++; - } - } if ($params{type} =~ /month/i) { $calendar=format_month(%params); -- cgit v1.2.3 From 5e7b2dea84a35163b599b88efc02cd7ef3e0ad46 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 8 Oct 2009 23:51:06 -0400 Subject: rename use_pagespec to pagespec_match_list To avoid breaking plugins, also support the old pagespec_match_list calling convention, with a deprecation warning. --- IkiWiki.pm | 183 ++++++++++++++++++---------------------- IkiWiki/Plugin/calendar.pm | 2 +- IkiWiki/Plugin/inline.pm | 8 +- IkiWiki/Plugin/map.pm | 3 +- IkiWiki/Plugin/orphans.pm | 2 +- IkiWiki/Plugin/pagecount.pm | 2 +- IkiWiki/Plugin/pagestats.pm | 9 +- IkiWiki/Plugin/postsparkline.pm | 2 +- debian/changelog | 6 +- doc/plugins/write.mdwn | 24 ++---- t/pagespec_match_list.t | 31 +++++++ t/use_pagespec.t | 31 ------- 12 files changed, 140 insertions(+), 163 deletions(-) create mode 100755 t/pagespec_match_list.t delete mode 100755 t/use_pagespec.t (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index daa71059b..fd7e23524 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -17,7 +17,7 @@ use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase %forcerebuild %loaded_plugins}; use Exporter q{import}; -our @EXPORT = qw(hook debug error template htmlpage deptype use_pagespec +our @EXPORT = qw(hook debug error template htmlpage deptype add_depends pagespec_match pagespec_match_list bestlink htmllink readfile writefile pagetype srcfile pagename displaytime will_render gettext urlto targetpage @@ -1798,91 +1798,6 @@ sub add_depends ($$;$) { return 1; } -sub use_pagespec ($$;@) { - my $page=shift; - my $pagespec=shift; - my %params=@_; - - my $sub=pagespec_translate($pagespec); - error "syntax error in pagespec \"$pagespec\"" - if $@ || ! defined $sub; - - my @candidates; - if (exists $params{limit}) { - @candidates=grep { $params{limit}->($_) } keys %pagesources; - } - else { - @candidates=keys %pagesources; - } - - if (defined $params{sort}) { - my $f; - if ($params{sort} eq 'title') { - $f=sub { pagetitle(basename($a)) cmp pagetitle(basename($b)) }; - } - elsif ($params{sort} eq 'title_natural') { - eval q{use Sort::Naturally}; - if ($@) { - error(gettext("Sort::Naturally needed for title_natural sort")); - } - $f=sub { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) }; - } - elsif ($params{sort} eq 'mtime') { - $f=sub { $pagemtime{$b} <=> $pagemtime{$a} }; - } - elsif ($params{sort} eq 'age') { - $f=sub { $pagectime{$b} <=> $pagectime{$a} }; - } - else { - error sprintf(gettext("unknown sort type %s"), $params{sort}); - } - @candidates = sort { &$f } @candidates; - } - - @candidates=reverse(@candidates) if $params{reverse}; - - my @matches; - my $firstfail; - my $count=0; - foreach my $p (@candidates) { - my $r=$sub->($p, location => $page); - if ($r) { - push @matches, [$p, $r]; - last if defined $params{num} && ++$count == $params{num}; - } - elsif (! defined $firstfail) { - $firstfail=$r; - } - } - - $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT); - - my @ret; - if (@matches) { - # Add all influences from successful matches. - foreach my $m (@matches) { - push @ret, $m->[0]; - my %i=$m->[1]->influences; - foreach my $i (keys %i) { - $depends_simple{$page}{lc $i} |= $i{$i}; - } - } - } - elsif (defined $firstfail) { - # Add influences from one failure. (Which one should not - # matter; all should have the same influences.) - my %i=$firstfail->influences; - foreach my $i (keys %i) { - $depends_simple{$page}{lc $i} |= $i{$i}; - } - - error(sprintf(gettext("cannot match pages: %s"), $firstfail)) - if $firstfail->isa("IkiWiki::ErrorReason"); - } - - return @ret; -} - sub deptype (@) { my $deptype=0; foreach my $type (@_) { @@ -2055,27 +1970,95 @@ sub pagespec_match ($$;@) { } sub pagespec_match_list ($$;@) { - my $pages=shift; - my $spec=shift; - my @params=@_; + my $page=shift; + my $pagespec=shift; + my %params=@_; - my $sub=pagespec_translate($spec); - error "syntax error in pagespec \"$spec\"" + # Backwards compatability with old calling convention. + if (ref $page) { + print STDERR "warning: a plugin (".caller().") is using pagespec_match_list in an obsolete way, and needs to be updated\n"; + $params{list}=$page; + $page=$params{location}; # ugh! + } + + my $sub=pagespec_translate($pagespec); + error "syntax error in pagespec \"$pagespec\"" if $@ || ! defined $sub; + + my @candidates; + if (exists $params{limit}) { + @candidates=grep { $params{limit}->($_) } keys %pagesources; + } + else { + @candidates=keys %pagesources; + } + + if (defined $params{sort}) { + my $f; + if ($params{sort} eq 'title') { + $f=sub { pagetitle(basename($a)) cmp pagetitle(basename($b)) }; + } + elsif ($params{sort} eq 'title_natural') { + eval q{use Sort::Naturally}; + if ($@) { + error(gettext("Sort::Naturally needed for title_natural sort")); + } + $f=sub { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) }; + } + elsif ($params{sort} eq 'mtime') { + $f=sub { $pagemtime{$b} <=> $pagemtime{$a} }; + } + elsif ($params{sort} eq 'age') { + $f=sub { $pagectime{$b} <=> $pagectime{$a} }; + } + else { + error sprintf(gettext("unknown sort type %s"), $params{sort}); + } + @candidates = sort { &$f } @candidates; + } + + @candidates=reverse(@candidates) if $params{reverse}; - my @ret; - my $r; - foreach my $page (@$pages) { - $r=$sub->($page, @params); - push @ret, $page if $r; + my @matches; + my $firstfail; + my $count=0; + foreach my $p (@candidates) { + my $r=$sub->($p, location => $page); + if ($r) { + push @matches, [$p, $r]; + last if defined $params{num} && ++$count == $params{num}; + } + elsif (! defined $firstfail) { + $firstfail=$r; + } } + + $depends{$page}{$pagespec} |= ($params{deptype} || $DEPEND_CONTENT); - if (! @ret && defined $r && $r->isa("IkiWiki::ErrorReason")) { - error(sprintf(gettext("cannot match pages: %s"), $r)); + my @ret; + if (@matches) { + # Add all influences from successful matches. + foreach my $m (@matches) { + push @ret, $m->[0]; + my %i=$m->[1]->influences; + foreach my $i (keys %i) { + $depends_simple{$page}{lc $i} |= $i{$i}; + } + } } - else { - return @ret; + elsif (defined $firstfail) { + # Add influences from one failure. (Which one should not + # matter; all should have the same influences.) + my %i=$firstfail->influences; + foreach my $i (keys %i) { + $depends_simple{$page}{lc $i} |= $i{$i}; + } + + error(sprintf(gettext("cannot match pages: %s"), $firstfail)) + if $firstfail->isa("IkiWiki::ErrorReason"); } + + return @ret; } sub pagespec_valid ($) { diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index a89175cfb..c50d038df 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -74,7 +74,7 @@ sub format_month (@) { my $nyear = $params{nyear}; my %linkcache; - foreach my $p (use_pagespec($params{page}, $params{pagespec}, + foreach my $p (pagespec_match_list($params{page}, $params{pagespec}, # add presence dependencies to update # month calendar when pages are added/removed deptype => deptype("presence"))) { diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index c02137aed..815a37838 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -216,7 +216,7 @@ sub preprocess_inline (@) { $num+=$params{skip}; } - @list = use_pagespec($params{page}, $params{pages}, + @list = pagespec_match_list($params{page}, $params{pages}, deptype => deptype($quick ? "presence" : "content"), limit => sub { $_[0] ne $params{page} }, sort => exists $params{sort} ? $params{sort} : "age", @@ -245,9 +245,11 @@ sub preprocess_inline (@) { } if ($feeds && exists $params{feedpages}) { - @feedlist = use_pagespec($params{page}, "($params{pages}) and ($params{feedpages})", + @feedlist = pagespec_match_list( + $params{page}, "($params{pages}) and ($params{feedpages})", deptype => deptype($quick ? "presence" : "content"), - list => \@feedlist); + list => \@feedlist, + ); } my ($feedbase, $feednum); diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 634b0e4d6..788b96827 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -36,7 +36,8 @@ sub preprocess (@) { # Get all the items to map. my %mapitems; - foreach my $page (use_pagespec($params{page}, $params{pages}, deptype => $deptype)) { + foreach my $page (pagespec_match_list($params{page}, $params{pages}, + deptype => $deptype)) { if (exists $params{show} && exists $pagestate{$page} && exists $pagestate{$page}{meta}{$params{show}}) { diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index 607239500..b1ebd1b9d 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -28,7 +28,7 @@ sub preprocess (@) { # considering as orphans. add_depends($params{page}, "*", deptype("links")); - my @orphans=use_pagespec($params{page}, $params{pages}, + my @orphans=pagespec_match_list($params{page}, $params{pages}, # update when orphans are added/removed deptype => deptype("presence"), limit => sub { diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm index 40474b2a1..8d36f057e 100644 --- a/IkiWiki/Plugin/pagecount.pm +++ b/IkiWiki/Plugin/pagecount.pm @@ -32,7 +32,7 @@ sub preprocess (@) { return scalar keys %pagesources; } - return scalar use_pagespec($params{page}, $pages, + return scalar pagespec_match_list($params{page}, $pages, deptype => deptype("presence")); } diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index e64f7d9c3..47638210a 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -37,16 +37,17 @@ sub preprocess (@) { my %counts; my $max = 0; - foreach my $page (use_pagespec($params{page}, $params{pages}, - # update when a displayed page is added or removed - deptype => deptype("presence"))) { + foreach my $page (pagespec_match_list($params{page}, $params{pages}, + # update when a displayed page is added/removed + deptype => deptype("presence"))) { use IkiWiki::Render; my @backlinks = IkiWiki::backlink_pages($page); if (exists $params{among}) { # only consider backlinks from the amoung pages - @backlinks = use_pagespec($params{page}, $params{among}, + @backlinks = pagespec_match_list( + $params{page}, $params{among}, # update whenever links on those pages change deptype => deptype("links"), list => \@backlinks diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm index f51e309c8..1d4532366 100644 --- a/IkiWiki/Plugin/postsparkline.pm +++ b/IkiWiki/Plugin/postsparkline.pm @@ -54,7 +54,7 @@ sub preprocess (@) { } my @list=sort { $params{timehash}->{$b} <=> $params{timehash}->{$a} } - use_pagespec($params{page}, $params{pages}, + pagespec_match_list($params{page}, $params{pages}, deptype => $deptype, limit => sub { $_[0] ne $params{page} }, ); diff --git a/debian/changelog b/debian/changelog index 3a6fdf77d..49809e6cf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -33,9 +33,9 @@ ikiwiki (3.14159266) UNRELEASED; urgency=low info. * Plugins providing PageSpec `match_*` functions should pass additional influence information when creating result objects. - * Added `use_pagespec` function, that plugins can use to find a list - of matching pages and add dependencies and influences, all at once, - and efficiently. + * API change: `pagespec_match_list` has completly changed its interface. + The old interface will be removed soon, and a warning will be printed + if any plugins try to use it. * Optimize away most expensive file prune calls, when refreshing, by only checking new files. diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 62bebbeed..f6ea76c36 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -625,16 +625,16 @@ dependency type from one or more of these keywords: If multiple types are specified, they are combined. -#### `use_pagespec($$;@)` +#### `pagespec_match_list($$;@)` Passed a page name, and [[ikiwiki/PageSpec]], returns a list of pages in the wiki that match the [[ikiwiki/PageSpec]]. The page will automatically be made to depend on the specified [[ikiwiki/PageSpec]], so `add_depends` does not need to be called. This -is significantly more efficient than calling `add_depends` -followed by `pagespec_match_list`. You should use this anytime a plugin -needs to match a set of pages and generate something based on that list. +is significantly more efficient than calling `add_depends` and +`pagespec_match` in a loop. You should use this anytime a plugin +needs to match a set of pages and do something based on that list. Additional named parameters can be specified: @@ -650,6 +650,9 @@ Additional named parameters can be specified: * `list` makes it only match amoung the specified list of pages. Default is to match amoung all pages in the wiki. +Unlike pagespec_match, this may throw an error if there is an error in +the pagespec. + #### `add_depends($$;$)` Makes the specified page depend on the specified [[ikiwiki/PageSpec]]. @@ -672,19 +675,6 @@ The most often used is "location", which specifies the location the PageSpec should match against. If not passed, relative PageSpecs will match relative to the top of the wiki. -#### `pagespec_match_list($$;@)` - -Passed a reference to a list of page names, and [[ikiwiki/PageSpec]], -returns the set of pages that match the [[ikiwiki/PageSpec]]. - -Additional named parameters can be passed, to further limit the match. -The most often used is "location", which specifies the location the -PageSpec should match against. If not passed, relative PageSpecs will match -relative to the top of the wiki. - -Unlike pagespec_match, this may throw an error if there is an error in -the pagespec. - #### `bestlink($$)` Given a page and the text of a link on the page, determine which diff --git a/t/pagespec_match_list.t b/t/pagespec_match_list.t new file mode 100755 index 000000000..85a30b542 --- /dev/null +++ b/t/pagespec_match_list.t @@ -0,0 +1,31 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Test::More tests => 10; + +BEGIN { use_ok("IkiWiki"); } + +%pagesources=( + foo => "foo.mdwn", + bar => "bar.mdwn", + "post/1" => "post/1.mdwn", + "post/2" => "post/2.mdwn", + "post/3" => "post/3.mdwn", +); + +is_deeply([pagespec_match_list("foo", "bar")], ["bar"]); +is_deeply([sort(pagespec_match_list("foo", "post/*"))], ["post/1", "post/2", "post/3"]); +is_deeply([pagespec_match_list("foo", "post/*", sort => "title", reverse => 1)], + ["post/3", "post/2", "post/1"]); +is_deeply([pagespec_match_list("foo", "post/*", sort => "title", num => 2)], + ["post/1", "post/2"]); +is_deeply([pagespec_match_list("foo", "post/*", sort => "title", num => 50)], + ["post/1", "post/2", "post/3"]); +is_deeply([pagespec_match_list("foo", "post/*", sort => "title", + limit => sub { $_[0] !~ /3/}) ], + ["post/1", "post/2"]); +my $r=eval { pagespec_match_list("foo", "beep") }; +ok(eval { pagespec_match_list("foo", "beep") } == 0); +ok(! $@, "does not fail with error when unable to match anything"); +eval { pagespec_match_list("foo", "this is not a legal pagespec!") }; +ok($@, "fails with error when pagespec bad"); diff --git a/t/use_pagespec.t b/t/use_pagespec.t deleted file mode 100755 index 92d7977cf..000000000 --- a/t/use_pagespec.t +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/perl -use warnings; -use strict; -use Test::More tests => 10; - -BEGIN { use_ok("IkiWiki"); } - -%pagesources=( - foo => "foo.mdwn", - bar => "bar.mdwn", - "post/1" => "post/1.mdwn", - "post/2" => "post/2.mdwn", - "post/3" => "post/3.mdwn", -); - -is_deeply([use_pagespec("foo", "bar")], ["bar"]); -is_deeply([sort(use_pagespec("foo", "post/*"))], ["post/1", "post/2", "post/3"]); -is_deeply([use_pagespec("foo", "post/*", sort => "title", reverse => 1)], - ["post/3", "post/2", "post/1"]); -is_deeply([use_pagespec("foo", "post/*", sort => "title", num => 2)], - ["post/1", "post/2"]); -is_deeply([use_pagespec("foo", "post/*", sort => "title", num => 50)], - ["post/1", "post/2", "post/3"]); -is_deeply([use_pagespec("foo", "post/*", sort => "title", - limit => sub { $_[0] !~ /3/}) ], - ["post/1", "post/2"]); -my $r=eval { use_pagespec("foo", "beep") }; -ok(eval { use_pagespec("foo", "beep") } == 0); -ok(! $@, "does not fail with error when unable to match anything"); -eval { use_pagespec("foo", "this is not a legal pagespec!") }; -ok($@, "fails with error when pagespec bad"); -- cgit v1.2.3 From 71e266b939d72871f7efbc9c498dc9b472bdf9eb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 11 Oct 2009 20:15:54 -0400 Subject: avoid temporary variables and fix a bug in pagespec variable name --- IkiWiki/Plugin/calendar.pm | 118 ++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 70 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index c50d038df..fe7ee0361 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -65,16 +65,8 @@ sub month_days { sub format_month (@) { my %params=@_; - my $pagespec = $params{pages}; - my $year = $params{year}; - my $month = $params{month}; - my $pmonth = $params{pmonth}; - my $nmonth = $params{nmonth}; - my $pyear = $params{pyear}; - my $nyear = $params{nyear}; - my %linkcache; - foreach my $p (pagespec_match_list($params{page}, $params{pagespec}, + foreach my $p (pagespec_match_list($params{page}, $params{pages}, # add presence dependencies to update # month calendar when pages are added/removed deptype => deptype("presence"))) { @@ -94,19 +86,19 @@ sub format_month (@) { my $calendar="\n"; # When did this month start? - my @monthstart = localtime(timelocal(0,0,0,1,$month-1,$year-1900)); + my @monthstart = localtime(timelocal(0,0,0,1,$params{month}-1,$params{year}-1900)); my $future_dom = 0; my $today = 0; - if ($year == $now[5]+1900 && $month == $now[4]+1) { + if ($params{year} == $now[5]+1900 && $params{month} == $now[4]+1) { $future_dom = $now[3]+1; $today = $now[3]; } # Find out month names for this, next, and previous months my $monthname=POSIX::strftime("%B", @monthstart); - my $pmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900))); - my $nmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900))); + my $pmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$params{pmonth}-1,$params{pyear}-1900))); + my $nmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$params{nmonth}-1,$params{nyear}-1900))); my $archivebase = 'archives'; $archivebase = $config{archivebase} if defined $config{archivebase}; @@ -114,26 +106,26 @@ sub format_month (@) { # Calculate URL's for monthly archives. my ($url, $purl, $nurl)=("$monthname",'',''); - if (exists $pagesources{"$archivebase/$year/$month"}) { + if (exists $pagesources{"$archivebase/$params{year}/$params{month}"}) { $url = htmllink($params{page}, $params{destpage}, - "$archivebase/$year/".sprintf("%02d", $month), + "$archivebase/$params{year}/".sprintf("%02d", $params{month}), linktext => " $monthname "); } - add_depends($params{page}, "$archivebase/$year/".sprintf("%02d", $month), + add_depends($params{page}, "$archivebase/$params{year}/".sprintf("%02d", $params{month}), deptype("presence")); - if (exists $pagesources{"$archivebase/$pyear/$pmonth"}) { + if (exists $pagesources{"$archivebase/$params{pyear}/$params{pmonth}"}) { $purl = htmllink($params{page}, $params{destpage}, - "$archivebase/$pyear/" . sprintf("%02d", $pmonth), + "$archivebase/$params{pyear}/" . sprintf("%02d", $params{pmonth}), linktext => " $pmonthname "); } - add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth), + add_depends($params{page}, "$archivebase/$params{pyear}/".sprintf("%02d", $params{pmonth}), deptype("presence")); - if (exists $pagesources{"$archivebase/$nyear/$nmonth"}) { + if (exists $pagesources{"$archivebase/$params{nyear}/$params{nmonth}"}) { $nurl = htmllink($params{page}, $params{destpage}, - "$archivebase/$nyear/" . sprintf("%02d", $nmonth), + "$archivebase/$params{nyear}/" . sprintf("%02d", $params{nmonth}), linktext => " $nmonthname "); } - add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth), + add_depends($params{page}, "$archivebase/$params{nyear}/".sprintf("%02d", $params{nmonth}), deptype("presence")); # Start producing the month calendar @@ -155,7 +147,7 @@ EOF my %downame; my %dowabbr; for my $dow ($week_start_day..$week_start_day+6) { - my @day=localtime(timelocal(0,0,0,$start_day++,$month-1,$year-1900)); + my @day=localtime(timelocal(0,0,0,$start_day++,$params{month}-1,$params{year}-1900)); my $downame = POSIX::strftime("%A", @day); my $dowabbr = POSIX::strftime("%a", @day); $downame{$dow % 7}=$downame; @@ -176,7 +168,7 @@ EOF # At this point, either the first is a week_start_day, in which case # nothing has been printed, or else we are in the middle of a row. - for (my $day = 1; $day <= month_days(year => $year, month => $month); + for (my $day = 1; $day <= month_days(year => $params{year}, month => $params{month}); $day++, $wday++, $wday %= 7) { # At tihs point, on a week_start_day, we close out a row, # and start a new one -- unless it is week_start_day on the @@ -187,8 +179,8 @@ EOF } my $tag; - my $mtag = sprintf("%02d", $month); - if (defined $pagesources{"$archivebase/$year/$mtag/$day"}) { + my $mtag = sprintf("%02d", $params{month}); + if (defined $pagesources{"$archivebase/$params{year}/$mtag/$day"}) { if ($day == $today) { $tag='month-calendar-day-this-day'; } @@ -197,9 +189,9 @@ EOF } $calendar.=qq{\t\t}; $calendar.=htmllink($params{page}, $params{destpage}, - pagename($linkcache{"$year/$mtag/$day"}), + pagename($linkcache{"$params{year}/$mtag/$day"}), "linktext" => "$day"); - push @list, pagename($linkcache{"$year/$mtag/$day"}); + push @list, pagename($linkcache{"$params{year}/$mtag/$day"}); $calendar.=qq{\n}; } else { @@ -231,43 +223,35 @@ EOF sub format_year (@) { my %params=@_; - my $pagespec = $params{pages}; - my $year = $params{year}; - my $month = $params{month}; - my $pmonth = $params{pmonth}; - my $nmonth = $params{nmonth}; - my $pyear = $params{pyear}; - my $nyear = $params{nyear}; - my $calendar="\n"; my $future_month = 0; - $future_month = $now[4]+1 if ($year == $now[5]+1900); + $future_month = $now[4]+1 if ($params{year} == $now[5]+1900); my $archivebase = 'archives'; $archivebase = $config{archivebase} if defined $config{archivebase}; $archivebase = $params{archivebase} if defined $params{archivebase}; # calculate URL's for previous and next years - my ($url, $purl, $nurl)=("$year",'',''); - if (exists $pagesources{"$archivebase/$year"}) { + my ($url, $purl, $nurl)=("$params{year}",'',''); + if (exists $pagesources{"$archivebase/$params{year}"}) { $url = htmllink($params{page}, $params{destpage}, - "$archivebase/$year", - linktext => "$year"); + "$archivebase/$params{year}", + linktext => "$params{year}"); } - add_depends($params{page}, "$archivebase/$year", deptype("presence")); - if (exists $pagesources{"$archivebase/$pyear"}) { + add_depends($params{page}, "$archivebase/$params{year}", deptype("presence")); + if (exists $pagesources{"$archivebase/$params{pyear}"}) { $purl = htmllink($params{page}, $params{destpage}, - "$archivebase/$pyear", + "$archivebase/$params{pyear}", linktext => "\←"); } - add_depends($params{page}, "$archivebase/$pyear", deptype("presence")); - if (exists $pagesources{"$archivebase/$nyear"}) { + add_depends($params{page}, "$archivebase/$params{pyear}", deptype("presence")); + if (exists $pagesources{"$archivebase/$params{nyear}"}) { $nurl = htmllink($params{page}, $params{destpage}, - "$archivebase/$nyear", + "$archivebase/$params{nyear}", linktext => "\→"); } - add_depends($params{page}, "$archivebase/$nyear", deptype("presence")); + add_depends($params{page}, "$archivebase/$params{nyear}", deptype("presence")); # Start producing the year calendar $calendar=< EOF - for ($month = 1; $month <= 12; $month++) { - my @day=localtime(timelocal(0,0,0,15,$month-1,$year-1900)); + for (my $month = 1; $month <= 12; $month++) { + my @day=localtime(timelocal(0,0,0,15,$month-1,$params{year}-1900)); my $murl; my $monthname = POSIX::strftime("%B", @day); my $monthabbr = POSIX::strftime("%b", @day); @@ -291,14 +275,14 @@ EOF my $tag; my $mtag=sprintf("%02d", $month); if ($month == $params{month}) { - if ($pagesources{"$archivebase/$year/$mtag"}) { + if ($pagesources{"$archivebase/$params{year}/$mtag"}) { $tag = 'this_month_link'; } else { $tag = 'this_month_nolink'; } } - elsif ($pagesources{"$archivebase/$year/$mtag"}) { + elsif ($pagesources{"$archivebase/$params{year}/$mtag"}) { $tag = 'month_link'; } elsif ($future_month && $month >= $future_month) { @@ -308,9 +292,9 @@ EOF $tag = 'month_nolink'; } - if ($pagesources{"$archivebase/$year/$mtag"}) { + if ($pagesources{"$archivebase/$params{year}/$mtag"}) { $murl = htmllink($params{page}, $params{destpage}, - "$archivebase/$year/$mtag", + "$archivebase/$params{year}/$mtag", linktext => "$monthabbr"); $calendar.=qq{\t}; $calendar.=$murl; @@ -319,7 +303,7 @@ EOF else { $calendar.=qq{\t$monthabbr\n}; } - add_depends($params{page}, "$archivebase/$year/$mtag", + add_depends($params{page}, "$archivebase/$params{year}/$mtag", deptype("presence")); $calendar.=qq{\t\n} if ($month % $params{months_per_row} == 0); @@ -356,28 +340,22 @@ sub preprocess (@) { } # Calculate month names for next month, and previous months - my $pmonth = $params{month} - 1; - my $nmonth = $params{month} + 1; - my $pyear = $params{year} - 1; - my $nyear = $params{year} + 1; + $params{pmonth} = $params{month} - 1; + $params{nmonth} = $params{month} + 1; + $params{pyear} = $params{year} - 1; + $params{nyear} = $params{year} + 1; # Adjust for January and December if ($params{month} == 1) { - $pmonth = 12; - $pyear--; + $params{pmonth} = 12; + $params{pyear}--; } if ($params{month} == 12) { - $nmonth = 1; - $nyear++; + $params{nmonth} = 1; + $params{nyear}++; } - $params{pmonth}=$pmonth; - $params{nmonth}=$nmonth; - $params{pyear} =$pyear; - $params{nyear} =$nyear; - - my $calendar="\n"; - + my $calendar=""; if ($params{type} =~ /month/i) { $calendar=format_month(%params); } -- cgit v1.2.3 From dd80be66ee7d9a28e788efcc1b3eb62bbe8611dd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 11 Oct 2009 21:06:10 -0400 Subject: calendar: Fix midnight rebuild trigger of calendars with explicit month/year. It was just broken for calendars with an explicit month or year, not triggering at all. Now it will update those at appropriate times. --- IkiWiki/Plugin/calendar.pm | 42 +++++++++++++++++++++++++++++++++--------- debian/changelog | 2 ++ 2 files changed, 35 insertions(+), 9 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index fe7ee0361..9cbfd769d 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -318,24 +318,48 @@ EOF sub preprocess (@) { my %params=@_; + + my $thisyear=1900 + $now[5]; + my $thismonth=1 + $now[4]; + $params{pages} = "*" unless defined $params{pages}; $params{type} = "month" unless defined $params{type}; - $params{month} = sprintf("%02d", $params{month}) if defined $params{month}; $params{week_start_day} = 0 unless defined $params{week_start_day}; $params{months_per_row} = 3 unless defined $params{months_per_row}; - - if (! defined $params{year} || ! defined $params{month}) { - # Record that the calendar next changes at midnight. + $params{year} = $thisyear unless defined $params{year}; + $params{month} = $thismonth unless defined $params{month}; + + $params{month} = sprintf("%02d", $params{month}); + + if ($params{type} eq 'month' && $params{year} == $thisyear + && $params{month} == $thismonth) { + # calendar for current month, updates next midnight $pagestate{$params{destpage}}{calendar}{nextchange}=($time + (60 - $now[0]) # seconds + (59 - $now[1]) * 60 # minutes + (23 - $now[2]) * 60 * 60 # hours ); - - $params{year} = 1900 + $now[5] unless defined $params{year}; - $params{month} = 1 + $now[4] unless defined $params{month}; + } + elsif ($params{type} eq 'month' && + (($params{year} == $thisyear && $params{month} > $thismonth) || + $params{year} > $thisyear)) { + # calendar for upcoming month, updates 1st of that month + $pagestate{$params{destpage}}{calendar}{nextchange}= + timelocal(0, 0, 0, 1, $params{month}-1, $params{year}); + } + elsif ($params{type} eq 'year' && $params{year} == $thisyear) { + # calendar for current year, updates 1st of next month + $pagestate{$params{destpage}}{calendar}{nextchange}= + timelocal(0, 0, 0, 1, $thismonth+1-1, $params{year}); + } + elsif ($params{type} eq 'year' && $params{year} > $thisyear) { + # calendar for upcoming year, updates 1st of that year + $pagestate{$params{destpage}}{calendar}{nextchange}= + timelocal(0, 0, 0, 1, 1-1, $params{year}); } else { + # calendar for past month or year, does not need + # to update any more delete $pagestate{$params{destpage}}{calendar}; } @@ -356,10 +380,10 @@ sub preprocess (@) { } my $calendar=""; - if ($params{type} =~ /month/i) { + if ($params{type} eq 'month') { $calendar=format_month(%params); } - elsif ($params{type} =~ /year/i) { + elsif ($params{type} eq 'year') { $calendar=format_year(%params); } diff --git a/debian/changelog b/debian/changelog index 0e288dd08..c64758a77 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,8 @@ ikiwiki (3.2009XXXX) UNRELEASED; urgency=low * Transitive dependencies are now correctly supported. * ikiwiki-calendar: New command automates creation of archive pages using the calendar plugin. + * calendar: Fix midnight rebuild trigger of calendars with explicit + month/year. -- Joey Hess Fri, 09 Oct 2009 19:53:50 -0400 -- cgit v1.2.3 From f3342773d3a6c9da11c248c4cc385dca284add06 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 11 Oct 2009 21:42:59 -0400 Subject: calendar: Fix bug in next/previous year/month links, which sometimes linked to an archive page from the wrong year. --- IkiWiki/Plugin/calendar.pm | 63 ++++++++++++++++++++++++---------------------- debian/changelog | 2 ++ 2 files changed, 35 insertions(+), 30 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 9cbfd769d..5b4bfac89 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -81,6 +81,21 @@ sub format_month (@) { # Only one posting per day is being linked to. $linkcache{"$year/$mtag/$mday"} = "$src"; } + + my $pmonth = $params{month} - 1; + my $nmonth = $params{month} + 1; + my $pyear = $params{year}; + my $nyear = $params{year}; + + # Adjust for January and December + if ($params{month} == 1) { + $pmonth = 12; + $pyear--; + } + if ($params{month} == 12) { + $nmonth = 1; + $nyear++; + } my @list; my $calendar="\n"; @@ -97,8 +112,8 @@ sub format_month (@) { # Find out month names for this, next, and previous months my $monthname=POSIX::strftime("%B", @monthstart); - my $pmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$params{pmonth}-1,$params{pyear}-1900))); - my $nmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$params{nmonth}-1,$params{nyear}-1900))); + my $pmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900))); + my $nmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900))); my $archivebase = 'archives'; $archivebase = $config{archivebase} if defined $config{archivebase}; @@ -113,19 +128,19 @@ sub format_month (@) { } add_depends($params{page}, "$archivebase/$params{year}/".sprintf("%02d", $params{month}), deptype("presence")); - if (exists $pagesources{"$archivebase/$params{pyear}/$params{pmonth}"}) { + if (exists $pagesources{"$archivebase/$pyear/$pmonth"}) { $purl = htmllink($params{page}, $params{destpage}, - "$archivebase/$params{pyear}/" . sprintf("%02d", $params{pmonth}), + "$archivebase/$pyear/" . sprintf("%02d", $pmonth), linktext => " $pmonthname "); } - add_depends($params{page}, "$archivebase/$params{pyear}/".sprintf("%02d", $params{pmonth}), + add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth), deptype("presence")); - if (exists $pagesources{"$archivebase/$params{nyear}/$params{nmonth}"}) { + if (exists $pagesources{"$archivebase/$nyear/$nmonth"}) { $nurl = htmllink($params{page}, $params{destpage}, - "$archivebase/$params{nyear}/" . sprintf("%02d", $params{nmonth}), + "$archivebase/$nyear/" . sprintf("%02d", $nmonth), linktext => " $nmonthname "); } - add_depends($params{page}, "$archivebase/$params{nyear}/".sprintf("%02d", $params{nmonth}), + add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth), deptype("presence")); # Start producing the month calendar @@ -222,8 +237,11 @@ EOF sub format_year (@) { my %params=@_; - + my $calendar="\n"; + + my $pyear = $params{year} - 1; + my $nyear = $params{year} + 1; my $future_month = 0; $future_month = $now[4]+1 if ($params{year} == $now[5]+1900); @@ -240,18 +258,18 @@ sub format_year (@) { linktext => "$params{year}"); } add_depends($params{page}, "$archivebase/$params{year}", deptype("presence")); - if (exists $pagesources{"$archivebase/$params{pyear}"}) { + if (exists $pagesources{"$archivebase/$pyear"}) { $purl = htmllink($params{page}, $params{destpage}, - "$archivebase/$params{pyear}", + "$archivebase/$pyear", linktext => "\←"); } - add_depends($params{page}, "$archivebase/$params{pyear}", deptype("presence")); - if (exists $pagesources{"$archivebase/$params{nyear}"}) { + add_depends($params{page}, "$archivebase/$pyear", deptype("presence")); + if (exists $pagesources{"$archivebase/$nyear"}) { $nurl = htmllink($params{page}, $params{destpage}, - "$archivebase/$params{nyear}", + "$archivebase/$nyear", linktext => "\→"); } - add_depends($params{page}, "$archivebase/$params{nyear}", deptype("presence")); + add_depends($params{page}, "$archivebase/$nyear", deptype("presence")); # Start producing the year calendar $calendar=< Fri, 09 Oct 2009 19:53:50 -0400 -- cgit v1.2.3 From 8a37be35acb2c2c37d272489d2f2678e47c61834 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 11 Oct 2009 21:43:16 -0400 Subject: fix day links I broke this recently. --- IkiWiki/Plugin/calendar.pm | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 5b4bfac89..0266612ae 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -71,7 +71,6 @@ sub format_month (@) { # month calendar when pages are added/removed deptype => deptype("presence"))) { my $mtime = $IkiWiki::pagectime{$p}; - my $src = $pagesources{$p}; my @date = localtime($mtime); my $mday = $date[3]; my $month = $date[4] + 1; @@ -79,7 +78,7 @@ sub format_month (@) { my $mtag = sprintf("%02d", $month); # Only one posting per day is being linked to. - $linkcache{"$year/$mtag/$mday"} = "$src"; + $linkcache{"$year/$mtag/$mday"} = $p; } my $pmonth = $params{month} - 1; @@ -97,7 +96,6 @@ sub format_month (@) { $nyear++; } - my @list; my $calendar="\n"; # When did this month start? @@ -195,7 +193,7 @@ EOF my $tag; my $mtag = sprintf("%02d", $params{month}); - if (defined $pagesources{"$archivebase/$params{year}/$mtag/$day"}) { + if (defined $linkcache{"$params{year}/$mtag/$day"}) { if ($day == $today) { $tag='month-calendar-day-this-day'; } @@ -204,9 +202,8 @@ EOF } $calendar.=qq{\t\t}; $calendar.=htmllink($params{page}, $params{destpage}, - pagename($linkcache{"$params{year}/$mtag/$day"}), + $linkcache{"$params{year}/$mtag/$day"}, "linktext" => "$day"); - push @list, pagename($linkcache{"$params{year}/$mtag/$day"}); $calendar.=qq{\n}; } else { -- cgit v1.2.3 From 23a21850faf1cbb4bd8547b11563c5806617cf7e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 11 Oct 2009 21:52:50 -0400 Subject: fix next/prev month padding bug --- IkiWiki/Plugin/calendar.pm | 21 ++++++++++++--------- debian/changelog | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 0266612ae..cf133e8dc 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -96,6 +96,10 @@ sub format_month (@) { $nyear++; } + # Add padding. + $pmonth=sprintf("%02d", $pmonth); + $nmonth=sprintf("%02d", $nmonth); + my $calendar="\n"; # When did this month start? @@ -121,24 +125,24 @@ sub format_month (@) { my ($url, $purl, $nurl)=("$monthname",'',''); if (exists $pagesources{"$archivebase/$params{year}/$params{month}"}) { $url = htmllink($params{page}, $params{destpage}, - "$archivebase/$params{year}/".sprintf("%02d", $params{month}), + "$archivebase/$params{year}/".$params{month}, linktext => " $monthname "); } - add_depends($params{page}, "$archivebase/$params{year}/".sprintf("%02d", $params{month}), + add_depends($params{page}, "$archivebase/$params{year}/$params{month}", deptype("presence")); if (exists $pagesources{"$archivebase/$pyear/$pmonth"}) { $purl = htmllink($params{page}, $params{destpage}, - "$archivebase/$pyear/" . sprintf("%02d", $pmonth), + "$archivebase/$pyear/$pmonth", linktext => " $pmonthname "); } - add_depends($params{page}, "$archivebase/$pyear/".sprintf("%02d", $pmonth), + add_depends($params{page}, "$archivebase/$pyear/$pmonth", deptype("presence")); if (exists $pagesources{"$archivebase/$nyear/$nmonth"}) { $nurl = htmllink($params{page}, $params{destpage}, - "$archivebase/$nyear/" . sprintf("%02d", $nmonth), + "$archivebase/$nyear/$nmonth", linktext => " $nmonthname "); } - add_depends($params{page}, "$archivebase/$nyear/".sprintf("%02d", $nmonth), + add_depends($params{page}, "$archivebase/$nyear/$nmonth", deptype("presence")); # Start producing the month calendar @@ -192,8 +196,7 @@ EOF } my $tag; - my $mtag = sprintf("%02d", $params{month}); - if (defined $linkcache{"$params{year}/$mtag/$day"}) { + if (defined $linkcache{"$params{year}/$params{month}/$day"}) { if ($day == $today) { $tag='month-calendar-day-this-day'; } @@ -202,7 +205,7 @@ EOF } $calendar.=qq{\t\t}; $calendar.=htmllink($params{page}, $params{destpage}, - $linkcache{"$params{year}/$mtag/$day"}, + $linkcache{"$params{year}/$params{month}/$day"}, "linktext" => "$day"); $calendar.=qq{\n}; } diff --git a/debian/changelog b/debian/changelog index 8881c48aa..5c47b2524 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,7 +31,7 @@ ikiwiki (3.2009XXXX) UNRELEASED; urgency=low * calendar: Fix midnight rebuild trigger of calendars with explicit month/year. * calendar: Fix bug in next/previous year/month links, which sometimes - linked to an archive page from the wrong year. + linked to an archive page from the wrong year, or were missing. -- Joey Hess Fri, 09 Oct 2009 19:53:50 -0400 -- cgit v1.2.3 From cf74cf7a37a1fa4e02dffc6f3ac580626d183433 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 11 Oct 2009 21:55:06 -0400 Subject: calendar: use left and right arrows for next/prev months This is consistent with the year display, and I think it is less visually confusing than using the full month names. --- IkiWiki/Plugin/calendar.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index cf133e8dc..dcf2b6d64 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -133,14 +133,14 @@ sub format_month (@) { if (exists $pagesources{"$archivebase/$pyear/$pmonth"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/$pmonth", - linktext => " $pmonthname "); + linktext => " \&larr "); } add_depends($params{page}, "$archivebase/$pyear/$pmonth", deptype("presence")); if (exists $pagesources{"$archivebase/$nyear/$nmonth"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/$nmonth", - linktext => " $nmonthname "); + linktext => " \&rarr "); } add_depends($params{page}, "$archivebase/$nyear/$nmonth", deptype("presence")); -- cgit v1.2.3 From e4c765c64fc31ab13c911b716e80b07b4d1a0037 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 11 Oct 2009 22:11:11 -0400 Subject: calendar: avoid inline images in links --- IkiWiki/Plugin/calendar.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index dcf2b6d64..e3c5e2f2d 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -126,6 +126,7 @@ sub format_month (@) { if (exists $pagesources{"$archivebase/$params{year}/$params{month}"}) { $url = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}/".$params{month}, + noimageinline => 1, linktext => " $monthname "); } add_depends($params{page}, "$archivebase/$params{year}/$params{month}", @@ -133,6 +134,7 @@ sub format_month (@) { if (exists $pagesources{"$archivebase/$pyear/$pmonth"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/$pmonth", + noimageinline => 1, linktext => " \&larr "); } add_depends($params{page}, "$archivebase/$pyear/$pmonth", @@ -140,6 +142,7 @@ sub format_month (@) { if (exists $pagesources{"$archivebase/$nyear/$nmonth"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/$nmonth", + noimageinline => 1, linktext => " \&rarr "); } add_depends($params{page}, "$archivebase/$nyear/$nmonth", @@ -205,8 +208,9 @@ EOF } $calendar.=qq{\t\t}; $calendar.=htmllink($params{page}, $params{destpage}, - $linkcache{"$params{year}/$params{month}/$day"}, - "linktext" => "$day"); + $linkcache{"$params{year}/$params{month}/$day"}, + noimageinline => 1, + "linktext" => "$day"); $calendar.=qq{\n}; } else { @@ -255,18 +259,21 @@ sub format_year (@) { if (exists $pagesources{"$archivebase/$params{year}"}) { $url = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}", + noimageinline => 1, linktext => "$params{year}"); } add_depends($params{page}, "$archivebase/$params{year}", deptype("presence")); if (exists $pagesources{"$archivebase/$pyear"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear", + noimageinline => 1, linktext => "\←"); } add_depends($params{page}, "$archivebase/$pyear", deptype("presence")); if (exists $pagesources{"$archivebase/$nyear"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear", + noimageinline => 1, linktext => "\→"); } add_depends($params{page}, "$archivebase/$nyear", deptype("presence")); @@ -313,6 +320,7 @@ EOF if ($pagesources{"$archivebase/$params{year}/$mtag"}) { $murl = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}/$mtag", + noimageinline => 1, linktext => "$monthabbr"); $calendar.=qq{\t}; $calendar.=$murl; -- cgit v1.2.3 From 11e6d650eae4377485cb83f61a0ce9519ceb4c57 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 12 Oct 2009 12:19:42 -0400 Subject: calendar: Fix CSS for year calendar to match the plugin documentation. The names in the documentation were completly different, but also seemed better chosen than the names in the code. --- IkiWiki/Plugin/calendar.pm | 13 ++++--------- debian/changelog | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index e3c5e2f2d..71c671d67 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -300,21 +300,16 @@ EOF my $tag; my $mtag=sprintf("%02d", $month); if ($month == $params{month}) { - if ($pagesources{"$archivebase/$params{year}/$mtag"}) { - $tag = 'this_month_link'; - } - else { - $tag = 'this_month_nolink'; - } + $tag = 'year-calendar-this-month'; } elsif ($pagesources{"$archivebase/$params{year}/$mtag"}) { - $tag = 'month_link'; + $tag = 'year-calendar-month-link'; } elsif ($future_month && $month >= $future_month) { - $tag = 'month_future'; + $tag = 'year-calendar-month-future'; } else { - $tag = 'month_nolink'; + $tag = 'year-calendar-month-nolink'; } if ($pagesources{"$archivebase/$params{year}/$mtag"}) { diff --git a/debian/changelog b/debian/changelog index e9f09a8c6..b9d1923cd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -34,6 +34,7 @@ ikiwiki (3.2009XXXX) UNRELEASED; urgency=low linked to an archive page from the wrong year, or were missing. * git: --getctime will now follow renames back to the original creation of a file. + * calendar: Fix CSS for year calendar to match the plugin documentation. -- Joey Hess Fri, 09 Oct 2009 19:53:50 -0400 -- cgit v1.2.3 From 227540fd875bfaa6b810c0d7caa346f32d5bd7ce Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 12 Oct 2009 12:30:10 -0400 Subject: calendar: Add creation time limits to user's pagespec This avoids all calendars rebuilding when a new page is added that will only show in one of them. --- IkiWiki/Plugin/calendar.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 71c671d67..5aac95884 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -66,7 +66,8 @@ sub format_month (@) { my %params=@_; my %linkcache; - foreach my $p (pagespec_match_list($params{page}, $params{pages}, + foreach my $p (pagespec_match_list($params{page}, + "creation_year($params{year}) and creation_month($params{month}) and ($params{pages})", # add presence dependencies to update # month calendar when pages are added/removed deptype => deptype("presence"))) { -- cgit v1.2.3 From 22737e53f1b0367bc9bfb8d7bcbfc4dcc08a81ae Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 12 Oct 2009 14:05:56 -0400 Subject: remove whitespace from within arrow links --- IkiWiki/Plugin/calendar.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 5aac95884..d5a80795a 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -136,7 +136,7 @@ sub format_month (@) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/$pmonth", noimageinline => 1, - linktext => " \&larr "); + linktext => "\&larr"); } add_depends($params{page}, "$archivebase/$pyear/$pmonth", deptype("presence")); @@ -144,7 +144,7 @@ sub format_month (@) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/$nmonth", noimageinline => 1, - linktext => " \&rarr "); + linktext => "\&rarr"); } add_depends($params{page}, "$archivebase/$nyear/$nmonth", deptype("presence")); -- cgit v1.2.3 From 5c78192435210cdb7792ed56b04c2ef24a2d2127 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 12 Oct 2009 14:19:04 -0400 Subject: 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(-) (limited to 'IkiWiki/Plugin/calendar.pm') 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, -- cgit v1.2.3 From 28c4caea59543b6d8fd0c62ff5a60aff67a9bba7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 12 Oct 2009 14:22:48 -0400 Subject: year calendar: Avoid highlighting the current month in a different year --- IkiWiki/Plugin/calendar.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index ddcd1a823..c9bdf4a17 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -262,8 +262,9 @@ sub format_year (@) { my $pyear = $params{year} - 1; my $nyear = $params{year} + 1; + my $thisyear = $now[5]+1900; my $future_month = 0; - $future_month = $now[4]+1 if ($params{year} == $now[5]+1900); + $future_month = $now[4]+1 if $params{year} == $thisyear; my $archivebase = 'archives'; $archivebase = $config{archivebase} if defined $config{archivebase}; @@ -314,7 +315,7 @@ EOF $calendar.=qq{\t\n} if ($month % $params{months_per_row} == 1); my $tag; my $mtag=sprintf("%02d", $month); - if ($month == $params{month}) { + if ($month == $params{month} && $thisyear == $params{year}) { $tag = 'year-calendar-this-month'; } elsif ($pagesources{"$archivebase/$params{year}/$mtag"}) { -- cgit v1.2.3 From 2255a6a0bba10eece24304f64ec8329068e8bf07 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 26 Nov 2009 14:57:52 -0500 Subject: calendar: Add title attributes for all links in the calendars. --- IkiWiki.pm | 2 +- IkiWiki/Plugin/calendar.pm | 33 +++++++++++++++++++++------------ debian/changelog | 1 + 3 files changed, 23 insertions(+), 13 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index 611ba6f65..99d5724eb 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1083,7 +1083,7 @@ sub htmllink ($$$;@) { my @attrs; foreach my $attr (qw{rel class title}) { if (defined $opts{$attr}) { - push @attrs, " $attr=\"".$opts{attr}.'"'; + push @attrs, " $attr=\"$opts{$attr}\""; } } diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index c9bdf4a17..cbbb57e98 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -128,7 +128,8 @@ sub format_month (@) { $url = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}/".$params{month}, noimageinline => 1, - linktext => " $monthname "); + linktext => $monthname, + title => $monthname); } add_depends($params{page}, "$archivebase/$params{year}/$params{month}", deptype("presence")); @@ -136,7 +137,8 @@ sub format_month (@) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/$pmonth", noimageinline => 1, - linktext => "\&larr"); + linktext => "\&larr", + title => $pmonthname); } add_depends($params{page}, "$archivebase/$pyear/$pmonth", deptype("presence")); @@ -144,7 +146,8 @@ sub format_month (@) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/$nmonth", noimageinline => 1, - linktext => "\&rarr"); + linktext => "\&rarr", + title => $nmonthname); } add_depends($params{page}, "$archivebase/$nyear/$nmonth", deptype("presence")); @@ -173,7 +176,7 @@ EOF my $dowabbr = POSIX::strftime("%a", @day); $downame{$dow % 7}=$downame; $dowabbr{$dow % 7}=$dowabbr; - $calendar.= qq{\t\t$dowabbr\n}; + $calendar.= qq{\t\t$dowabbr\n}; } $calendar.=< $params{year}, month => $params{month}); $day++, $wday++, $wday %= 7) { - # At tihs point, on a week_start_day, we close out a row, + # At this point, on a week_start_day, we close out a row, # and start a new one -- unless it is week_start_day on the # first, where we do not close a row -- since none was started. if ($wday == $week_start_day) { @@ -200,7 +203,8 @@ EOF } my $tag; - if (defined $linkcache{"$params{year}/$params{month}/$day"}) { + my $key="$params{year}/$params{month}/$day"; + if (defined $linkcache{$key}) { if ($day == $today) { $tag='month-calendar-day-this-day'; } @@ -209,9 +213,10 @@ EOF } $calendar.=qq{\t\t}; $calendar.=htmllink($params{page}, $params{destpage}, - $linkcache{"$params{year}/$params{month}/$day"}, + $linkcache{$key}, noimageinline => 1, - "linktext" => "$day"); + linktext => $day, + title => pagetitle(IkiWiki::basename($linkcache{$key}))); $calendar.=qq{\n}; } else { @@ -276,21 +281,24 @@ sub format_year (@) { $url = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}", noimageinline => 1, - linktext => "$params{year}"); + linktext => $params{year}, + title => $params{year}); } add_depends($params{page}, "$archivebase/$params{year}", deptype("presence")); if (exists $pagesources{"$archivebase/$pyear"}) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear", noimageinline => 1, - linktext => "\←"); + linktext => "\←", + title => $pyear); } add_depends($params{page}, "$archivebase/$pyear", deptype("presence")); if (exists $pagesources{"$archivebase/$nyear"}) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear", noimageinline => 1, - linktext => "\→"); + linktext => "\→", + title => $nyear); } add_depends($params{page}, "$archivebase/$nyear", deptype("presence")); @@ -333,7 +341,8 @@ EOF $murl = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}/$mtag", noimageinline => 1, - linktext => "$monthabbr"); + linktext => $monthabbr, + title => $monthname); $calendar.=qq{\t}; $calendar.=$murl; $calendar.=qq{\t\n}; diff --git a/debian/changelog b/debian/changelog index e31928223..2b468ca2f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,7 @@ ikiwiki (3.20091114) UNRELEASED; urgency=low pretty-printed dates, using the same formatting as used for page modification date display, etc. * htmllink: Allow a title attribute to be specified. + * calendar: Add title attributes for all links in the calendars. -- Joey Hess Mon, 16 Nov 2009 15:46:45 -0500 -- cgit v1.2.3 From f02f806cf70ed19c9e9aa70e232ca46398b3538a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 2 Dec 2009 12:58:45 -0500 Subject: calendar: Fix month wraparound error that broke in December. --- IkiWiki/Plugin/calendar.pm | 10 ++++++++-- debian/changelog | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index cbbb57e98..77fd50827 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -396,8 +396,14 @@ sub preprocess (@) { } elsif ($params{type} eq 'year' && $params{year} == $thisyear) { # calendar for current year, updates 1st of next month - $pagestate{$params{destpage}}{calendar}{nextchange}= - timelocal(0, 0, 0, 1, $thismonth+1-1, $params{year}); + if ($thismonth < 12) { + $pagestate{$params{destpage}}{calendar}{nextchange}= + timelocal(0, 0, 0, 1, $thismonth+1-1, $params{year}); + } + else { + $pagestate{$params{destpage}}{calendar}{nextchange}= + timelocal(0, 0, 0, 1, 1-1, $params{year}+1); + } } elsif ($params{type} eq 'year' && $params{year} > $thisyear) { # calendar for upcoming year, updates 1st of that year diff --git a/debian/changelog b/debian/changelog index 2b468ca2f..3afe89b59 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,7 @@ ikiwiki (3.20091114) UNRELEASED; urgency=low modification date display, etc. * htmllink: Allow a title attribute to be specified. * calendar: Add title attributes for all links in the calendars. + * calendar: Fix month wraparound error that broke in December. -- Joey Hess Mon, 16 Nov 2009 15:46:45 -0500 -- cgit v1.2.3 From 59277c9b6b6461d7097db12b1ed06c1a6a58ec17 Mon Sep 17 00:00:00 2001 From: Torsten Veller Date: Sat, 2 Jan 2010 19:22:25 +0100 Subject: Terminate the arrow entities with ";" --- IkiWiki/Plugin/calendar.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 77fd50827..2b87451ce 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -137,7 +137,7 @@ sub format_month (@) { $purl = htmllink($params{page}, $params{destpage}, "$archivebase/$pyear/$pmonth", noimageinline => 1, - linktext => "\&larr", + linktext => "\←", title => $pmonthname); } add_depends($params{page}, "$archivebase/$pyear/$pmonth", @@ -146,7 +146,7 @@ sub format_month (@) { $nurl = htmllink($params{page}, $params{destpage}, "$archivebase/$nyear/$nmonth", noimageinline => 1, - linktext => "\&rarr", + linktext => "\→", title => $nmonthname); } add_depends($params{page}, "$archivebase/$nyear/$nmonth", -- cgit v1.2.3 From 34fff64e7b56f4f8cd99430f9f927d2a5d1e3619 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Feb 2010 06:35:52 -0500 Subject: setup file ordering --- IkiWiki/Plugin/aggregate.pm | 1 - IkiWiki/Plugin/amazon_s3.pm | 1 - IkiWiki/Plugin/autoindex.pm | 1 - IkiWiki/Plugin/calendar.pm | 1 + IkiWiki/Plugin/color.pm | 1 + IkiWiki/Plugin/conditional.pm | 2 +- IkiWiki/Plugin/cutpaste.pm | 1 + IkiWiki/Plugin/date.pm | 1 + IkiWiki/Plugin/format.pm | 1 + IkiWiki/Plugin/fortune.pm | 1 + IkiWiki/Plugin/graphviz.pm | 1 + IkiWiki/Plugin/haiku.pm | 1 + IkiWiki/Plugin/img.pm | 1 + IkiWiki/Plugin/linkmap.pm | 1 + IkiWiki/Plugin/listdirectives.pm | 1 + IkiWiki/Plugin/map.pm | 1 + IkiWiki/Plugin/more.pm | 1 + IkiWiki/Plugin/orphans.pm | 1 + IkiWiki/Plugin/pagecount.pm | 1 + IkiWiki/Plugin/pagestats.pm | 1 + IkiWiki/Plugin/pingee.pm | 1 - IkiWiki/Plugin/pinger.pm | 1 - IkiWiki/Plugin/poll.pm | 1 + IkiWiki/Plugin/polygen.pm | 1 + IkiWiki/Plugin/postsparkline.pm | 1 + IkiWiki/Plugin/progress.pm | 1 + IkiWiki/Plugin/recentchanges.pm | 1 - IkiWiki/Plugin/rsync.pm | 1 - IkiWiki/Plugin/shortcut.pm | 1 + IkiWiki/Plugin/sparkline.pm | 1 + IkiWiki/Plugin/table.pm | 1 + IkiWiki/Plugin/template.pm | 1 + IkiWiki/Plugin/testpagespec.pm | 1 - IkiWiki/Plugin/teximg.pm | 1 + IkiWiki/Plugin/toc.pm | 1 + IkiWiki/Plugin/toggle.pm | 1 + IkiWiki/Plugin/underlay.pm | 1 - IkiWiki/Plugin/version.pm | 1 + IkiWiki/Setup.pm | 4 +++- 39 files changed, 32 insertions(+), 11 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index c18d413e6..5a9eb433d 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -43,7 +43,6 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, - section => "special-purpose", }, aggregateinternal => { type => "boolean", diff --git a/IkiWiki/Plugin/amazon_s3.pm b/IkiWiki/Plugin/amazon_s3.pm index f2f4dbcf2..cfd8cd347 100644 --- a/IkiWiki/Plugin/amazon_s3.pm +++ b/IkiWiki/Plugin/amazon_s3.pm @@ -45,7 +45,6 @@ sub getsetup () { plugin => { safe => 0, rebuild => 0, - section => "special-purpose", }, amazon_s3_key_id => { type => "string", diff --git a/IkiWiki/Plugin/autoindex.pm b/IkiWiki/Plugin/autoindex.pm index e50464dca..555856b11 100644 --- a/IkiWiki/Plugin/autoindex.pm +++ b/IkiWiki/Plugin/autoindex.pm @@ -16,7 +16,6 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, - section => "special-purpose", }, } diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 2b87451ce..aaee2c610 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -38,6 +38,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, archivebase => { type => "string", diff --git a/IkiWiki/Plugin/color.pm b/IkiWiki/Plugin/color.pm index b9407ba28..d550dd9f4 100644 --- a/IkiWiki/Plugin/color.pm +++ b/IkiWiki/Plugin/color.pm @@ -18,6 +18,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm index beeddc672..892b1cff9 100644 --- a/IkiWiki/Plugin/conditional.pm +++ b/IkiWiki/Plugin/conditional.pm @@ -16,7 +16,7 @@ sub getsetup { plugin => { safe => 1, rebuild => undef, - section => "core", + section => "widget", }, } diff --git a/IkiWiki/Plugin/cutpaste.pm b/IkiWiki/Plugin/cutpaste.pm index 417442f34..01e9ce043 100644 --- a/IkiWiki/Plugin/cutpaste.pm +++ b/IkiWiki/Plugin/cutpaste.pm @@ -19,6 +19,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/date.pm b/IkiWiki/Plugin/date.pm index 652e6df0a..ea5c9a9c5 100644 --- a/IkiWiki/Plugin/date.pm +++ b/IkiWiki/Plugin/date.pm @@ -15,6 +15,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/format.pm b/IkiWiki/Plugin/format.pm index c8041209f..d54e71131 100644 --- a/IkiWiki/Plugin/format.pm +++ b/IkiWiki/Plugin/format.pm @@ -15,6 +15,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/fortune.pm b/IkiWiki/Plugin/fortune.pm index 17e57dea1..f481c7eac 100644 --- a/IkiWiki/Plugin/fortune.pm +++ b/IkiWiki/Plugin/fortune.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/graphviz.pm b/IkiWiki/Plugin/graphviz.pm index 32e994d6b..bec122076 100644 --- a/IkiWiki/Plugin/graphviz.pm +++ b/IkiWiki/Plugin/graphviz.pm @@ -18,6 +18,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/haiku.pm b/IkiWiki/Plugin/haiku.pm index 5a062a276..bf23dce67 100644 --- a/IkiWiki/Plugin/haiku.pm +++ b/IkiWiki/Plugin/haiku.pm @@ -16,6 +16,7 @@ sub getsetup { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 82db15a7e..f06121578 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -19,6 +19,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/linkmap.pm b/IkiWiki/Plugin/linkmap.pm index 68eb6c8c6..ac26e072e 100644 --- a/IkiWiki/Plugin/linkmap.pm +++ b/IkiWiki/Plugin/linkmap.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm index 09f08c567..8a67f7160 100644 --- a/IkiWiki/Plugin/listdirectives.pm +++ b/IkiWiki/Plugin/listdirectives.pm @@ -19,6 +19,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, directive_description_dir => { type => "string", diff --git a/IkiWiki/Plugin/map.pm b/IkiWiki/Plugin/map.pm index 788b96827..ce3ac1d24 100644 --- a/IkiWiki/Plugin/map.pm +++ b/IkiWiki/Plugin/map.pm @@ -21,6 +21,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/more.pm b/IkiWiki/Plugin/more.pm index 77d5fb077..266c8e1d0 100644 --- a/IkiWiki/Plugin/more.pm +++ b/IkiWiki/Plugin/more.pm @@ -17,6 +17,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/orphans.pm b/IkiWiki/Plugin/orphans.pm index 702943f87..e3cc3c940 100644 --- a/IkiWiki/Plugin/orphans.pm +++ b/IkiWiki/Plugin/orphans.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm index 8d36f057e..dd5de3c83 100644 --- a/IkiWiki/Plugin/pagecount.pm +++ b/IkiWiki/Plugin/pagecount.pm @@ -15,6 +15,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index 4313aa271..1c0b46830 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -27,6 +27,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/pingee.pm b/IkiWiki/Plugin/pingee.pm index aafce9e70..f5386d0ca 100644 --- a/IkiWiki/Plugin/pingee.pm +++ b/IkiWiki/Plugin/pingee.pm @@ -15,7 +15,6 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, - section => "special-purpose", }, } diff --git a/IkiWiki/Plugin/pinger.pm b/IkiWiki/Plugin/pinger.pm index a797fc7bd..c20ecb5d4 100644 --- a/IkiWiki/Plugin/pinger.pm +++ b/IkiWiki/Plugin/pinger.pm @@ -21,7 +21,6 @@ sub getsetup () { plugin => { safe => 1, rebuild => 0, - section => "special-purpose", }, pinger_timeout => { type => "integer", diff --git a/IkiWiki/Plugin/poll.pm b/IkiWiki/Plugin/poll.pm index bc1e3501e..6bc4579c2 100644 --- a/IkiWiki/Plugin/poll.pm +++ b/IkiWiki/Plugin/poll.pm @@ -17,6 +17,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/polygen.pm b/IkiWiki/Plugin/polygen.pm index bc21d71c7..78e3611e1 100644 --- a/IkiWiki/Plugin/polygen.pm +++ b/IkiWiki/Plugin/polygen.pm @@ -20,6 +20,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/postsparkline.pm b/IkiWiki/Plugin/postsparkline.pm index 0d5a12e33..2fae9c5fe 100644 --- a/IkiWiki/Plugin/postsparkline.pm +++ b/IkiWiki/Plugin/postsparkline.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/progress.pm b/IkiWiki/Plugin/progress.pm index fe64b40b1..d27df5ca8 100644 --- a/IkiWiki/Plugin/progress.pm +++ b/IkiWiki/Plugin/progress.pm @@ -18,6 +18,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 04219b721..5c7b71aaa 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -22,7 +22,6 @@ sub getsetup () { plugin => { safe => 1, rebuild => 1, - section => "core", }, recentchangespage => { type => "string", diff --git a/IkiWiki/Plugin/rsync.pm b/IkiWiki/Plugin/rsync.pm index 8dd983be7..e38801e4a 100644 --- a/IkiWiki/Plugin/rsync.pm +++ b/IkiWiki/Plugin/rsync.pm @@ -16,7 +16,6 @@ sub getsetup () { plugin => { safe => 0, rebuild => 0, - section => "special-purpose", }, rsync_command => { type => "string", diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm index 1840a5722..0cedbe447 100644 --- a/IkiWiki/Plugin/shortcut.pm +++ b/IkiWiki/Plugin/shortcut.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/sparkline.pm b/IkiWiki/Plugin/sparkline.pm index fb4849492..42665ac63 100644 --- a/IkiWiki/Plugin/sparkline.pm +++ b/IkiWiki/Plugin/sparkline.pm @@ -24,6 +24,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm index 96d63f455..2edd1eacd 100644 --- a/IkiWiki/Plugin/table.pm +++ b/IkiWiki/Plugin/table.pm @@ -16,6 +16,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index 39d9667f9..3e024c5f8 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -19,6 +19,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/testpagespec.pm b/IkiWiki/Plugin/testpagespec.pm index 17a77cb69..440fca33b 100644 --- a/IkiWiki/Plugin/testpagespec.pm +++ b/IkiWiki/Plugin/testpagespec.pm @@ -15,7 +15,6 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, - section => "special-purpose", }, } diff --git a/IkiWiki/Plugin/teximg.pm b/IkiWiki/Plugin/teximg.pm index f92ed0132..0aaa79698 100644 --- a/IkiWiki/Plugin/teximg.pm +++ b/IkiWiki/Plugin/teximg.pm @@ -31,6 +31,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, teximg_dvipng => { type => "boolean", diff --git a/IkiWiki/Plugin/toc.pm b/IkiWiki/Plugin/toc.pm index b8537d3eb..ac07b9af6 100644 --- a/IkiWiki/Plugin/toc.pm +++ b/IkiWiki/Plugin/toc.pm @@ -18,6 +18,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm index ef066a42f..f9c899540 100644 --- a/IkiWiki/Plugin/toggle.pm +++ b/IkiWiki/Plugin/toggle.pm @@ -20,6 +20,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Plugin/underlay.pm b/IkiWiki/Plugin/underlay.pm index ab74fc37e..116fe7324 100644 --- a/IkiWiki/Plugin/underlay.pm +++ b/IkiWiki/Plugin/underlay.pm @@ -18,7 +18,6 @@ sub getsetup () { plugin => { safe => 0, rebuild => undef, - section => "special-purpose", }, add_underlays => { type => "string", diff --git a/IkiWiki/Plugin/version.pm b/IkiWiki/Plugin/version.pm index 587cd55fa..c13643478 100644 --- a/IkiWiki/Plugin/version.pm +++ b/IkiWiki/Plugin/version.pm @@ -17,6 +17,7 @@ sub getsetup () { plugin => { safe => 1, rebuild => undef, + section => "widget", }, } diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm index 7a7683fab..a3fd5ce66 100644 --- a/IkiWiki/Setup.pm +++ b/IkiWiki/Setup.pm @@ -121,9 +121,11 @@ sub getsetup () { $config{syslog}=$syslog; return map { sort { $a->[0] cmp $b->[0] } @{$sections{$_}} } - sort { # core first, then alphabetical + sort { # core first, other last, otherwise alphabetical ($b eq "core") <=> ($a eq "core") || + ($a eq "other") <=> ($b eq "other") + || $a cmp $b } keys %sections; } -- cgit v1.2.3 From cbf269eee29a66e1350e5553f38eee5b4683be8a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 19 Mar 2010 13:10:17 -0400 Subject: audited use POSIX The POSIX perl module exports a huge number of functions by default, so make sure all imports are qualified. (And remove one that was not necessary.) --- IkiWiki.pm | 2 +- IkiWiki/Plugin/calendar.pm | 2 +- IkiWiki/Plugin/relativedate.pm | 2 +- IkiWiki/Plugin/wmd.pm | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki.pm b/IkiWiki.pm index a618836cf..6e333504e 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -7,7 +7,7 @@ use strict; use Encode; use HTML::Entities; use URI::Escape q{uri_escape_utf8}; -use POSIX; +use POSIX (); use Storable; use open qw{:utf8 :std}; diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index aaee2c610..ff84bc440 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -22,7 +22,7 @@ use warnings; use strict; use IkiWiki 3.00; use Time::Local; -use POSIX; +use POSIX (); my $time=time; my @now=localtime($time); diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm index 06df2efd5..7f006af83 100644 --- a/IkiWiki/Plugin/relativedate.pm +++ b/IkiWiki/Plugin/relativedate.pm @@ -5,7 +5,7 @@ use warnings; no warnings 'redefine'; use strict; use IkiWiki 3.00; -use POSIX; +use POSIX (); use Encode; sub import { diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm index 5361d2914..99b136281 100644 --- a/IkiWiki/Plugin/wmd.pm +++ b/IkiWiki/Plugin/wmd.pm @@ -4,7 +4,6 @@ package IkiWiki::Plugin::wmd; use warnings; use strict; use IkiWiki 3.00; -use POSIX; use Encode; sub import { -- cgit v1.2.3 From 3131433f64235ad5425eb93d5773580b607876fb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 15 Apr 2010 13:40:53 -0400 Subject: calendar: Add archive_pagespec, which is used by ikiwiki-calendar to specify which pages to include on the calendar archive pages. (The pagespec can still also be specified on the ikiwiki-calendar command line.) --- IkiWiki/Plugin/calendar.pm | 8 ++++++++ debian/changelog | 4 ++++ doc/ikiwiki-calendar.mdwn | 8 +++++--- doc/ikiwiki/directive/calendar.mdwn | 7 +++++-- ikiwiki-calendar.in | 6 +++++- 5 files changed, 27 insertions(+), 6 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index ff84bc440..0f0e9518a 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -47,6 +47,14 @@ sub getsetup () { safe => 1, rebuild => 1, }, + archive_pagespec => { + type => "pagespec", + example => "posts/* and !*/Discussion", + description => "PageSpec of pages to include in the archives; used by ikiwiki-calendar command", + link => 'ikiwiki/PageSpec', + safe => 1, + rebuild => 0, + }, } sub is_leap_year (@) { diff --git a/debian/changelog b/debian/changelog index 26b00a07c..7c607b2a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -27,6 +27,10 @@ ikiwiki (3.20100410) UNRELEASED; urgency=low for master language. * po: Configuring the same language as master and slave confuses processing; so filter out such a misconfiguration. + * calendar: Add archive_pagespec, which is used by ikiwiki-calendar to + specify which pages to include on the calendar archive pages. + (The pagespec can still also be specified on the ikiwiki-calendar command + line.) -- Joey Hess Sun, 04 Apr 2010 12:17:11 -0400 diff --git a/doc/ikiwiki-calendar.mdwn b/doc/ikiwiki-calendar.mdwn index 982892fca..c1f4d7267 100644 --- a/doc/ikiwiki-calendar.mdwn +++ b/doc/ikiwiki-calendar.mdwn @@ -16,9 +16,11 @@ You must specify the setup file for your wiki. The pages will be created inside its `srcdir`, beneath the `archivebase` directory used by the calendar plugin (default "archives"). -You will probably want to specify a [[ikiwiki/PageSpec]] -to control which pages are included on the calendars. The -default is all pages. To limit it to only posts in a blog, +To control which pages are included on the calendars, +a [[ikiwiki/PageSpec]] can be specified. The default is +all pages, or the pages specified by the `comments_pagespec` +setting in the config file. A pagespec can also be specified +on the command line. To limit it to only posts in a blog, use something like "posts/* and !*/Discussion". It defaults to creating calendar pages for the current diff --git a/doc/ikiwiki/directive/calendar.mdwn b/doc/ikiwiki/directive/calendar.mdwn index b2ac75b11..8a08081ee 100644 --- a/doc/ikiwiki/directive/calendar.mdwn +++ b/doc/ikiwiki/directive/calendar.mdwn @@ -40,9 +40,12 @@ An example crontab: "month" or "year". The default is a month view calendar. * `pages` - Specifies the [[ikiwiki/PageSpec]] of pages to link to from the month calendar. Defaults to "*". -* `archivebase` - Configures the base of the archives hierarchy. The - default is "archives". Note that this default can also be overridden +* `archivebase` - Configures the base of the archives hierarchy. + The default is "archives". Note that this default can also be overridden for the whole wiki by setting `archivebase` in ikiwiki's setup file. + Calendars link to pages under here, with names like "2010/04" and + "2010". These pages can be automatically created using the + [[ikiwiki-calendar]] tool. * `year` - The year for which the calendar is requested. Defaults to the current year. * `month` - The numeric month for which the calendar is requested, in the diff --git a/ikiwiki-calendar.in b/ikiwiki-calendar.in index 9738ea5f7..6b6f693b3 100755 --- a/ikiwiki-calendar.in +++ b/ikiwiki-calendar.in @@ -15,7 +15,7 @@ GetOptions( "force" => \$force, ) || usage(); my $setup=shift || usage(); -my $pagespec=shift || "*"; +my $pagespec=shift; my $startyear=shift || 1900+(localtime(time))[5]; my $endyear=shift || $startyear; @@ -27,6 +27,10 @@ IkiWiki::checkconfig(); my $archivebase = 'archives'; $archivebase = $config{archivebase} if defined $config{archivebase}; +if (! defined $pagespec) { + $pagespec=$config{archive_pagespec} || "*"; +} + sub writearchive ($$;$) { my $template=template(shift); my $year=shift; -- cgit v1.2.3 From 142e025ae471c91e68a23476f700df0b8ad6b31d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 15 Apr 2010 20:12:03 -0400 Subject: calendar: Improved display of arrows. --- IkiWiki/Plugin/calendar.pm | 21 +++++++++++---------- debian/changelog | 1 + doc/plugins/calendar.mdwn | 2 ++ doc/style.css | 8 ++++++++ 4 files changed, 22 insertions(+), 10 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 0f0e9518a..aeb5f3d29 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -164,11 +164,11 @@ sub format_month (@) { # Start producing the month calendar $calendar=< - - $purl - $url - $nurl - + + $purl + $url + $nurl + EOF @@ -312,13 +312,14 @@ sub format_year (@) { add_depends($params{page}, "$archivebase/$nyear", deptype("presence")); # Start producing the year calendar + my $m=$params{months_per_row}-2; $calendar=< - - $purl - $url - $nurl - + + $purl + $url + $nurl + Months diff --git a/debian/changelog b/debian/changelog index e4056fdc6..737d73655 100644 --- a/debian/changelog +++ b/debian/changelog @@ -43,6 +43,7 @@ ikiwiki (3.20100415) UNRELEASED; urgency=low * sidebar: Add global_sidebars setting. * conditional: Fix bug that forced "all" mode off by default. * calendarmonth.tmpl: The month calendar is now put in a sidebar. + * calendar: Improved display of arrows. -- Joey Hess Sun, 04 Apr 2010 12:17:11 -0400 diff --git a/doc/plugins/calendar.mdwn b/doc/plugins/calendar.mdwn index 49fd90627..76e718a3b 100644 --- a/doc/plugins/calendar.mdwn +++ b/doc/plugins/calendar.mdwn @@ -14,6 +14,7 @@ customization. * `month-calendar` - The month calendar as a whole. * `month-calendar-head` - The head of the month calendar (ie,"March"). +* `month-calendar-arrow` - Arrow pointing to previous/next month. * `month-calendar-day-head` - A column head in the month calendar (ie, a day-of-week abbreviation). * `month-calendar-day-noday`, `month-calendar-day-link`, @@ -27,6 +28,7 @@ customization. weekends. * `year-calendar` - The year calendar as a whole. * `year-calendar-head` - The head of the year calendar (ie, "2007"). +* `year-calendar-arrow` - Arrow pointing to previous/next year. * `year-calendar-subhead` - For example, "Months". * `year-calendar-month-link`, `year-calendar-month-nolink`, `year-calendar-month-future`, `year-calendar-this-month` - The month diff --git a/doc/style.css b/doc/style.css index 44e06ae4f..7ffcf9fe2 100644 --- a/doc/style.css +++ b/doc/style.css @@ -431,3 +431,11 @@ pre.hl { color:#000000; background-color:#ffffff; } /* For the calendar plugin. */ .month-calendar-day-this-day { background-color: #eee; } .year-calendar-this-month { background-color: #eee; } +.month-calendar-arrow A:link, +.year-calendar-arrow A:link, +.month-calendar-arrow A:visited, +.year-calendar-arrow A:visited { + text-decoration: none; + font-weight: normal; + font-size: 150%; +} -- cgit v1.2.3 From 0f778849c6df237f2219de6e1fa237cf2bc9955f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 8 May 2010 12:45:21 -0400 Subject: calendar: Allow negative month to be specified. -1 is last month, etc. (And also negaitve years.) --- IkiWiki/Plugin/calendar.pm | 27 +++++++++++++++++++++++---- debian/changelog | 2 ++ doc/ikiwiki/directive/calendar.mdwn | 6 +++--- doc/plugins/calendar/discussion.mdwn | 11 ++++++++++- 4 files changed, 38 insertions(+), 8 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index aeb5f3d29..02f41070e 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -386,8 +386,19 @@ sub preprocess (@) { $params{year} = $thisyear unless defined $params{year}; $params{month} = $thismonth unless defined $params{month}; + my $relativemonth=0; + if ($params{month} < 1) { + $params{month}=$thismonth+$params{month}; + $relativemonth=1; + } + my $relativeyear=0; + if ($params{year} < 1) { + $params{year}=$thisyear+$params{year}; + $relativeyear=1; + } + $params{month} = sprintf("%02d", $params{month}); - + if ($params{type} eq 'month' && $params{year} == $thisyear && $params{month} == $thismonth) { # calendar for current month, updates next midnight @@ -404,8 +415,11 @@ sub preprocess (@) { $pagestate{$params{destpage}}{calendar}{nextchange}= timelocal(0, 0, 0, 1, $params{month}-1, $params{year}); } - elsif ($params{type} eq 'year' && $params{year} == $thisyear) { - # calendar for current year, updates 1st of next month + elsif (($params{type} eq 'year' && $params{year} == $thisyear) || + $relativemonth) { + # Calendar for current year updates 1st of next month. + # Any calendar relative to the current month also updates + # then. if ($thismonth < 12) { $pagestate{$params{destpage}}{calendar}{nextchange}= timelocal(0, 0, 0, 1, $thismonth+1-1, $params{year}); @@ -415,6 +429,12 @@ sub preprocess (@) { timelocal(0, 0, 0, 1, 1-1, $params{year}+1); } } + elsif ($relativeyear) { + # Any calendar relative to the current year updates 1st + # of next year. + $pagestate{$params{destpage}}{calendar}{nextchange}= + timelocal(0, 0, 0, 1, 1-1, $thisyear+1); + } elsif ($params{type} eq 'year' && $params{year} > $thisyear) { # calendar for upcoming year, updates 1st of that year $pagestate{$params{destpage}}{calendar}{nextchange}= @@ -426,7 +446,6 @@ sub preprocess (@) { delete $pagestate{$params{destpage}}{calendar}; } - # Calculate month names for next month, and previous months my $calendar=""; if ($params{type} eq 'month') { $calendar=format_month(%params); diff --git a/debian/changelog b/debian/changelog index f74e9929f..795f02822 100644 --- a/debian/changelog +++ b/debian/changelog @@ -26,6 +26,8 @@ ikiwiki (3.20100505) UNRELEASED; urgency=low leave passwordauth enabled and let people who don't have an openid use it. The openid selector form avoids the UI annoyance of having both openid and passwordauth on one form. + * calendar: Allow negative month to be specified. -1 is last month, etc. + (And also negaitve years.) -- Joey Hess Wed, 05 May 2010 18:07:29 -0400 diff --git a/doc/ikiwiki/directive/calendar.mdwn b/doc/ikiwiki/directive/calendar.mdwn index 198da9d51..e9216e11f 100644 --- a/doc/ikiwiki/directive/calendar.mdwn +++ b/doc/ikiwiki/directive/calendar.mdwn @@ -47,14 +47,14 @@ An example crontab: "2010". These pages can be automatically created using the `ikiwiki-calendar` program. * `year` - The year for which the calendar is requested. Defaults to the - current year. + current year. Can also use -1 to refer to last year, and so on. * `month` - The numeric month for which the calendar is requested, in the range 1..12. Used only for the month view calendar, and defaults to the - current month. + current month. Can also use -1 to refer to last month, and so on. * `week_start_day` - A number, in the range 0..6, which represents the day of the week that the month calendar starts with. 0 is Sunday, 1 is Monday, and so on. Defaults to 0, which is Sunday. -* `months_per_row` - In the annual calendar, number of months to place in +* `months_per_row` - In the year calendar, number of months to place in each row. Defaults to 3. [[!meta robots="noindex, follow"]] diff --git a/doc/plugins/calendar/discussion.mdwn b/doc/plugins/calendar/discussion.mdwn index 9d57b7a1e..bb76a9d8b 100644 --- a/doc/plugins/calendar/discussion.mdwn +++ b/doc/plugins/calendar/discussion.mdwn @@ -1,6 +1,15 @@ It would be nice if the "month" type calendar could collect all of the matching pages on a given date in some inline type way. --[[DavidBremner]] +> I agree, but I have not come up with good html to display them. Seems +> it might need some sort of popup. + Is it possible to get the calendar to link to pages based not on their timestamp (as I understand that it does now, or have I misunderstood this?) and instead on for example their location in a directory hierarchy. That way the calendar could be used as a planning / timeline device which I think would be great. --[[Alexander]] -I would like the ability to specify relative previous months. This way I could have a sidebar with the last three months by specifying no month, then 'month="-1"' and 'month="-2"'. Negative numbers for the month would otherwise be invalid, so this shouldn't produce any conflicts with expected behavior. (Right?) -- [[StevenBlack]] +I would like the ability to specify relative previous months. This way I +could have a sidebar with the last three months by specifying no month, +then 'month="-1"' and 'month="-2"'. Negative numbers for the month would +otherwise be invalid, so this shouldn't produce any conflicts with expected +behavior. (Right?) -- [[StevenBlack]] + +> Great idea! Just implemented that and also relative years. --[[Joey]] -- cgit v1.2.3 From fd817f9ac3c074622fe7076516dca61199b09372 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 8 May 2010 12:52:19 -0400 Subject: calendar: nextchange calculation bugfix If a page had multiple calendars, the last one won and set nextchange. That's wrong; the calendar that needs to next update soonest should win. --- IkiWiki/Plugin/calendar.pm | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 02f41070e..d43320cac 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -373,6 +373,16 @@ EOF return $calendar; } +sub setnextchange ($$) { + my $page=shift; + my $timestamp=shift; + + if (! exists $pagestate{$page}{calendar}{nextchange} || + $pagestate{$page}{calendar}{nextchange} > $timestamp) { + $pagestate{$page}{calendar}{nextchange}=$timestamp; + } +} + sub preprocess (@) { my %params=@_; @@ -402,18 +412,18 @@ sub preprocess (@) { if ($params{type} eq 'month' && $params{year} == $thisyear && $params{month} == $thismonth) { # calendar for current month, updates next midnight - $pagestate{$params{destpage}}{calendar}{nextchange}=($time + setnextchange($params{destpage}, ($time + (60 - $now[0]) # seconds + (59 - $now[1]) * 60 # minutes + (23 - $now[2]) * 60 * 60 # hours - ); + )); } elsif ($params{type} eq 'month' && (($params{year} == $thisyear && $params{month} > $thismonth) || $params{year} > $thisyear)) { # calendar for upcoming month, updates 1st of that month - $pagestate{$params{destpage}}{calendar}{nextchange}= - timelocal(0, 0, 0, 1, $params{month}-1, $params{year}); + setnextchange($params{destpage}, + timelocal(0, 0, 0, 1, $params{month}-1, $params{year})); } elsif (($params{type} eq 'year' && $params{year} == $thisyear) || $relativemonth) { @@ -421,24 +431,24 @@ sub preprocess (@) { # Any calendar relative to the current month also updates # then. if ($thismonth < 12) { - $pagestate{$params{destpage}}{calendar}{nextchange}= - timelocal(0, 0, 0, 1, $thismonth+1-1, $params{year}); + setnextchange($params{destpage}, + timelocal(0, 0, 0, 1, $thismonth+1-1, $params{year})); } else { - $pagestate{$params{destpage}}{calendar}{nextchange}= - timelocal(0, 0, 0, 1, 1-1, $params{year}+1); + setnextchange($params{destpage}, + timelocal(0, 0, 0, 1, 1-1, $params{year}+1)); } } elsif ($relativeyear) { # Any calendar relative to the current year updates 1st # of next year. - $pagestate{$params{destpage}}{calendar}{nextchange}= - timelocal(0, 0, 0, 1, 1-1, $thisyear+1); + setnextchange($params{destpage}, + timelocal(0, 0, 0, 1, 1-1, $thisyear+1)); } elsif ($params{type} eq 'year' && $params{year} > $thisyear) { # calendar for upcoming year, updates 1st of that year - $pagestate{$params{destpage}}{calendar}{nextchange}= - timelocal(0, 0, 0, 1, 1-1, $params{year}); + setnextchange($params{destpage}, + timelocal(0, 0, 0, 1, 1-1, $params{year})); } else { # calendar for past month or year, does not need -- cgit v1.2.3 From d0c17a4a46b48d8513c0167271f2f2eb8b9bc081 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 8 May 2010 13:51:05 -0400 Subject: calendar: Display year name in title of month calendar. Also, fix relative month calculations. --- IkiWiki/Plugin/calendar.pm | 21 +++++++++++++-------- debian/changelog | 1 + 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index d43320cac..0bf933dcd 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -132,12 +132,12 @@ sub format_month (@) { $archivebase = $params{archivebase} if defined $params{archivebase}; # Calculate URL's for monthly archives. - my ($url, $purl, $nurl)=("$monthname",'',''); + my ($url, $purl, $nurl)=("$monthname $params{year}",'',''); if (exists $pagesources{"$archivebase/$params{year}/$params{month}"}) { $url = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}/".$params{month}, noimageinline => 1, - linktext => $monthname, + linktext => "$monthname $params{year}", title => $monthname); } add_depends($params{page}, "$archivebase/$params{year}/$params{month}", @@ -396,15 +396,20 @@ sub preprocess (@) { $params{year} = $thisyear unless defined $params{year}; $params{month} = $thismonth unless defined $params{month}; - my $relativemonth=0; - if ($params{month} < 1) { - $params{month}=$thismonth+$params{month}; - $relativemonth=1; - } my $relativeyear=0; if ($params{year} < 1) { - $params{year}=$thisyear+$params{year}; $relativeyear=1; + $params{year}=$thisyear+$params{year}; + } + my $relativemonth=0; + if ($params{month} < 1) { + $relativemonth=1; + my $monthoff=$params{month}; + $params{month}=($thismonth+$monthoff) % 12; + $params{month}=12 if $params{month}==0; + my $yearoff=POSIX::ceil(($thismonth-$params{month}) / -12) + - int($monthoff / 12); + $params{year}-=$yearoff; } $params{month} = sprintf("%02d", $params{month}); diff --git a/debian/changelog b/debian/changelog index 795f02822..f47793477 100644 --- a/debian/changelog +++ b/debian/changelog @@ -28,6 +28,7 @@ ikiwiki (3.20100505) UNRELEASED; urgency=low and passwordauth on one form. * calendar: Allow negative month to be specified. -1 is last month, etc. (And also negaitve years.) + * calendar: Display year name in title of month calendar. -- Joey Hess Wed, 05 May 2010 18:07:29 -0400 -- cgit v1.2.3 From 04ff998c51b578017edf369e0dfc2dc7c63d8071 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 10 Jun 2010 15:01:10 -0400 Subject: calendar styling * calendar: Shorten day names, and improve styling of month calendar. * style.css: Reduced sidebar width back to 20ex from 30; the month calendar will now fit in the smaller width, and 30 was feeling too large. --- IkiWiki/Plugin/calendar.pm | 5 +++-- debian/changelog | 9 ++++++--- doc/style.css | 15 ++++++++++++--- 3 files changed, 21 insertions(+), 8 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 0bf933dcd..359c9b861 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -123,6 +123,7 @@ sub format_month (@) { } # Find out month names for this, next, and previous months + my $monthabbrev=POSIX::strftime("%b", @monthstart); my $monthname=POSIX::strftime("%B", @monthstart); my $pmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$pmonth-1,$pyear-1900))); my $nmonthname=POSIX::strftime("%B", localtime(timelocal(0,0,0,1,$nmonth-1,$nyear-1900))); @@ -137,7 +138,7 @@ sub format_month (@) { $url = htmllink($params{page}, $params{destpage}, "$archivebase/$params{year}/".$params{month}, noimageinline => 1, - linktext => "$monthname $params{year}", + linktext => "$monthabbrev $params{year}", title => $monthname); } add_depends($params{page}, "$archivebase/$params{year}/$params{month}", @@ -182,7 +183,7 @@ EOF for my $dow ($week_start_day..$week_start_day+6) { my @day=localtime(timelocal(0,0,0,$start_day++,$params{month}-1,$params{year}-1900)); my $downame = POSIX::strftime("%A", @day); - my $dowabbr = POSIX::strftime("%a", @day); + my $dowabbr = substr($downame, 0, 1); $downame{$dow % 7}=$downame; $dowabbr{$dow % 7}=$dowabbr; $calendar.= qq{\t\t$dowabbr\n}; diff --git a/debian/changelog b/debian/changelog index f7810c66f..d66bcab20 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -ikiwiki (3.20100609) unstable; urgency=low +ikiwiki (3.20100610) unstable; urgency=low * creation_day() etc use local time, not gmtime. To match calendars, which use local time. @@ -11,10 +11,13 @@ ikiwiki (3.20100609) unstable; urgency=low * editpage: Avoid storing accidental state changes when previewing pages. * page.tmpl: Add a div around the sidebar, page content, and comments, to aide in styling. - * style.css: Improvements to make floating sidebar fit better on + * style.css: Improvements to make floating sidebar fit much better on pages with inlines. + * calendar: Shorten day names, and improve styling of month calendar. + * style.css: Reduced sidebar width back to 20ex from 30; the month calendar + will now fit in the smaller width, and 30 was feeling too large. - -- Joey Hess Mon, 31 May 2010 20:44:17 -0400 + -- Joey Hess Thu, 10 Jun 2010 14:24:05 -0400 ikiwiki (3.20100518.2) unstable; urgency=low diff --git a/doc/style.css b/doc/style.css index 154729721..2cc467b4f 100644 --- a/doc/style.css +++ b/doc/style.css @@ -199,7 +199,7 @@ div.recentchanges { } .sidebar { - width: 30ex; + width: 20ex; float: right; margin-left: 4px; margin-bottom: 4px; @@ -383,8 +383,17 @@ pre.hl { color:#000000; background-color:#ffffff; } .hl.kwd { color:#010181; } /* calendar plugin */ -.month-calendar-day-this-day { background-color: #eee; } -.year-calendar-this-month { background-color: #eee; } +.month-calendar-day-this-day, +.year-calendar-this-month { + background-color: #eee; +} +.month-calendar-day-head, +.month-calendar-day-nolink, +.month-calendar-day-link, +.month-calendar-day-this-day, +.month-calendar-day-future { + text-align: right; +} .month-calendar-arrow A:link, .year-calendar-arrow A:link, .month-calendar-arrow A:visited, -- cgit v1.2.3 From d541cc854a6e610d2d9f5f7b950f4abb76e36954 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 15 Jun 2010 13:38:19 -0400 Subject: calendar: Tune archive_pagespec to only match pages, not other files. --- IkiWiki/Plugin/calendar.pm | 2 +- auto-blog.setup | 2 +- debian/changelog | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin/calendar.pm') diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index 359c9b861..bb995d499 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -49,7 +49,7 @@ sub getsetup () { }, archive_pagespec => { type => "pagespec", - example => "posts/* and !*/Discussion", + example => "page(posts/*) and !*/Discussion", description => "PageSpec of pages to include in the archives; used by ikiwiki-calendar command", link => 'ikiwiki/PageSpec', safe => 1, diff --git a/auto-blog.setup b/auto-blog.setup index ef03295d6..980074ec3 100644 --- a/auto-blog.setup +++ b/auto-blog.setup @@ -46,7 +46,7 @@ IkiWiki::Setup::Automator->import( example => "blog", comments_pagespec => "posts/* and !*/Discussion", blogspam_pagespec => "postcomment(*)", - archive_pagespec => "posts/* and !*/Discussion", + archive_pagespec => "page(posts/*) and !*/Discussion", global_sidebars => 0, discussion => 0, locked_pages => "*", diff --git a/debian/changelog b/debian/changelog index 32ba0cf08..bddedeafa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,7 @@ ikiwiki (3.20100611) UNRELEASED; urgency=low * websetup: Allow enabling plugins listed in disable_plugins. * editpage, comments: Fix broken links in sidebar (due to forcebaseurl). (Thanks, privat) + * calendar: Tune archive_pagespec to only match pages, not other files. -- Joey Hess Fri, 11 Jun 2010 13:39:15 -0400 -- cgit v1.2.3