]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/pagecount.pm
amazon_s3: Fix to support the EU S3 datacenter, which is more picky about attempts...
[git.ikiwiki.info.git] / IkiWiki / Plugin / pagecount.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::pagecount;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
8 sub import {
9         hook(type => "getsetup", id => "pagecount", call => \&getsetup);
10         hook(type => "preprocess", id => "pagecount", call => \&preprocess);
11 }
13 sub getsetup () {
14         return 
15                 plugin => {
16                         safe => 1,
17                         rebuild => undef,
18                 },
19 }
21 sub preprocess (@) {
22         my %params=@_;
23         my $pages=defined $params{pages} ? $params{pages} : "*";
24         
25         # Just get a list of all the pages, and count the items in it.
26         # Use a presence dependency to only update when pages are added
27         # or removed.
29         if ($pages eq '*') {
30                 # optimisation to avoid needing to try matching every page
31                 add_depends($params{page}, $pages, deptype("presence"));
32                 return scalar keys %pagesources;
33         }
35         return scalar pagespec_match_list($params{page}, $pages,
36                 deptype => deptype("presence"));
37 }
39 1