From 4a4610e66e7dd548843bdf69d2b59e612ebeabd3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 6 Apr 2012 16:09:27 +0100 Subject: trail: fix inline documentation --- IkiWiki/Plugin/trail.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/IkiWiki/Plugin/trail.pm b/IkiWiki/Plugin/trail.pm index 330d2a31d..b73961e66 100644 --- a/IkiWiki/Plugin/trail.pm +++ b/IkiWiki/Plugin/trail.pm @@ -26,10 +26,10 @@ sub import { # # * $pagestate{$T}{trail}{contents} # Reference to an array of lists each containing either: -# - [link, "link"] +# - [link => "link"] # A link specification, pointing to the same page that [[link]] # would select -# - [pagespec, "posts/*", "age", 0] +# - [pagespec => "posts/*", "age", 0] # A match by pagespec; the third array element is the sort order # and the fourth is whether to reverse sorting # -- cgit v1.2.3 From 258ee1bc3b9c43807064c771ebcb9ce2840d4264 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Fri, 6 Apr 2012 17:05:26 +0100 Subject: trail, inline: treat pagenames as a list of literal names, not links --- IkiWiki/Plugin/inline.pm | 6 +++--- IkiWiki/Plugin/trail.pm | 19 +++++++++++++++++-- doc/ikiwiki/directive/inline.mdwn | 8 ++++---- t/trail.t | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index a50c4b7b7..8eb033951 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -211,9 +211,7 @@ sub preprocess_inline (@) { } } - @list = grep { $_ ne '' } - map { bestlink($params{page}, $_) } - split ' ', $params{pagenames}; + @list = split ' ', $params{pagenames}; if (yesno($params{reverse})) { @list=reverse(@list); @@ -222,6 +220,8 @@ sub preprocess_inline (@) { foreach my $p (@list) { add_depends($params{page}, $p, deptype($quick ? "presence" : "content")); } + + @list = grep { exists $pagesources{$_} } @list; } else { my $num=0; diff --git a/IkiWiki/Plugin/trail.pm b/IkiWiki/Plugin/trail.pm index b73961e66..34a2ca5b6 100644 --- a/IkiWiki/Plugin/trail.pm +++ b/IkiWiki/Plugin/trail.pm @@ -26,6 +26,8 @@ sub import { # # * $pagestate{$T}{trail}{contents} # Reference to an array of lists each containing either: +# - [pagenames => "page1", "page2"] +# Those literal pages # - [link => "link"] # A link specification, pointing to the same page that [[link]] # would select @@ -148,8 +150,8 @@ sub preprocess_trailitems (@) { } if (exists $params{pagenames}) { - my @list = map { [link => $_] } split ' ', $params{pagenames}; - push @{$pagestate{$params{page}}{trail}{contents}}, @list; + push @{$pagestate{$params{page}}{trail}{contents}}, + [pagenames => (split ' ', $params{pagenames})]; } return ""; @@ -271,6 +273,19 @@ sub prerender { $c->[1], sort => $c->[2], reverse => $c->[3]); } + elsif ($c->[0] eq 'pagenames') { + my @pagenames = @$c; + shift @pagenames; + foreach my $page (@pagenames) { + if (exists $pagesources{$page}) { + push @$members, $page; + } + else { + # rebuild trail if it turns up + add_depends($trail, $page, deptype("presence")); + } + } + } elsif ($c->[0] eq 'link') { my $best = bestlink($trail, $c->[1]); push @$members, $best if length $best; diff --git a/doc/ikiwiki/directive/inline.mdwn b/doc/ikiwiki/directive/inline.mdwn index b2f1b5306..a9c241afc 100644 --- a/doc/ikiwiki/directive/inline.mdwn +++ b/doc/ikiwiki/directive/inline.mdwn @@ -113,10 +113,10 @@ Here are some less often needed parameters: and/or `page/feed.rss`. This option is not supported if the wiki is configured not to use `usedirs`. * `pagenames` - If given instead of `pages`, this is interpreted as a - space-separated list of links to pages (with the same - [[SubPage/LinkingRules]] as in a [[ikiwiki/WikiLink]]), and they are inlined - in exactly the order given: the `sort` and `pages` parameters cannot be used - in conjunction with this one. + space-separated list of absolute page names ([[SubPage/LinkingRules]] are + not taken into account), and they are inlined in exactly the order given: + the `sort` and `pages` parameters cannot be used in conjunction with + this one. * `trail` - If set to "yes" and the [[!iki plugins/trail desc=trail]] plugin is enabled, turn the inlined pages into a trail with next/previous links, by passing the same options to [[ikiwiki/directive/trailitems]]. The `skip` diff --git a/t/trail.t b/t/trail.t index 7766344b1..2e4b9278d 100755 --- a/t/trail.t +++ b/t/trail.t @@ -93,7 +93,7 @@ write_old_file("sorting/linked2.mdwn", "linked2"); write_old_file("sorting.mdwn", '[[!traillink linked]] ' . '[[!trailitems pages="sorting/z/a or sorting/a/b or sorting/a/c"]] ' . - '[[!trailitems pagenames="beginning middle end"]] ' . + '[[!trailitems pagenames="sorting/beginning sorting/middle sorting/end"]] ' . '[[!inline pages="sorting/old or sorting/ancient or sorting/new" trail="yes"]] ' . '[[!traillink linked2]]'); -- cgit v1.2.3