use strict;
use IkiWiki;
-my (%backlinks, %rendered);
+my (%backlinks, %rendered, %scanned);
our %brokenlinks;
my $links_calculated=0;
}
templateactions($template, $page);
- my @backlinks=sort { $a->{page} cmp $b->{page} } backlinks($page);
+ my @backlinks=sort { $a->{page} cmp $b->{page} || $a->{url} cmp $b->{url} } backlinks($page);
my ($backlinks, $more_backlinks);
if (@backlinks <= $config{numbacklinks} || ! $config{numbacklinks}) {
$backlinks=\@backlinks;
ctime => displaytime($pagectime{$page}, undef, 1),
baseurl => baseurl($page),
html5 => $config{html5},
+ responsive_layout => $config{responsive_layout},
);
run_hooks(pagetemplate => sub {
sub scan ($) {
my $file=shift;
+ return if ($config{rebuild} && $phase > PHASE_SCAN) || $scanned{$file};
+ $scanned{$file}=1;
debug(sprintf(gettext("scanning %s"), $file));
$page = pagename($file);
if (! exists $pagesources{$page} &&
file_pruned($file)) {
+ no warnings 'once';
$File::Find::prune=1;
return;
}
else {
push @files, $f;
if ($pages{$page}) {
- debug(sprintf(gettext("%s has multiple possible source pages"), $page));
+ debug(sprintf(gettext("%s has multiple possible source files; one will be chosen at random"), $page));
}
$pages{$page}=1;
}
}
push @files, $f;
if ($pages{$page}) {
- debug(sprintf(gettext("%s has multiple possible source pages"), $page));
+ debug(sprintf(gettext("%s has multiple possible source files; one will be chosen at random"), $page));
}
$pages{$page}=1;
}
}
$pagecase{lc $page}=$page;
if (! exists $pagectime{$page}) {
- $pagectime{$page}=(srcfile_stat($file))[10];
+ my @stat=srcfile_stat($file, 1);
+ # For the creation time of the page, take the
+ # inode change time (not creation time!) or
+ # the modification time, whichever is older.
+ my $ctime=($stat[10] < $stat[9] ? $stat[10] : $stat[9]);
+ $pagectime{$page}=$ctime if defined $ctime;
}
}
}
my @internal_changed;
foreach my $file (@$files) {
my $page=pagename($file);
- my ($srcfile, @stat)=srcfile_stat($file);
- if (! exists $pagemtime{$page} ||
- $stat[9] > $pagemtime{$page} ||
- $forcerebuild{$page}) {
+ my ($srcfile, @stat)=srcfile_stat($file, 1);
+ if (defined $srcfile &&
+ (! exists $pagemtime{$page} ||
+ $stat[9] > $pagemtime{$page} ||
+ $forcerebuild{$page})) {
$pagemtime{$page}=$stat[9];
if (isinternal($page)) {
return 1;
}
-sub want_find_changes {
- $config{only_committed_changes} &&
- exists $IkiWiki::hooks{rcs}{rcs_find_changes} &&
- exists $IkiWiki::hooks{rcs}{rcs_get_current_rev}
-}
-
sub refresh () {
+ $phase = PHASE_SCAN;
+
srcdir_check();
run_hooks(refresh => sub { shift->() });
my ($files, $pages, $new, $internal_new, $del, $internal_del, $changed, $internal_changed);
- if (! $config{rebuild} && want_find_changes() && defined $IkiWiki::lastrev) {
+ my $want_find_changes=$config{only_committed_changes} &&
+ exists $IkiWiki::hooks{rcs}{rcs_find_changes} &&
+ exists $IkiWiki::hooks{rcs}{rcs_get_current_rev};
+ if (! $config{rebuild} && $want_find_changes && defined $IkiWiki::lastrev && length $IkiWiki::lastrev) {
my ($changed_raw, $del_raw);
($changed_raw, $del_raw, $IkiWiki::lastrev) = $IkiWiki::hooks{rcs}{rcs_find_changes}{call}->($IkiWiki::lastrev);
($files, $pages)=process_changed_files($changed_raw, $del_raw);
else {
($files, $pages)=find_src_files();
}
- if (want_find_changes()) {
- if (! defined($IkiWiki::lastrev)) {
+ if ($want_find_changes) {
+ if (! defined($IkiWiki::lastrev) || ! length $IkiWiki::lastrev) {
$IkiWiki::lastrev=$IkiWiki::hooks{rcs}{rcs_get_current_rev}{call}->();
}
}
}
calculate_links();
-
+
+ # At this point it becomes OK to start matching pagespecs.
+ $phase = PHASE_RENDER;
+ # Save some memory in full rebuilds: we no longer need to keep
+ # track of which pages we've scanned, because we can assume the
+ # answer is "all of them".
+ %scanned = () if $config{rebuild};
+
remove_del(@$del, @$internal_del);
foreach my $file (@$changed) {
loadindex();
unlockwiki();
+ # This function behaves as though it's in the render phase;
+ # all other files are assumed to have been scanned last time.
+ $phase = PHASE_RENDER;
+
my $srcfile=possibly_foolish_untaint($config{render});
my $file=$srcfile;
$file=~s/\Q$config{srcdir}\E\/?//;