* 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.
master
joey 2006-07-30 00:20:11 +00:00
parent 584fe78075
commit ab75c0323b
10 changed files with 82 additions and 67 deletions

View File

@ -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

View File

@ -567,11 +567,7 @@ sub cgi () { #{{{
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) {

View File

@ -58,7 +58,7 @@ sub preprocess_inline (@) { #{{{
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});
@ -88,15 +88,10 @@ sub preprocess_inline (@) { #{{{
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;
@ -181,13 +176,10 @@ sub genrss ($@) { #{{{
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;
} #}}}

View File

@ -29,6 +29,8 @@ sub import { #{{{
call => \&change);
IkiWiki::hook(type => "cgi", id => "skeleton",
call => \&cgi);
IkiWiki::hook(type => "cgi", id => "savestate",
call => \&savestate);
} # }}}
sub getopt () { #{{{
@ -95,4 +97,8 @@ sub cgi ($) { #{{{
IkiWiki::debug("skeleton plugin running in cgi");
} #}}}
sub savestate () { #{{{
IkiWiki::debug("skeleton plugin running in savestate");
} #}}}
1

View File

@ -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 (%rendered && exists $hooks{change}) {
foreach my $id (keys %{$hooks{change}}) {
$hooks{change}{$id}{call}->(keys %rendered);
if (@del) {
run_hooks(delete => sub { shift->(@del) });
}
if (%rendered) {
run_hooks(change => sub { shift->(keys %rendered) });
}
} #}}}

10
debian/changelog vendored
View File

@ -1,3 +1,13 @@
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!"

View File

@ -4,15 +4,23 @@ into html pages suitable for publishing on a website. Unlike a traditional
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.

View File

@ -157,6 +157,14 @@ called in turn, and passed a CGI object. The hook should examine the
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`

View File

@ -15,3 +15,10 @@ poor-man's news aggregator.
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)

View File

@ -68,11 +68,7 @@ sub getconfig () { #{{{
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;