my $backlinks_calculated=0;
sub calculate_backlinks () { #{{{
+ return if $backlinks_calculated;
%backlinks=();
foreach my $page (keys %links) {
foreach my $link (@{$links{$page}}) {
sub backlinks ($) { #{{{
my $page=shift;
- calculate_backlinks() unless $backlinks_calculated;
+ calculate_backlinks();
my @links;
return unless $backlinks{$page};
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;
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 $_) {
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 $_) {
scan($file);
}
}
+ calculate_backlinks();
# render changed and new pages
foreach my $file (@changed) {
$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;
}
}
}