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.
95 > do not accept my patch: it is an ugly hack that works for me, but its too narrow to be merged in IkiWiki:
97 > - it assumes the [[ikiwiki/directive/pagestats]] directive only deals with tags, which is wrong;
98 > - such a feature (allowing displaying tags using their title), if enabled, should be enabled for the [[plugins/tag]] plugin (and maybe other plugins [[I have in mind|users/spalax]]) as well.
100 > I cannot manage to find a solution to my problem that suits me.
104 > On two sites I maintain using IkiWiki, I have tags that:
106 > - have special characters in it (like [[ยท|http://en.wikipedia.org/wiki/Interpunct]]) that generate ugly URLs;
107 > - have subtags (e.g. `math/calculus`, `math/algebra`, `physics/mechanic` etc.).
109 > That is, having [[ikiwiki/directive/taglink]] or [[ikiwiki/directive/pagestats]] displaying tags using the pagename (that is something derived from the basename of the URL) is not sufficient for me. I would like to be able to display them using their title, their full name (from the `tagbase` parameter), or both.
113 > A solution would be to provide a `tagtext` config option, set to one of `page` (use pagename), `title` (use [[ikiwiki/directive/meta]] title), `path` (use path, since the tagbase), `pathtitle` (use path, and use title for each of the subtags); or a boolean `display_tagtitle` and `display_tagpath`, which would handle the way tags are displayed.
115 > I see at least two drawbacks to this solution:
117 > - I do not know what would be the default of these options, not to break backward compatibility: [[ikiwiki/directive/taglink]] would suggest `page`, whereas the footer would suggest `path`.
118 > - The [[ikiwiki/directive/pagestats]] directive would need an optional boolean parameter `tag`, to specify whether to use these options or not.
122 > I actually wonder if someone else also have this problem: as far as I can see on other sites using IkiWiki and tags, I would not be surprised if others are satisfyed with the current way tags are displayed: I do not remember having seen subtags, or tags in non-English language with weird characters in them.
124 > So, I wonder whether this discussion would benefit IkiWiki, or if I should just go on with my hack (or maybe a plugin, but I think it would be quite difficult to do, given that the very same function is used to display tags and to uniquely identify them).
126 > -- [[Louis|spalax]]