X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/ee1ad53c4c2710aa7ded61bdc56f3a8cce514f22..3e8b7a6b196767d2c7d21790b6ed7c3fb5f70d31:/IkiWiki/Plugin/pagestats.pm diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index f6398c535..dbe69539d 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -12,16 +12,25 @@ package IkiWiki::Plugin::pagestats; use warnings; use strict; -use IkiWiki 2.00; +use IkiWiki 3.00; # Names of the HTML classes to use for the tag cloud our @classes = ('smallestPC', 'smallPC', 'normalPC', 'bigPC', 'biggestPC' ); -sub import { #{{{ +sub import { + hook(type => "getsetup", id => "pagestats", call => \&getsetup); hook(type => "preprocess", id => "pagestats", call => \&preprocess); -} # }}} +} -sub preprocess (@) { #{{{ +sub getsetup () { + return + plugin => { + safe => 1, + rebuild => undef, + }, +} + +sub preprocess (@) { my %params=@_; $params{pages}="*" unless defined $params{pages}; my $style = ($params{style} or 'cloud'); @@ -35,8 +44,7 @@ sub preprocess (@) { #{{{ foreach my $page (keys %links) { if (pagespec_match($page, $params{pages}, location => $params{page})) { use IkiWiki::Render; - my @bl = IkiWiki::backlinks($page); - $counts{$page} = scalar(@bl); + $counts{$page} = scalar(IkiWiki::backlinks($page)); $max = $counts{$page} if $counts{$page} > $max; } } @@ -50,7 +58,8 @@ sub preprocess (@) { #{{{ } sort { $counts{$b} <=> $counts{$a} } keys %counts). "\n\n" ; - } else { + } + else { # In case of misspelling, default to a page cloud my $res = "
\n"; @@ -64,6 +73,6 @@ sub preprocess (@) { #{{{ return $res; } -} # }}} +} 1