]> sipb.mit.edu Git - ikiwiki.git/commitdiff
Track whether we're in the scan or render phase
authorSimon McVittie <smcv@debian.org>
Wed, 5 Mar 2014 10:11:04 +0000 (10:11 +0000)
committerSimon McVittie <smcv@debian.org>
Wed, 5 Mar 2014 10:42:19 +0000 (10:42 +0000)
In the scan phase, it's too early to match pagespecs or sort pages;
in the render phase, both of those are OK.

It would be possible to add phases later, renumbering them if necessary
to maintain numerical order.

IkiWiki.pm
IkiWiki/Render.pm
po/po2wiki

index d8cfc31ccb972b5ee615cb041ad64fbeca38cc52..9511c8303dfadc056107ae35e5fb6dca3417911b 100644 (file)
@@ -14,7 +14,7 @@ use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
        %pagestate %wikistate %renderedfiles %oldrenderedfiles
        %pagesources %delpagesources %destsources %depends %depends_simple
        @mass_depends %hooks %forcerebuild %loaded_plugins %typedlinks
-       %oldtypedlinks %autofiles @underlayfiles $lastrev};
+       %oldtypedlinks %autofiles @underlayfiles $lastrev $phase};
 
 use Exporter q{import};
 our @EXPORT = qw(hook debug error htmlpage template template_depends
@@ -34,6 +34,11 @@ our $DEPEND_CONTENT=1;
 our $DEPEND_PRESENCE=2;
 our $DEPEND_LINKS=4;
 
+# Phases of processing.
+sub PHASE_SCAN () { 0 }
+sub PHASE_RENDER () { 1 }
+$phase = PHASE_SCAN;
+
 # Optimisation.
 use Memoize;
 memoize("abs2rel");
index 9e93534c6aca921e89fb86d2df9190cba3c403ba..c88de1e8e5f7f8974729b6e5a52be956149bb3f3 100644 (file)
@@ -827,6 +827,8 @@ sub gen_autofile ($$$) {
 }
 
 sub refresh () {
+       $phase = PHASE_SCAN;
+
        srcdir_check();
        run_hooks(refresh => sub { shift->() });
        my ($files, $pages, $new, $internal_new, $del, $internal_del, $changed, $internal_changed);
@@ -878,7 +880,10 @@ sub refresh () {
        }
 
        calculate_links();
-       
+
+       # At this point it becomes OK to start matching pagespecs.
+       $phase = PHASE_RENDER;
+
        remove_del(@$del, @$internal_del);
 
        foreach my $file (@$changed) {
@@ -942,6 +947,10 @@ sub commandline_render () {
        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\/?//;
index 126aa8e17d0949d0c9a55477268464936092ff33..862aa9d97b7b3a80abe7e0bdbf4b5d7acf371ef0 100755 (executable)
@@ -22,6 +22,8 @@ foreach my $file (@$files) {
        $pagesources{$page}=$file; # used by po plugin functions
 }
 
+$IkiWiki::phase = IkiWiki::PHASE_RENDER;
+
 foreach my $lang (@{$config{po_slave_languages}}) {
        my ($ll, $name)=IkiWiki::Plugin::po::splitlangpair($lang);
        $config{destdir}="../underlays/locale/$ll";