aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Plugin/pagecount.pm
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-10-08 18:41:08 -0400
committerJoey Hess <joey@gnu.kitenet.net>2009-10-08 18:47:25 -0400
commit1abbc6a4041e752fbec9b947a9d453b3b126c120 (patch)
tree200e56b061b498ae28092b6c3c5d3e567f36c1cd /IkiWiki/Plugin/pagecount.pm
parent32cd5f0b798c41b2320a4165c5b6ecc18a4e6e3e (diff)
downloadikiwiki-1abbc6a4041e752fbec9b947a9d453b3b126c120.tar
ikiwiki-1abbc6a4041e752fbec9b947a9d453b3b126c120.tar.gz
pagecount: switched to use_pagespec
Diffstat (limited to 'IkiWiki/Plugin/pagecount.pm')
-rw-r--r--IkiWiki/Plugin/pagecount.pm24
1 files changed, 12 insertions, 12 deletions
diff --git a/IkiWiki/Plugin/pagecount.pm b/IkiWiki/Plugin/pagecount.pm
index 419f2d535..40474b2a1 100644
--- a/IkiWiki/Plugin/pagecount.pm
+++ b/IkiWiki/Plugin/pagecount.pm
@@ -20,20 +20,20 @@ sub getsetup () {
sub preprocess (@) {
my %params=@_;
- $params{pages}="*" unless defined $params{pages};
+ my $pages=defined $params{pages} ? $params{pages} : "*";
- # Needs to update count whenever a page is added or removed, so
- # register a presence dependency.
- add_depends($params{page}, $params{pages}, deptype("presence"));
-
- my @pages;
- if ($params{pages} eq "*") {
- @pages=keys %pagesources;
- }
- else {
- @pages=pagespec_match_list([keys %pagesources], $params{pages}, location => $params{page});
+ # Just get a list of all the pages, and count the items in it.
+ # Use a presence dependency to only update when pages are added
+ # or removed.
+
+ if ($pages eq '*') {
+ # optimisation to avoid needing to try matching every page
+ add_depends($params{page}, $pages, deptype("presence"));
+ return scalar keys %pagesources;
}
- return $#pages+1;
+
+ return scalar use_pagespec($params{page}, $pages,
+ deptype => deptype("presence"));
}
1