+
+ # handle linkbacks; if a page has added/removed links, update the
+ # pages it links to
+ # TODO: inefficient; pages may get rendered above and again here;
+ # problem is the linkbacks could be wrong in the first pass render
+ # above.
+ if (%rendered) {
+ my %linkchanged;
+ foreach my $file (keys %rendered, @del) {
+ my $pagename=pagename($file);
+ if (exists $links{$pagename}) {
+ foreach my $link (@{$links{$pagename}}) {
+ if (! exists $oldlinks{$pagename} ||
+ ! grep { $_ eq $link } @{$oldlinks{$pagename}}) {
+ $linkchanged{$link}=1;
+ }
+ }
+ }
+ if (exists $oldlinks{$pagename}) {
+ foreach my $link (@{$oldlinks{$pagename}}) {
+ if (! exists $links{$pagename} ||
+ ! grep { $_ eq $link } @{$links{$pagename}}) {
+ $linkchanged{$link}=1;
+ }
+ }
+ }
+ }
+ foreach my $link (keys %linkchanged) {
+ my $linkfile=$pagesources{$link};
+ if (defined $linkfile) {
+ debug("rendering $linkfile, to update its linkbacks");
+ render($linkfile);
+ }
+ }
+ }