diff options
author | Joey Hess <joey@kitenet.net> | 2013-01-02 15:31:10 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2013-01-02 15:31:10 -0400 |
commit | 22cb87c6849dd2baf0c944f1d546f4318e67b325 (patch) | |
tree | 4d4248b8b279add30c768fcca2dc090daa4bda10 /IkiWiki | |
parent | 812a5a136d522107053a15fdb3e518054c44a0e1 (diff) | |
parent | 7029f98bc735efcec08213d51bdec2c6645d682d (diff) | |
download | ikiwiki-22cb87c6849dd2baf0c944f1d546f4318e67b325.tar ikiwiki-22cb87c6849dd2baf0c944f1d546f4318e67b325.tar.gz |
Merge remote-tracking branch 'smcv/ready/trail'
Diffstat (limited to 'IkiWiki')
-rw-r--r-- | IkiWiki/Plugin/trail.pm | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/IkiWiki/Plugin/trail.pm b/IkiWiki/Plugin/trail.pm index cf0f0a15e..cb94855fd 100644 --- a/IkiWiki/Plugin/trail.pm +++ b/IkiWiki/Plugin/trail.pm @@ -62,12 +62,20 @@ sub getsetup () { }, } +# Cache of pages' old titles, so we can tell whether they changed +my %old_trail_titles; + sub needsbuild (@) { my $needsbuild=shift; + foreach my $page (keys %pagestate) { if (exists $pagestate{$page}{trail}) { if (exists $pagesources{$page} && grep { $_ eq $pagesources{$page} } @$needsbuild) { + # Remember its title, so we can know whether + # it changed. + $old_trail_titles{$page} = title_of($page); + # Remove state, it will be re-added # if the preprocessor directive is still # there during the rebuild. {item} is the @@ -78,6 +86,7 @@ sub needsbuild (@) { } } } + return $needsbuild; } @@ -230,6 +239,12 @@ sub trails_differ { if (! exists $new->{$trail}) { return 1; } + + if (exists $old_trail_titles{$trail} && + title_of($trail) ne $old_trail_titles{$trail}) { + return 1; + } + my ($old_p, $old_n) = @{$old->{$trail}}; my ($new_p, $new_n) = @{$new->{$trail}}; $old_p = "" unless defined $old_p; @@ -239,9 +254,20 @@ sub trails_differ { if ($old_p ne $new_p) { return 1; } + + if (exists $old_trail_titles{$old_p} && + title_of($old_p) ne $old_trail_titles{$old_p}) { + return 1; + } + if ($old_n ne $new_n) { return 1; } + + if (exists $old_trail_titles{$old_n} && + title_of($old_n) ne $old_trail_titles{$old_n}) { + return 1; + } } foreach my $trail (keys %$new) { @@ -318,8 +344,6 @@ sub prerender { $prev = $members->[$i - 1] if $i > 0; my $next = $members->[$i + 1]; - add_depends($member, $trail, deptype("presence")); - $member_to_trails{$member}{$trail} = [$prev, $next]; } @@ -359,6 +383,12 @@ sub prerender { sub build_affected { my %affected; + # In principle we might not have done this yet, although in practice + # at least the trail itself has probably changed, and its template + # almost certainly contains TRAILS or TRAILLOOP, triggering our + # prerender as a side-effect. + prerender(); + foreach my $member (keys %rebuild_trail_members) { $affected{$member} = sprintf(gettext("building %s, its previous or next page has changed"), $member); } @@ -406,13 +436,11 @@ sub pagetemplate (@) { my ($prevurl, $nexturl, $prevtitle, $nexttitle); if (defined $prev) { - add_depends($params{destpage}, $prev, deptype("presence")); $prevurl = urlto($prev, $page); $prevtitle = title_of($prev); } if (defined $next) { - add_depends($params{destpage}, $next, deptype("presence")); $nexturl = urlto($next, $page); $nexttitle = title_of($next); } |