projects
/
ikiwiki.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
903a5a3
)
trail: avoid collecting trail members twice
author
Simon McVittie
<smcv@debian.org>
Sat, 12 Nov 2011 16:57:27 +0000
(16:57 +0000)
committer
Simon McVittie
<smcv@debian.org>
Sat, 12 Nov 2011 16:57:27 +0000
(16:57 +0000)
IkiWiki/Plugin/trail.pm
patch
|
blob
|
history
diff --git
a/IkiWiki/Plugin/trail.pm
b/IkiWiki/Plugin/trail.pm
index e9b4d9cd4fc589ff2b35f2256f6d7d76bd697770..e6e55bbdbe104364a407466bd16daf0d099246ba 100644
(file)
--- a/
IkiWiki/Plugin/trail.pm
+++ b/
IkiWiki/Plugin/trail.pm
@@
-88,6
+88,8
@@
sub needsbuild (@) {
return $needsbuild;
}
return $needsbuild;
}
+my $scanned = 0;
+
=for wiki
The `trail` directive is supplied by the [[plugins/contrib/trail]]
=for wiki
The `trail` directive is supplied by the [[plugins/contrib/trail]]
@@
-112,6
+114,15
@@
The available options are:
sub preprocess_trail (@) {
my %params = @_;
sub preprocess_trail (@) {
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;
+ }
+
if (exists $params{circular}) {
$pagestate{$params{page}}{trail}{circular} =
IkiWiki::yesno($params{circular});
if (exists $params{circular}) {
$pagestate{$params{page}}{trail}{circular} =
IkiWiki::yesno($params{circular});
@@
-166,14
+177,20
@@
to the trail.
=cut
sub preprocess_trailinline (@) {
=cut
sub preprocess_trailinline (@) {
- preprocess_trail(@_);
- return unless defined wantarray;
+ my %params = @_;
+
+ if (defined wantarray) {
+ scalar preprocess_trail(%params);
- if (IkiWiki->can("preprocess_inline")) {
- return IkiWiki::preprocess_inline(@_);
+ if (IkiWiki->can("preprocess_inline")) {
+ return IkiWiki::preprocess_inline(@_);
+ }
+ else {
+ error("trailinline directive requires the inline plugin");
+ }
}
else {
}
else {
-
error("trailinline directive requires the inline plugin"
);
+
preprocess_trail(%params
);
}
}
}
}
@@
-193,6
+210,15
@@
sub preprocess_trailitem (@) {
my $link = shift;
shift;
my $link = shift;
shift;
+ # avoid collecting everything in the preprocess stage if we already
+ # did in the scan stage
+ if (defined wantarray) {
+ return "" if $scanned;
+ }
+ else {
+ $scanned = 1;
+ }
+
my %params = @_;
my $trail = $params{page};
my %params = @_;
my $trail = $params{page};
@@
-242,7
+268,18
@@
sub preprocess_traillink (@) {
$link = linkpage($2);
add_link($params{page}, $link, 'trail');
$link = linkpage($2);
add_link($params{page}, $link, 'trail');
- push @{$pagestate{$params{page}}{trail}{contents}}, "link $link";
+
+ # avoid collecting everything in the preprocess stage if we already
+ # did in the scan stage
+ my $already;
+ if (defined wantarray) {
+ $already = $scanned;
+ }
+ else {
+ $scanned = 1;
+ }
+
+ push @{$pagestate{$params{page}}{trail}{contents}}, [link => $link] unless $already;
if (defined $linktext) {
$linktext = pagetitle($linktext);
if (defined $linktext) {
$linktext = pagetitle($linktext);