aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2011-11-12 21:37:28 +0000
committerSimon McVittie <smcv@debian.org>2011-11-12 21:37:28 +0000
commitd70ba7cff3fc6cc78ea2f8eb0713212478ab6ba7 (patch)
tree6e8b98b163d0493b89d15658dc77206ab9b7bbe0 /IkiWiki
parent74b1b2761ac21e73376d714503aad326dd6f8fec (diff)
downloadikiwiki-d70ba7cff3fc6cc78ea2f8eb0713212478ab6ba7.tar
ikiwiki-d70ba7cff3fc6cc78ea2f8eb0713212478ab6ba7.tar.gz
Split trail directive into trailitems, trailoptions
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/trail.pm86
1 files changed, 38 insertions, 48 deletions
diff --git a/IkiWiki/Plugin/trail.pm b/IkiWiki/Plugin/trail.pm
index 098b98607..5ee152155 100644
--- a/IkiWiki/Plugin/trail.pm
+++ b/IkiWiki/Plugin/trail.pm
@@ -12,9 +12,10 @@ use IkiWiki 3.00;
sub import {
hook(type => "getsetup", id => "trail", call => \&getsetup);
hook(type => "needsbuild", id => "trail", call => \&needsbuild);
- hook(type => "preprocess", id => "trail", call => \&preprocess_trail, scan => 1);
+ hook(type => "preprocess", id => "trailoptions", call => \&preprocess_trailoptions, scan => 1);
hook(type => "preprocess", id => "trailinline", call => \&preprocess_trailinline, scan => 1);
hook(type => "preprocess", id => "trailitem", call => \&preprocess_trailitem, scan => 1);
+ hook(type => "preprocess", id => "trailitems", call => \&preprocess_trailitems, scan => 1);
hook(type => "preprocess", id => "traillink", call => \&preprocess_traillink, scan => 1);
hook(type => "pagetemplate", id => "trail", call => \&pagetemplate);
}
@@ -103,23 +104,9 @@ sub needsbuild (@) {
my $scanned = 0;
-sub preprocess_trail (@) {
+sub preprocess_trailoptions (@) {
my %params = @_;
- # avoid collecting everything in the preprocess stage if we already
- # did in the scan stage
- if (defined wantarray) {
- return "" if $scanned;
- }
- else {
- $scanned = 1;
- }
-
- # trail members from a pagespec ought to be in some sort of order,
- # and path is a nice obvious default
- $params{sortthese} = 'path' unless exists $params{sortthese};
- $params{reversethese} = 'no' unless exists $params{reversethese};
-
if (exists $params{circular}) {
$pagestate{$params{page}}{trail}{circular} =
IkiWiki::yesno($params{circular});
@@ -133,47 +120,19 @@ sub preprocess_trail (@) {
$pagestate{$params{page}}{trail}{reverse} = $params{reverse};
}
- if (exists $params{pages}) {
- push @{$pagestate{$params{page}}{trail}{contents}},
- ["pagespec" => $params{pages}, $params{sortthese},
- IkiWiki::yesno($params{reversethese})];
- }
-
- if (exists $params{pagenames}) {
- my @list = map { [link => $_] } split ' ', $params{pagenames};
- push @{$pagestate{$params{page}}{trail}{contents}}, @list;
- }
-
return "";
}
sub preprocess_trailinline (@) {
my %params = @_;
- if (exists $params{sort}) {
- $params{sortthese} = $params{sort};
- delete $params{sort};
- }
- else {
+ if (! exists $params{sort}) {
# sort in the same order as [[plugins/inline]]'s default
- $params{sortthese} = 'age';
- }
-
- if (exists $params{reverse}) {
- $params{reversethese} = $params{reverse};
- delete $params{reverse};
- }
-
- if (exists $params{trailsort}) {
- $params{sort} = $params{trailsort};
- }
-
- if (exists $params{trailreverse}) {
- $params{reverse} = $params{trailreverse};
+ $params{sort} = 'age';
}
if (defined wantarray) {
- scalar preprocess_trail(%params);
+ scalar preprocess_trailitems(%params);
if (IkiWiki->can("preprocess_inline")) {
return IkiWiki::preprocess_inline(@_);
@@ -183,7 +142,7 @@ sub preprocess_trailinline (@) {
}
}
else {
- preprocess_trail(%params);
+ preprocess_trailitems(%params);
}
}
@@ -211,6 +170,37 @@ sub preprocess_trailitem (@) {
return "";
}
+sub preprocess_trailitems (@) {
+ my %params = @_;
+
+ # avoid collecting everything in the preprocess stage if we already
+ # did in the scan stage
+ if (defined wantarray) {
+ return "" if $scanned;
+ }
+ else {
+ $scanned = 1;
+ }
+
+ # trail members from a pagespec ought to be in some sort of order,
+ # and path is a nice obvious default
+ $params{sort} = 'path' unless exists $params{sort};
+ $params{reverse} = 'no' unless exists $params{reverse};
+
+ if (exists $params{pages}) {
+ push @{$pagestate{$params{page}}{trail}{contents}},
+ ["pagespec" => $params{pages}, $params{sort},
+ IkiWiki::yesno($params{reverse})];
+ }
+
+ if (exists $params{pagenames}) {
+ my @list = map { [link => $_] } split ' ', $params{pagenames};
+ push @{$pagestate{$params{page}}{trail}{contents}}, @list;
+ }
+
+ return "";
+}
+
sub preprocess_traillink (@) {
my $link = shift;
shift;