From 72c53650ad4a708493880daa75cdda9d056fc75e Mon Sep 17 00:00:00 2001 From: joey Date: Wed, 9 May 2007 00:48:09 +0000 Subject: * Add the needsbuild hook. Plugins can use this to manipulate which files ikiwiki builds when refreshing the wiki. --- IkiWiki/Plugin/skeleton.pm | 5 +++++ IkiWiki/Render.pm | 21 ++++++++++++--------- 2 files changed, 17 insertions(+), 9 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/skeleton.pm b/IkiWiki/Plugin/skeleton.pm index b8c327c9d..fb4cfe9af 100644 --- a/IkiWiki/Plugin/skeleton.pm +++ b/IkiWiki/Plugin/skeleton.pm @@ -11,6 +11,7 @@ use IkiWiki 2.00; sub import { #{{{ hook(type => "getopt", id => "skeleton", call => \&getopt); hook(type => "checkconfig", id => "skeleton", call => \&checkconfig); + hook(type => "needsbuild", id => "skeleton", call => \&needsbuild); hook(type => "preprocess", id => "skeleton", call => \&preprocess); hook(type => "filter", id => "skeleton", call => \&filter); hook(type => "htmlize", id => "skeleton", call => \&htmlize); @@ -35,6 +36,10 @@ sub checkconfig () { #{{{ debug("skeleton plugin checkconfig"); } #}}} +sub needsbuild () { #{{{ + debug("skeleton plugin needsbuild"); +} #}}} + sub preprocess (@) { #{{{ my %params=@_; diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 0b7e00d9d..37383384d 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -318,8 +318,8 @@ sub refresh () { #{{{ } } - # scan changed and new files - my @changed; + # find changed and new files + my @needsbuild; foreach my $file (@files) { my $page=pagename($file); @@ -327,16 +327,19 @@ sub refresh () { #{{{ if (! exists $pagemtime{$page} || $mtime > $pagemtime{$page} || $forcerebuild{$page}) { - debug(sprintf(gettext("scanning %s"), $file)); - $pagemtime{$page}=$mtime; - push @changed, $file; - scan($file); + $pagemtime{$page}=$mtime; + push @needsbuild, $file; } } - calculate_backlinks(); + run_hooks(needsbuild => sub { shift->(\@needsbuild) }); - # render changed and new pages - foreach my $file (@changed) { + # scan and rendder files + foreach my $file (@needsbuild) { + debug(sprintf(gettext("scanning %s"), $file)); + scan($file); + } + calculate_backlinks(); + foreach my $file (@needsbuild) { debug(sprintf(gettext("rendering %s"), $file)); render($file); $rendered{$file}=1; -- cgit v1.2.3