diff --git a/doc/todo/Option_linktext_for_pagestats_directive.mdwn b/doc/todo/Option_linktext_for_pagestats_directive.mdwn new file mode 100644 index 000000000..fad813a39 --- /dev/null +++ b/doc/todo/Option_linktext_for_pagestats_directive.mdwn @@ -0,0 +1,92 @@ +Hello, +here is a proposal to add a new option to [[ikiwiki/directive]] +[[ikiwiki/directive/pagestats]] (from plugin [[plugins/pagestats]]). + +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. + +Here is a [[patch]], for both code and documentation. + +[[!toggle id=diff text="View patch"]] +[[!toggleable id=diff text=""" + diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm + index 17b26f7..a65fd7a 100644 + --- a/IkiWiki/Plugin/pagestats.pm + +++ b/IkiWiki/Plugin/pagestats.pm + @@ -29,11 +29,31 @@ sub getsetup () { + rebuild => undef, + section => "widget", + }, + + pagestats_linktext => { + + type => "string", + + example => "title", + + description => "Set link text to be whether page title (page) or meta title (title).", + + safe => 1, + + rebuild => 1, + + }, + +} + + + +sub linktext ($$) { + + # Return the text of the link to a tag, depending on option linktext. + + use Data::Dumper; + + my $page = $_[0]; + + my $linktype = $_[1]; + + if (($linktype eq "title") and (exists $pagestate{$page}{meta}{title})) { + + return $pagestate{$page}{meta}{title}; + + } else { + + return undef; + + } + } + + sub preprocess (@) { + my %params=@_; + $params{pages}="*" unless defined $params{pages}; + + $params{linktext} = $config{pagestats_linktext} unless defined $params{linktext}; + my $style = ($params{style} or 'cloud'); + + my %counts; + @@ -78,7 +98,7 @@ sub preprocess (@) { + return "
". + - htmllink($params{page}, $params{destpage}, $_, noimageinline => 1). + + htmllink($params{page}, $params{destpage}, $_, noimageinline => 1, linktext => linktext($_, $params{linktext})). + " | ".$counts{$_}." |