X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/ef7bddbc3693d7abf227100a9a9bc21d186dfada..fe001bd7bf8d16ae998aa66513e3d2276ab9749b:/IkiWiki/Plugin/pagestats.pm?ds=sidebyside

diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm
index 47638210a..17b26f7ba 100644
--- a/IkiWiki/Plugin/pagestats.pm
+++ b/IkiWiki/Plugin/pagestats.pm
@@ -27,6 +27,7 @@ sub getsetup () {
 		plugin => {
 			safe => 1,
 			rebuild => undef,
+			section => "widget",
 		},
 }
 
@@ -63,8 +64,18 @@ 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".
+		return "<table class='".(exists $params{class} ? $params{class} : "pageStats")."'>\n".
 			join("\n", map {
 				"<tr><td>".
 				htmllink($params{page}, $params{destpage}, $_, noimageinline => 1).
@@ -76,16 +87,31 @@ sub preprocess (@) {
 	else {
 		# In case of misspelling, default to a page cloud
 
-		my $res = "<div class='pagecloud'>\n";
+		my $res;
+		if ($style eq 'list') {
+			$res = "<ul class='".(exists $params{class} ? $params{class} : "list")."'>\n";
+		}
+		else {
+			$res = "<div class='".(exists $params{class} ? $params{class} : "pagecloud")."'>\n";
+		}
 		foreach my $page (sort keys %counts) {
 			next unless $counts{$page} > 0;
 
 			my $class = $classes[$counts{$page} * scalar(@classes) / ($max + 1)];
+			
+			$res.="<li>" if $style eq 'list';
 			$res .= "<span class=\"$class\">".
 			        htmllink($params{page}, $params{destpage}, $page).
 			        "</span>\n";
+			$res.="</li>" if $style eq 'list';
+
+		}
+		if ($style eq 'list') {
+			$res .= "</ul>\n";
+		}
+		else {
+			$res .= "</div>\n";
 		}
-		$res .= "</div>\n";
 
 		return $res;
 	}