given type.
* Add a savestate hook.
* Don't put blog post forms on pages if there's no cgiurl set.
* Reformat front page.
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 () { #{{{
$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
my $q=CGI->new;
- if (exists $hooks{cgi}) {
- foreach my $id (keys %{$hooks{cgi}}) {
- $hooks{cgi}{$id}{call}->($q);
- }
- }
+ run_hooks(cgi => sub { shift->($q) });
my $do=$q->param('do');
if (! defined $do || ! length $do) {
my $ret="";
- if (exists $params{rootpage}) {
+ if (exists $params{rootpage} && $config{cgiurl}) {
# Add a blog post form, with a rss link button.
my $formtemplate=template("blogpost.tmpl", blind_cache => 1);
$formtemplate->param(cgiurl => $config{cgiurl});
if $params{archive} eq "no";
$template->param(ctime => displaytime($pagectime{$page}));
- if (exists $hooks{pagetemplate}) {
- foreach my $id (keys %{$hooks{pagetemplate}}) {
- $hooks{pagetemplate}{$id}{call}->(
- page => $page,
- destpage => $params{page},
- template => $template,
- );
- }
- }
+ run_hooks(pagetemplate => sub {
+ shift->(page => $page, destpage => $params{page},
+ template => $template,);
+ });
$ret.=$template->output;
$template->clear_params;
items => \@items,
);
- 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;
} #}}}
call => \&change);
IkiWiki::hook(type => "cgi", id => "skeleton",
call => \&cgi);
+ IkiWiki::hook(type => "cgi", id => "savestate",
+ call => \&savestate);
} # }}}
sub getopt () { #{{{
IkiWiki::debug("skeleton plugin running in cgi");
} #}}}
+sub savestate () { #{{{
+ IkiWiki::debug("skeleton plugin running in savestate");
+} #}}}
+
1
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;
} #}}}
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;
} #}}}
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;
}
}
}
- 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) });
}
} #}}}
+ikiwiki (1.13) UNRELEASED; urgency=low
+
+ * 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.
+
+ -- Joey Hess <joeyh@debian.org> Sat, 29 Jul 2006 20:10:51 -0400
+
ikiwiki (1.12) unstable; urgency=low
"Viva l'Italia!"
wiki, ikiwiki does not have its own means of storing page history.
Instead it can use [[Subversion]] (or [[Git]]).
-* [[News]] is a blog (built using ikiwiki) of news items about ikiwiki. It's the best way to find out when there's a new version to [[Download]].
+* [[News]] is a blog (built using ikiwiki) of news items about ikiwiki.
+ It's the best way to find out when there's a new version to [[Download]].
-* See [[Features]] for a list of ikiwiki's features. [[RoadMap]], [[TODO]] and [[bugs]] might also be of interest. Feel free to post your thoughts about ikiwiki to [[Discussion]].
+* See [[Features]] for a list of ikiwiki's features. [[RoadMap]], [[TODO]]
+ and [[bugs]] might also be of interest. Feel free to post your thoughts
+ about ikiwiki to [[Discussion]].
-* [[Setup]] has a tutorial for setting up ikiwiki, and [[Usage]] documents the parameters and usage of the ikiwiki program. If you use ikiwiki, please add your wiki to [[IkiWikiUsers]].
+* [[Setup]] has a tutorial for setting up ikiwiki, and [[Usage]] documents
+ the parameters and usage of the ikiwiki program. If you use ikiwiki,
+ please add your wiki to [[IkiWikiUsers]].
-* [[Security]] lists potential security problems. ikiwiki is still being developed, and is being written with security as a priority, so don't expect things to stay in this list for long.
+* [[Security]] lists potential security problems. ikiwiki is still being
+ developed, and is being written with security as a priority, so don't
+ expect things to stay in this list for long.
-* Developers, please document any ikiwiki patches you have in the [[PatchQueue]].
+* Developers, please document any ikiwiki patches you have in the
+ [[PatchQueue]].
All wikis are supposed to have a [[SandBox]], so this one does too.
parameters, and if it will handle this CGI request, output a page and
terminate the program.
+## savestate
+
+ IkiWiki::hook(type => "savestate", id => "foo", call => \&savestate);
+
+This hook is called wheneven ikiwiki normally saves its state, just before
+the state is saved. The function can save other state, modify values before
+they're saved, etc.
+
# Wiki configuration
A plugin can access the wiki's configuration via the `%IkiWiki::config`
better would be to use preprocessor directives in a wiki page, probably
the same page that inlines all the pages together.
* Where to store when a feed was last pulled?
+
+So I need:
+
+* A way to store info from the preprocessor directives about what pages
+ to pull and expiry.
+* A way to store info on last pull time, guids, etc.
+* Switch for a mode that a) pulls b) expires old c) rebuilds wiki (for cron)
if (! $config{setup}) {
loadplugins();
- if (exists $hooks{getopt}) {
- foreach my $id (keys %{$hooks{getopt}}) {
- $hooks{getopt}{$id}{call}->();
- }
- }
+ run_hooks(getopt => sub { shift->() });
if (grep /^-/, @ARGV) {
print STDERR "Unknown option: $_\n"
foreach grep /^-/, @ARGV;