diff options
author | Simon McVittie <smcv@debian.org> | 2015-11-30 20:58:54 +0000 |
---|---|---|
committer | Simon McVittie <smcv@debian.org> | 2015-11-30 20:58:54 +0000 |
commit | 72c3b81efb1079f8db070ac89e97e9b7bcedd61b (patch) | |
tree | c65f003c541a27f90fa56afe15e779af12fd1184 | |
parent | b199349ffddce2b8afd89567882e182f7ef9bff1 (diff) | |
parent | e3e6ca2777990caf96e524f59e22925841c79e6e (diff) | |
download | ikiwiki-72c3b81efb1079f8db070ac89e97e9b7bcedd61b.tar ikiwiki-72c3b81efb1079f8db070ac89e97e9b7bcedd61b.tar.gz |
Merge remote-tracking branch 'smcv/pagestats-show'
-rw-r--r-- | IkiWiki/Plugin/pagestats.pm | 17 | ||||
-rw-r--r-- | doc/ikiwiki/directive/pagestats.mdwn | 6 |
2 files changed, 21 insertions, 2 deletions
diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index 460a5969a..ac0a463e3 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -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}; @@ -84,7 +97,7 @@ 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). @@ -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'; diff --git a/doc/ikiwiki/directive/pagestats.mdwn b/doc/ikiwiki/directive/pagestats.mdwn index 8d2be0946..ab8397366 100644 --- a/doc/ikiwiki/directive/pagestats.mdwn +++ b/doc/ikiwiki/directive/pagestats.mdwn @@ -40,4 +40,10 @@ that name still works, if its value is numeric. The optional `class` parameter can be used to control the class of the generated tag cloud `div` or page stats `table`. +By default, the names of pages are shown. The `show` parameter +can be used (with a non-numeric value) to show the titles or descriptions +of pages instead (as set by the [[meta]] directive). For example: + + \[[!pagestats pages="tags/*" show="title"]] + [[!meta robots="noindex, follow"]] |