X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/74b5fb09aae8166b3614c206a9e7e4a227cd9a16..ff6941cef9a88ea2a0d3af2e5ae1edd09048916b:/IkiWiki/Render.pm?ds=sidebyside diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index f59e54f29..4033468b2 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -11,6 +11,7 @@ my %backlinks; my $backlinks_calculated=0; sub calculate_backlinks () { #{{{ + return if $backlinks_calculated; %backlinks=(); foreach my $page (keys %links) { foreach my $link (@{$links{$page}}) { @@ -26,7 +27,7 @@ sub calculate_backlinks () { #{{{ sub backlinks ($) { #{{{ my $page=shift; - calculate_backlinks() unless $backlinks_calculated; + calculate_backlinks(); my @links; return unless $backlinks{$page}; @@ -154,8 +155,8 @@ sub scan ($) { #{{{ push @links, titlepage($2); } if ($config{discussion}) { - # Discussion links are a special case since they're not in the - # text of the page, but on its template. + # Discussion links are a special case since they're + # not in the text of the page, but on its template. push @links, "$page/discussion"; } $links{$page}=\@links; @@ -212,11 +213,12 @@ sub refresh () { #{{{ my %exists; my @files; eval q{use File::Find}; + error($@) if $@; find({ no_chdir => 1, wanted => sub { $_=decode_utf8($_); - if (/$config{wiki_file_prune_regexp}/) { + if (file_pruned($_, $config{srcdir})) { $File::Find::prune=1; } elsif (! -d $_ && ! -l $_) { @@ -236,7 +238,7 @@ sub refresh () { #{{{ no_chdir => 1, wanted => sub { $_=decode_utf8($_); - if (/$config{wiki_file_prune_regexp}/) { + if (file_pruned($_, $config{underlaydir})) { $File::Find::prune=1; } elsif (! -d $_ && ! -l $_) { @@ -303,6 +305,7 @@ sub refresh () { #{{{ scan($file); } } + calculate_backlinks(); # render changed and new pages foreach my $file (@changed) { @@ -311,22 +314,16 @@ sub refresh () { #{{{ $rendered{$file}=1; } - # if any files were added or removed, check to see if each page - # needs an update due to linking to them or inlining them + # rebuild pages that link to added or removed pages if (@add || @del) { -FILE: foreach my $file (@files) { - next if $rendered{$file}; - my $page=pagename($file); - foreach my $f (@add, @del) { - my $p=pagename($f); - foreach my $link (@{$links{$page}}) { - if (bestlink($page, $link) eq $p) { - debug("rendering $file, which links to $p"); - render($file); - $rendered{$file}=1; - next FILE; - } - } + foreach my $f (@add, @del) { + my $p=pagename($f); + foreach my $page (keys %{$backlinks{$p}}) { + my $file=$pagesources{$page}; + next if $rendered{$file}; + debug("rendering $file, which links to $p"); + render($file); + $rendered{$file}=1; } } }