X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/21add7ffa87a5e622d18bdbb24c638c15bdb3800..83b9bf54ec85f7c1156983108f57c2b1af0e8fe5:/IkiWiki/Plugin/pagecount.pm diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm index c08ab3931..80561350b 100644 --- a/IkiWiki/Plugin/pagecount.pm +++ b/IkiWiki/Plugin/pagecount.pm @@ -3,7 +3,7 @@ package IkiWiki::Plugin::pagecount; use warnings; use strict; -use IkiWiki 2.00; +use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "pagecount", call => \&getsetup); @@ -23,16 +23,17 @@ sub preprocess (@) { $params{pages}="*" unless defined $params{pages}; # Needs to update count whenever a page is added or removed, so - # register a dependency. - add_depends($params{page}, $params{pages}); + # register a presence dependency. + add_depends($params{page}, $params{pages}, presence => 1); - my @pages=keys %pagesources; - return $#pages+1 if $params{pages} eq "*"; # optimisation - my $count=0; - foreach my $page (@pages) { - $count++ if pagespec_match($page, $params{pages}, location => $params{page}); + my @pages; + if ($params{pages} eq "*") { + @pages=keys %pagesources; } - return $count; + else { + @pages=pagespec_match_list([keys %pagesources], $params{pages}, location => $params{page}); + } + return $#pages+1; } 1