From: Simon McVittie Date: Fri, 12 Sep 2014 20:38:06 +0000 (+0100) Subject: Merge branch 'ready/trail-sort' X-Git-Tag: 3.20140916~50 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/2eea320b674870956f6ad6c7b377b158cec2d624?hp=a5536103e7a64d5b15da50666d00aaa86686d945 Merge branch 'ready/trail-sort' --- diff --git a/IkiWiki.pm b/IkiWiki.pm index cd4ac815d..49ac97196 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -2460,6 +2460,19 @@ sub pagespec_match ($$;@) { return $sub->($page, @params); } +# e.g. @pages = sort_pages("title", \@pages, reverse => "yes") +# +# Not exported yet, but could be in future if it is generally useful. +# Note that this signature is not the same as IkiWiki::SortSpec::sort_pages, +# which is "more internal". +sub sort_pages ($$;@) { + my $sort = shift; + my $list = shift; + my %params = @_; + $sort = sortspec_translate($sort, $params{reverse}); + return IkiWiki::SortSpec::sort_pages($sort, @$list); +} + sub pagespec_match_list ($$;@) { my $page=shift; my $pagespec=shift; diff --git a/IkiWiki/Plugin/trail.pm b/IkiWiki/Plugin/trail.pm index d5fb2b5d6..476db4dcb 100644 --- a/IkiWiki/Plugin/trail.pm +++ b/IkiWiki/Plugin/trail.pm @@ -319,10 +319,9 @@ sub prerender { } if (defined $pagestate{$trail}{trail}{sort}) { - # re-sort - @$members = pagespec_match_list($trail, 'internal(*)', - list => $members, - sort => $pagestate{$trail}{trail}{sort}); + @$members = IkiWiki::sort_pages( + $pagestate{$trail}{trail}{sort}, + $members); } if (IkiWiki::yesno $pagestate{$trail}{trail}{reverse}) {