Package: ikiwiki
Version: 3.20091218
Severity: wishlist
Tags: patch

Hi Joey,
I'm attaching a patch to implement a "maxcount" option to pagestats, so that 
the user can choose how many pages/tags to show. I just converted my blog from 
drupal to ikiwiki, and having ~80 tags I felt the need for this.

I'm CCing Enrico since it seems like he was the original author.

Please consider including it.

Thank you!
David

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.29-1-686 (SMP w/1 CPU core)
Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages ikiwiki depends on:
ii  libhtml-parser-perl           3.64-1     collection of modules that parse 
H
ii  libhtml-scrubber-perl         0.08-4     Perl extension for 
scrubbing/sanit
ii  libhtml-template-perl         2.9-1      HTML::Template : A module for 
usin
ii  liburi-perl                   1.50-1     module to manipulate and access 
UR
ii  markdown                      1.0.1-7    Text-to-HTML conversion tool
ii  perl                          5.10.1-8   Larry Wall's Practical Extraction 
ii  python                        2.5.4-8    An interactive high-level object-
o
ii  python-support                1.0.6      automated rebuilding support for 
P

Versions of packages ikiwiki recommends:
ii  bzr                        2.0.3-1       easy to use distributed version 
co
ii  gcc [c-compiler]           4:4.4.2-2     The GNU C compiler
ii  gcc-4.1 [c-compiler]       4.1.2-27      The GNU C compiler
ii  gcc-4.3 [c-compiler]       4.3.4-6       The GNU C compiler
ii  gcc-4.4 [c-compiler]       4.4.2-6       The GNU C compiler
ii  git-core                   1:1.6.6~rc1-1 fast, scalable, distributed 
revisi
pn  libauthen-passphrase-perl  <none>        (no description available)
ii  libc6-dev [libc-dev]       2.10.2-2      GNU C Library: Development 
Librari
ii  libcgi-formbuilder-perl    3.05.01-7     Easily generate and process 
statef
ii  libcgi-session-perl        4.41-1        persistent session data in CGI 
app
pn  liblwpx-paranoidagent-perl <none>        (no description available)
ii  libmail-sendmail-perl      0.79.16-1     Send email from a perl script
pn  libnet-openid-consumer-per <none>        (no description available)
pn  libterm-readline-gnu-perl  <none>        (no description available)
ii  libtimedate-perl           1.1900-1      Time and date functions for Perl
ii  libxml-simple-perl         2.18-2        Perl module for reading and 
writin
ii  mercurial                  1.4.1-1       scalable distributed version 
contr
ii  subversion                 1.6.6dfsg-2   Advanced version control system

Versions of packages ikiwiki suggests:
ii  dvipng                       1.12-2      convert DVI files to PNG graphics
ii  gettext                      0.17-8      GNU Internationalization 
utilities
ii  graphviz                     2.20.2-6    rich set of graph drawing tools
ii  libcrypt-ssleay-perl         0.57-2      Support for https protocol in LWP
ii  libdigest-sha1-perl          2.12-1      NIST SHA-1 message digest 
algorith
pn  libfile-mimeinfo-perl        <none>      (no description available)
pn  libhighlight-perl            <none>      (no description available)
ii  libhtml-tree-perl            3.23-1      represent and create HTML syntax 
t
ii  liblocale-gettext-perl       1.05-6      Using libc functions for 
internati
ii  libmailtools-perl            2.04-1      Manipulate email in perl programs
pn  libnet-amazon-s3-perl        <none>      (no description available)
pn  librpc-xml-perl              <none>      (no description available)
ii  libsearch-xapian-perl        1.0.17.0-1  Perl bindings for the Xapian 
searc
pn  libsort-naturally-perl       <none>      (no description available)
pn  libtext-csv-perl             <none>      (no description available)
pn  libtext-textile-perl         <none>      (no description available)
pn  libtext-typography-perl      <none>      (no description available)
pn  libtext-wikicreole-perl      <none>      (no description available)
pn  libtext-wikiformat-perl      <none>      (no description available)
pn  libxml-feed-perl             <none>      (no description available)
ii  perlmagick                   7:6.5.8.3-1 Perl interface to the ImageMagick 
pn  po4a                         <none>      (no description available)
ii  polygen                      1.0.6.ds2-8 generator of random sentences 
from
ii  python-docutils              0.6-2       utilities for the documentation 
of
pn  sparkline-php                <none>      (no description available)
ii  texlive                      2009-5      TeX Live: A decent selection of 
th
pn  tidy                         <none>      (no description available)
pn  viewvc | gitweb | viewcvs    <none>      (no description available)
pn  xapian-omega                 <none>      (no description available)

-- no debconf information

-- 
 . ''`.   Debian developer | http://wiki.debian.org/DavidPaleino
 : :'  : Linuxer #334216 --|-- http://www.hanskalabs.net/
 `. `'`  GPG: 1392B174 ----|---- http://snipr.com/qa_page
   `-   2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174
From: David Paleino <[email protected]>
Subject: implement a "maxcount" option to pagestats, to limit the
 number of shown tags to the most popular "n".

--- /usr/share/perl5/IkiWiki/Plugin/pagestats.pm	2009-12-06 20:55:09.000000000 +0100
+++ .ikiwiki/IkiWiki/Plugin/pagestats.pm	2009-12-23 01:14:19.000000000 +0100
@@ -30,6 +30,10 @@
 		},
 }
 
+sub orderbyvalue {
+	$count{$b} <=> $count{$a};
+}
+
 sub preprocess (@) {
 	my %para...@_;
 	$params{pages}="*" unless defined $params{pages};
@@ -77,6 +81,18 @@
 		# In case of misspelling, default to a page cloud
 
 		my $res = "<div class='pagecloud'>\n";
+
+		if (exists $params{maxcount}) {
+			my $i = 0;
+			my %goods = {};
+			foreach $key (sort orderbyvalue (keys(%counts))) {
+				if ($i++ < $params{maxcount}) {
+					$goods{$key} = $counts{$key};
+				}
+			}
+			%counts = %goods;
+		}
+
 		foreach my $page (sort keys %counts) {
 			next unless $counts{$page} > 0;
 

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to