From c6bf4228d5c988e715ff08a9374b72ce054daa2c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 5 Oct 2009 15:01:05 -0400 Subject: [PATCH] make links dependencies fire if broken links change --- IkiWiki/Render.pm | 41 ++++++++++++++++++++++++++++------------- doc/plugins/write.mdwn | 6 ++++-- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 4e8aae3bc..599bb26e2 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -63,24 +63,39 @@ sub find_changed_links (@_) { my %linkchangers; foreach my $file (@_) { my $page=pagename($file); - + if (exists $links{$page}) { - foreach my $link (map { bestlink($page, $_) } @{$links{$page}}) { - if (length $link && - (! exists $oldlinks{$page} || - ! grep { bestlink($page, $_) eq $link } @{$oldlinks{$page}})) { - $linkchanged{$link}=1; - $linkchangers{lc($page)}=1; + foreach my $l (@{$links{$page}}) { + my $link=bestlink($page, $l); + if (length $link) { + if (! exists $oldlinks{$page} || + ! grep { bestlink($page, $_) eq $link } @{$oldlinks{$page}}) { + $linkchanged{$link}=1; + $linkchangers{lc($page)}=1; + } + } + else { + if (! grep { lc $_ eq lc $l } @{$oldlinks{$page}}) { + $linkchangers{lc($page)}=1 + } } + } } if (exists $oldlinks{$page}) { - foreach my $link (map { bestlink($page, $_) } @{$oldlinks{$page}}) { - if (length $link && - (! exists $links{$page} || - ! grep { bestlink($page, $_) eq $link } @{$links{$page}})) { - $linkchanged{$link}=1; - $linkchangers{lc($page)}=1; + foreach my $l (@{$oldlinks{$page}}) { + my $link=bestlink($page, $l); + if (length $link) { + if (! exists $links{$page} || + ! grep { bestlink($page, $_) eq $link } @{$links{$page}}) { + $linkchanged{$link}=1; + $linkchangers{lc($page)}=1; + } + } + else { + if (! grep { lc $_ eq lc $l } @{$links{$page}}) { + $linkchangers{lc($page)}=1 + } } } } diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 73db6f12a..133030f08 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -620,8 +620,10 @@ used to indicate weaker types of dependencies: * `presence` if set to true, only the presence of a matching page triggers the dependency. -* `links` if set to true, any change in the text of links on a matching page - triggers the dependency +* `links` if set to true, any change to links on a matching page + triggers the dependency. This includes when a link is added, removed, + or changes what it points to due to other changes. It does not include + the addition or removal of a duplicate link. #### `pagespec_match($$;@)` -- 2.45.0