summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@gnu.kitenet.net>2009-12-25 14:31:51 -0500
committerJoey Hess <joey@gnu.kitenet.net>2009-12-25 14:31:51 -0500
commit3a1c8c2b463b8a4f6b3b2c866c5e1b1500f95193 (patch)
tree2f517365da1620c6af25e76335036b9dfb35c78c
parentdbf0f25346a7eb0b63581639df3ac0c73753a0f0 (diff)
pagestats: Add show parameter. Closes: #562129
-rw-r--r--IkiWiki/Plugin/pagestats.pm10
-rw-r--r--debian/changelog6
-rw-r--r--doc/ikiwiki/directive/pagestats.mdwn6
3 files changed, 22 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm
index 47638210a..4313aa271 100644
--- a/IkiWiki/Plugin/pagestats.pm
+++ b/IkiWiki/Plugin/pagestats.pm
@@ -63,6 +63,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 {
diff --git a/debian/changelog b/debian/changelog
index 0e76bd727..e01037171 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+ikiwiki (3.20091219) UNRELEASED; urgency=low
+
+ * pagestats: Add show parameter. Closes: #562129
+
+ -- Joey Hess <joeyh@debian.org> Fri, 25 Dec 2009 14:31:22 -0500
+
ikiwiki (3.20091218) unstable; urgency=low
* Add complete Spanish basewiki translation done by Fernando Gonzalez de
diff --git a/doc/ikiwiki/directive/pagestats.mdwn b/doc/ikiwiki/directive/pagestats.mdwn
index f14c80b07..68f4d2734 100644
--- a/doc/ikiwiki/directive/pagestats.mdwn
+++ b/doc/ikiwiki/directive/pagestats.mdwn
@@ -22,4 +22,10 @@ Or to display a cloud of tags related to Linux, you could use:
\[[!pagestats pages="tags/* and not tags/linux" among="tagged(linux)"]]
+The optional `show` parameter limits display to the specified number of
+pages. For instance, to show a table of the top ten pages with the most
+links:
+
+ \[[!pagestats style="table" show="10"]]
+
[[!meta robots="noindex, follow"]]