summaryrefslogtreecommitdiff
path: root/IkiWiki.pm
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-07-30 00:20:11 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-07-30 00:20:11 +0000
commitab75c0323bc584203a2b4a507c2a2012523354d0 (patch)
treeff4f82fd125bb7976b74d88520bd3cb847fc814d /IkiWiki.pm
parent584fe78075793b2b5dc2992125e88188cae0d1c7 (diff)
* Add a run_hooks function for the common task of running all hooks of a
given type. * Add a savestate hook. * Don't put blog post forms on pages if there's no cgiurl set. * Reformat front page.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r--IkiWiki.pm19
1 files changed, 14 insertions, 5 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index d369d7da8..54ca84550 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -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 () { #{{{
@@ -503,4 +499,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