X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/54f600af14bf6dc067ffc30ec6f22d517001fe99..751c06fabaf5c7a0d3b08bf87cd1978c101303b9:/IkiWiki/Plugin/pagestats.pm?ds=inline diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index 17b26f7ba..ac0a463e3 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -31,11 +31,30 @@ 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}; my $style = ($params{style} or 'cloud'); - + + # Backwards compatibility + if (defined $params{show} && $params{show} =~ m/^\d+$/) { + $params{limit} = $params{show}; + delete $params{show}; + } + my %counts; my $max = 0; foreach my $page (pagespec_match_list($params{page}, $params{pages}, @@ -64,11 +83,11 @@ sub preprocess (@) { $max = $counts{$page} if $counts{$page} > $max; } - if (exists $params{show}) { + if (exists $params{limit}) { my $i=0; my %show; foreach my $key (sort { $counts{$b} <=> $counts{$a} } keys %counts) { - last if ++$i > $params{show}; + last if ++$i > $params{limit}; $show{$key}=$counts{$key}; } %counts=%show; @@ -78,7 +97,7 @@ sub preprocess (@) { return "\n". join("\n", map { "" } sort { $counts{$b} <=> $counts{$a} } keys %counts). @@ -101,7 +120,7 @@ sub preprocess (@) { $res.="
  • " if $style eq 'list'; $res .= "". - htmllink($params{page}, $params{destpage}, $page). + htmllink($params{page}, $params{destpage}, $page, linktext => linktext($page, %params)). "\n"; $res.="
  • " if $style eq 'list';
    ". - htmllink($params{page}, $params{destpage}, $_, noimageinline => 1). + htmllink($params{page}, $params{destpage}, $_, noimageinline => 1, linktext => linktext($_, %params)). "".$counts{$_}."