X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/6a9e16374f1549c7e63c7cd1c0e6989b2fb32191..22adebe8adf9ddf2a064c54b9c1e4c0e8799907b:/IkiWiki.pm diff --git a/IkiWiki.pm b/IkiWiki.pm index 085953a17..b5707195b 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -11,7 +11,7 @@ use Memoize; memoize("abs2rel"); use vars qw{%config %links %oldlinks %oldpagemtime %pagectime - %renderedfiles %pagesources %depends %hooks}; + %renderedfiles %pagesources %depends %hooks %forcerebuild}; sub defaultconfig () { #{{{ wiki_file_prune_regexp => qr{((^|/).svn/|\.\.|^\.|\/\.|\.html?$|\.rss$)}, @@ -61,7 +61,7 @@ sub checkconfig () { #{{{ if (defined $config{locale}) { eval q{use POSIX}; $ENV{LANG} = $config{locale} - if POSIX::setlocale(&POSIX::LANG, $config{locale}); + if POSIX::setlocale(&POSIX::LC_TIME, $config{locale}); } if ($config{w3mmode}) { @@ -93,11 +93,7 @@ sub checkconfig () { #{{{ require IkiWiki::Rcs::Stub; } - if (exists $hooks{checkconfig}) { - foreach my $id (keys %{$hooks{checkconfig}}) { - $hooks{checkconfig}{$id}{call}->(); - } - } + run_hooks(checkconfig => sub { shift->() }); } #}}} sub loadplugins () { #{{{ @@ -399,6 +395,8 @@ sub loadindex () { #{{{ } #}}} sub saveindex () { #{{{ + run_hooks(savestate => sub { shift->() }); + if (! -d $config{wikistatedir}) { mkdir($config{wikistatedir}); } @@ -503,4 +501,17 @@ sub hook (@) { # {{{ $hooks{$param{type}}{$param{id}}=\%param; } # }}} +sub run_hooks ($$) { # {{{ + # Calls the given sub for each hook of the given type, + # passing it the hook function to call. + my $type=shift; + my $sub=shift; + + if (exists $hooks{$type}) { + foreach my $id (keys %{$hooks{$type}}) { + $sub->($hooks{$type}{$id}{call}); + } + } +} #}}} + 1