From 830672fd2893494a56d4ac0f731d353bac3580a6 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Tue, 25 Jan 2011 19:31:23 +0100 Subject: [PATCH] post-scan hooks During the scan phase plugins can push anonymous functions into the @post_scan array, to be called after all pages have been scanned. This allows plugin to run actions between the scanning and building phase, which is important for pre-render actions that e.g. need to ensure that pagespec patterns will match correctly. --- IkiWiki.pm | 2 +- IkiWiki/Render.pm | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index 907dc4c75..55bc6a59b 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -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}; + %oldtypedlinks %autofiles @post_scan}; use Exporter q{import}; our @EXPORT = qw(hook debug error htmlpage template template_depends diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 05132a8a8..bf5a01b5f 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -775,6 +775,7 @@ sub refresh () { }); my $oldlink_targets=calculate_old_links($changed, $del); + @post_scan = (); foreach my $file (@$changed) { scan($file); } @@ -789,10 +790,16 @@ sub refresh () { } } + foreach my $proc (@post_scan) { + $proc->(); + } + calculate_links(); remove_del(@$del, @$internal_del); + + foreach my $file (@$changed) { render($file, sprintf(gettext("building %s"), $file)); } -- 2.32.0.93.g670b81a890