From cd5a24d8b405902801ca710cb77d6cc3f802f90f Mon Sep 17 00:00:00 2001 From: Louis Date: Sat, 22 Feb 2014 22:30:09 +0000 Subject: [PATCH 1/3] pagestats: add disp parameter --- IkiWiki/Plugin/pagestats.pm | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index 460a5969a..b0ecf7eca 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{disp} && + exists $pagestate{$page} && + exists $pagestate{$page}{meta}{$params{disp}}) { + return $pagestate{$page}{meta}{$params{disp}}; + } + else { + return undef; + } +} + sub preprocess (@) { my %params=@_; $params{pages}="*" unless defined $params{pages}; @@ -84,7 +97,7 @@ sub preprocess (@) { return "\n". join("\n", map { "" } sort { $counts{$b} <=> $counts{$a} } keys %counts). @@ -107,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'; From 89492a62a76e1bf5f5a1d2b1d9ac82b042b7ec49 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 14 Sep 2014 15:51:22 +0100 Subject: [PATCH 2/3] pagestats: consistent indentation --- IkiWiki/Plugin/pagestats.pm | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index b0ecf7eca..d0a4ec7aa 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -34,14 +34,14 @@ sub getsetup () { sub linktext ($%) { # Return the text of the link to a tag, depending on option linktext. my ($page, %params) = @_; - if (exists $params{disp} && - exists $pagestate{$page} && - exists $pagestate{$page}{meta}{$params{disp}}) { - return $pagestate{$page}{meta}{$params{disp}}; - } - else { - return undef; - } + if (exists $params{disp} && + exists $pagestate{$page} && + exists $pagestate{$page}{meta}{$params{disp}}) { + return $pagestate{$page}{meta}{$params{disp}}; + } + else { + return undef; + } } sub preprocess (@) { From e3e6ca2777990caf96e524f59e22925841c79e6e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 14 Sep 2014 15:57:09 +0100 Subject: [PATCH 3/3] pagestats: rename disp to show, and document it --- IkiWiki/Plugin/pagestats.pm | 6 +++--- doc/ikiwiki/directive/pagestats.mdwn | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/IkiWiki/Plugin/pagestats.pm b/IkiWiki/Plugin/pagestats.pm index d0a4ec7aa..ac0a463e3 100644 --- a/IkiWiki/Plugin/pagestats.pm +++ b/IkiWiki/Plugin/pagestats.pm @@ -34,10 +34,10 @@ sub getsetup () { sub linktext ($%) { # Return the text of the link to a tag, depending on option linktext. my ($page, %params) = @_; - if (exists $params{disp} && + if (exists $params{show} && exists $pagestate{$page} && - exists $pagestate{$page}{meta}{$params{disp}}) { - return $pagestate{$page}{meta}{$params{disp}}; + exists $pagestate{$page}{meta}{$params{show}}) { + return $pagestate{$page}{meta}{$params{show}}; } else { return undef; 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"]]
    ". - htmllink($params{page}, $params{destpage}, $_, noimageinline => 1). + htmllink($params{page}, $params{destpage}, $_, noimageinline => 1, linktext => linktext($_, %params)). "".$counts{$_}."