Added my site, even though it's in an early state
[ikiwiki.git] / IkiWiki / Plugin / pagecount.pm
blobdd5de3c83102aac6b806eae75a2517c622ac10e2
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);
13 sub getsetup () {
14 return
15 plugin => {
16 safe => 1,
17 rebuild => undef,
18 section => "widget",
22 sub preprocess (@) {
23 my %params=@_;
24 my $pages=defined $params{pages} ? $params{pages} : "*";
26 # Just get a list of all the pages, and count the items in it.
27 # Use a presence dependency to only update when pages are added
28 # or removed.
30 if ($pages eq '*') {
31 # optimisation to avoid needing to try matching every page
32 add_depends($params{page}, $pages, deptype("presence"));
33 return scalar keys %pagesources;
36 return scalar pagespec_match_list($params{page}, $pages,
37 deptype => deptype("presence"));