]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/pagestats.pm
mdwn: Automatically detect which libdiscount flags to use
[git.ikiwiki.info.git] / IkiWiki / Plugin / pagestats.pm
index 460a5969a60e6924af3f637db2c3760e8883e7ae..304ddd1c826e95f86d9dbfe139626852149e482c 100644 (file)
@@ -31,6 +31,19 @@ sub getsetup () {
                },
 }
 
+sub linktext ($%) {
+       # Return the text of the link to a tag, depending on option linktext.
+       my ($page, %params) = @_;
+       if (exists $params{show} &&
+               exists $pagestate{$page} &&
+               exists $pagestate{$page}{meta}{$params{show}}) {
+               return $pagestate{$page}{meta}{$params{show}};
+       }
+       else {
+               return undef;
+       }
+}
+
 sub preprocess (@) {
        my %params=@_;
        $params{pages}="*" unless defined $params{pages};
@@ -73,7 +86,7 @@ sub preprocess (@) {
        if (exists $params{limit}) {
                my $i=0;
                my %show;
-               foreach my $key (sort { $counts{$b} <=> $counts{$a} } keys %counts) {
+               foreach my $key (sort { $counts{$b} <=> $counts{$a} || $a cmp $b } keys %counts) {
                        last if ++$i > $params{limit};
                        $show{$key}=$counts{$key};
                }
@@ -84,10 +97,10 @@ sub preprocess (@) {
                return "<table class='".(exists $params{class} ? $params{class} : "pageStats")."'>\n".
                        join("\n", map {
                                "<tr><td>".
-                               htmllink($params{page}, $params{destpage}, $_, noimageinline => 1).
+                               htmllink($params{page}, $params{destpage}, $_, noimageinline => 1, linktext => linktext($_, %params)).
                                "</td><td>".$counts{$_}."</td></tr>"
                        }
-                       sort { $counts{$b} <=> $counts{$a} } keys %counts).
+                       sort { $counts{$b} <=> $counts{$a} || $a cmp $b } keys %counts).
                        "\n</table>\n" ;
        }
        else {
@@ -107,7 +120,7 @@ sub preprocess (@) {
                        
                        $res.="<li>" if $style eq 'list';
                        $res .= "<span class=\"$class\">".
-                               htmllink($params{page}, $params{destpage}, $page).
+                                                       htmllink($params{page}, $params{destpage}, $page, linktext => linktext($page, %params)).
                                "</span>\n";
                        $res.="</li>" if $style eq 'list';