X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/blobdiff_plain/344ab0a16b749c44d6d19dbe1a179c8e30ceef31..20071c39458b841ed9c1e4cb4e7844358e98016a:/IkiWiki/Plugin/pagestats.pm diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index 79b3292c6..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; +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'); @@ -33,10 +42,9 @@ sub preprocess (@) { #{{{ my %counts; my $max = 0; foreach my $page (keys %links) { - if (pagespec_match($page, $params{pages})) { + 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; } } @@ -45,12 +53,13 @@ sub preprocess (@) { #{{{ return "\n". join("\n", map { "" } sort { $counts{$b} <=> $counts{$a} } keys %counts). "\n
". - htmllink($params{page}, $params{destpage}, $_, 1). + htmllink($params{page}, $params{destpage}, $_, noimageinline => 1). "".$counts{$_}."
\n" ; - } else { + } + else { # In case of misspelling, default to a page cloud my $res = "
\n"; @@ -64,6 +73,6 @@ sub preprocess (@) { #{{{ return $res; } -} # }}} +} 1