aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2013-01-02 19:14:26 +0000
committerSimon McVittie <smcv@debian.org>2013-01-02 19:19:32 +0000
commit7b06a65221ae16bf447c591dba5712c1d9f00461 (patch)
treecf19405c342a2f97863989a97dfdca0649c4f9f6 /IkiWiki
parent94a51309635b799fd25aeaf60d90fab25939343e (diff)
downloadikiwiki-7b06a65221ae16bf447c591dba5712c1d9f00461.tar
ikiwiki-7b06a65221ae16bf447c591dba5712c1d9f00461.tar.gz
If the title of a trail or trail-member changes, rebuild affected pages
If the title of a trail changes, each member of that trail must be rebuilt, for its prev/up/next box to reflect the new title. If the title of a member changes, its next and previous items (if any) must be rebuilt, for their prev/up/next boxes to reflect the new title.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/trail.pm26
1 files changed, 26 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/trail.pm b/IkiWiki/Plugin/trail.pm
index 86c94642a..b1bb6d5b5 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) {