aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Render.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/Render.pm
parent584fe78075793b2b5dc2992125e88188cae0d1c7 (diff)
downloadikiwiki-ab75c0323bc584203a2b4a507c2a2012523354d0.tar
ikiwiki-ab75c0323bc584203a2b4a507c2a2012523354d0.tar.gz
* 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/Render.pm')
-rw-r--r--IkiWiki/Render.pm43
1 files changed, 13 insertions, 30 deletions
diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm
index caec7f1f0..5dbb4654c 100644
--- a/IkiWiki/Render.pm
+++ b/IkiWiki/Render.pm
@@ -31,11 +31,9 @@ sub htmlize ($$) { #{{{
error("htmlization of $type not supported");
}
- if (exists $hooks{sanitize}) {
- foreach my $id (keys %{$hooks{sanitize}}) {
- $content=$hooks{sanitize}{$id}{call}->($content);
- }
- }
+ run_hooks(sanitize => sub {
+ $content=shift->($content);
+ });
return $content;
} #}}}
@@ -206,15 +204,9 @@ sub genpage ($$$) { #{{{
styleurl => styleurl($page),
);
- if (exists $hooks{pagetemplate}) {
- foreach my $id (keys %{$hooks{pagetemplate}}) {
- $hooks{pagetemplate}{$id}{call}->(
- page => $page,
- destpage => $page,
- template => $template,
- );
- }
- }
+ run_hooks(pagetemplate => sub {
+ shift->(page => $page, destpage => $page, template => $template);
+ });
return $template->output;
} #}}}
@@ -268,14 +260,9 @@ sub filter ($$) {
my $page=shift;
my $content=shift;
- if (exists $hooks{filter}) {
- foreach my $id (keys %{$hooks{filter}}) {
- $content=$hooks{filter}{$id}{call}->(
- page => $page,
- content => $content
- );
- }
- }
+ run_hooks(filter => sub {
+ $content=shift->(page => $page, content => $content);
+ });
return $content;
}
@@ -496,15 +483,11 @@ FILE: foreach my $file (@files) {
}
}
- if (@del && exists $hooks{delete}) {
- foreach my $id (keys %{$hooks{delete}}) {
- $hooks{delete}{$id}{call}->(@del);
- }
+ if (@del) {
+ run_hooks(delete => sub { shift->(@del) });
}
- if (%rendered && exists $hooks{change}) {
- foreach my $id (keys %{$hooks{change}}) {
- $hooks{change}{$id}{call}->(keys %rendered);
- }
+ if (%rendered) {
+ run_hooks(change => sub { shift->(keys %rendered) });
}
} #}}}