]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/pagestats.pm
minor refactor/optimisation
[git.ikiwiki.info.git] / IkiWiki / Plugin / pagestats.pm
index 47638210aeddeff49866ac1e5a6459828556ddd2..1c0b46830163da3872a0e4b62f0db4960ca3605c 100644 (file)
@@ -27,6 +27,7 @@ sub getsetup () {
                plugin => {
                        safe => 1,
                        rebuild => undef,
+                       section => "widget",
                },
 }
 
@@ -63,6 +64,16 @@ sub preprocess (@) {
                $max = $counts{$page} if $counts{$page} > $max;
        }
 
+       if (exists $params{show}) {
+               my $i=0;
+               my %show;
+               foreach my $key (sort { $counts{$b} <=> $counts{$a} } keys %counts) {
+                       last if ++$i > $params{show};
+                       $show{$key}=$counts{$key};
+               }
+               %counts=%show;
+       }
+
        if ($style eq 'table') {
                return "<table class='pageStats'>\n".
                        join("\n", map {