2 here is a proposal to add a new option to [[ikiwiki/directive]]
3 [[ikiwiki/directive/pagestats]] (from plugin [[plugins/pagestats]]).
5 This adds global option `pagestats_linktext` (and directive option `linktext`) to specify whether directive `pagestats` should use the page name or the [[title|ikiwiki/directive/meta]] of tags.
7 Here is a [[patch]], for both code and documentation.
9 [[!toggle id=diff text="View patch"]]
10 [[!toggleable id=diff text="""
11 diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm
12 index 17b26f7..a65fd7a 100644
13 --- a/IkiWiki/Plugin/pagestats.pm
14 +++ b/IkiWiki/Plugin/pagestats.pm
15 @@ -29,11 +29,31 @@ sub getsetup () {
19 + pagestats_linktext => {
22 + description => "Set link text to be whether page title (page) or meta title (title).",
29 + # Return the text of the link to a tag, depending on option linktext.
32 + my $linktype = $_[1];
33 + if (($linktype eq "title") and (exists $pagestate{$page}{meta}{title})) {
34 + return $pagestate{$page}{meta}{title};
42 $params{pages}="*" unless defined $params{pages};
43 + $params{linktext} = $config{pagestats_linktext} unless defined $params{linktext};
44 my $style = ($params{style} or 'cloud');
47 @@ -78,7 +98,7 @@ sub preprocess (@) {
48 return "<table class='".(exists $params{class} ? $params{class} : "pageStats")."'>\n".
51 - htmllink($params{page}, $params{destpage}, $_, noimageinline => 1).
52 + htmllink($params{page}, $params{destpage}, $_, noimageinline => 1, linktext => linktext($_, $params{linktext})).
53 "</td><td>".$counts{$_}."</td></tr>"
55 sort { $counts{$b} <=> $counts{$a} } keys %counts).
56 @@ -101,8 +121,8 @@ sub preprocess (@) {
58 $res.="<li>" if $style eq 'list';
59 $res .= "<span class=\"$class\">".
60 - htmllink($params{page}, $params{destpage}, $page).
62 + htmllink($params{page}, $params{destpage}, $page, linktext => linktext($page, $params{linktext})).
64 $res.="</li>" if $style eq 'list';
67 diff --git a/doc/ikiwiki/directive/pagestats.mdwn b/doc/ikiwiki/directive/pagestats.mdwn
68 index 8d904f5..56970e6 100644
69 --- a/doc/ikiwiki/directive/pagestats.mdwn
70 +++ b/doc/ikiwiki/directive/pagestats.mdwn
71 @@ -37,4 +37,6 @@ links:
72 The optional `class` parameter can be used to control the class
73 of the generated tag cloud `div` or page stats `table`.
75 +The optional `linktext` parameter can be used to control the text that is displayed for each tag. It can be `page` (the name of the page is used) or `title` (the title, according to the [[ikiwiki/directive/meta]] [[ikiwiki/directive]], is used). This option can be set globally in the setup using option `pagestats_linktext`; default is `page`.
77 [[!meta robots="noindex, follow"]]
78 diff --git a/doc/plugins/pagestats.mdwn b/doc/plugins/pagestats.mdwn
79 index 347e39a..6a72a9a 100644
80 --- a/doc/plugins/pagestats.mdwn
81 +++ b/doc/plugins/pagestats.mdwn
83 This plugin provides the [[ikiwiki/directive/pagestats]]
84 [[ikiwiki/directive]], which can generate stats about how pages link to
85 each other, or display a tag cloud.
87 +Their is one global option for the setup file:
89 +* `pagestats_linktext` controls the text that is displayed for each tag. If `page` (the default), the name of the page is used; if `title`, its title (according to the [[ikiwiki/directive/meta]] [[ikiwiki/directive]]) is used.