make links dependencies fire if broken links change
authorJoey Hess <joey@gnu.kitenet.net>
Mon, 5 Oct 2009 19:01:05 +0000 (15:01 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Mon, 5 Oct 2009 19:01:05 +0000 (15:01 -0400)
IkiWiki/Render.pm
doc/plugins/write.mdwn

index 4e8aae3bc8ea187cd82f0d8b17d17b84dfc9e2c8..599bb26e2b382a7b139f3fc415db9442a11c195a 100644 (file)
@@ -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
+                                       }
                                }
                        }
                }
index 73db6f12abfc5432d132a1a77ba2023b05ee79b9..133030f08fc5bef55dc7dcf2fbca03add189a2db 100644 (file)
@@ -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($$;@)`