X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/39195de96e6f705e4a5741254d6d01d14127005c..5c0e56d149c6b33d010561f64f583e7ad1c529da:/IkiWiki/Plugin/pagecount.pm diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm index e059fa618..5a2301af4 100644 --- a/IkiWiki/Plugin/pagecount.pm +++ b/IkiWiki/Plugin/pagecount.pm @@ -3,22 +3,22 @@ package IkiWiki::Plugin::pagecount; use warnings; use strict; -use IkiWiki 2.00; +use IkiWiki 3.00; -sub import { #{{{ +sub import { hook(type => "getsetup", id => "pagecount", call => \&getsetup); hook(type => "preprocess", id => "pagecount", call => \&preprocess); -} # }}} +} -sub getsetup () { #{{{ +sub getsetup () { return plugin => { safe => 1, rebuild => undef, }, -} #}}} +} -sub preprocess (@) { #{{{ +sub preprocess (@) { my %params=@_; $params{pages}="*" unless defined $params{pages}; @@ -26,13 +26,14 @@ sub preprocess (@) { #{{{ # register a dependency. add_depends($params{page}, $params{pages}); - 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