sub import { #{{{
IkiWiki::hook(type => "checkconfig", id => "hyperestraier",
call => \&checkconfig);
+ IkiWiki::hook(type => "pagetemplate", id => "hyperestraier",
+ call => \&pagetemplate);
IkiWiki::hook(type => "delete", id => "hyperestraier",
call => \&delete);
- IkiWiki::hook(type => "render", id => "hyperestraier",
- call => \&render);
+ IkiWiki::hook(type => "change", id => "hyperestraier",
+ call => \&change);
IkiWiki::hook(type => "cgi", id => "hyperestraier",
call => \&cgi);
} # }}}
IkiWiki::error("Must specify $required when using the search plugin\n");
}
}
+} #}}}
+
+sub pagetemplate (@) { #{{{
+ my %params=@_;
+ my $page=$params{page};
+ my $template=$params{template};
- $IkiWiki::config{headercontent}.=qq{
+ # Add search box to page header.
+ if ($template->query(name => "searchform")) {
+ $template->param(searchform => qq{
<form method="get" action="$IkiWiki::config{cgiurl}" id="searchform">
<div>
<input type="text" name="phrase" value="" size="16" />
<input type="hidden" name="do" value="hyperestraier" />
</div>
</form>
-};
+});
+ }
} #}}}
sub delete (@) { #{{{
IkiWiki::estcfg();
} #}}}
-sub render (@) { #{{{
+sub change (@) { #{{{
IkiWiki::debug("updating hyperestraier search index");
IkiWiki::estcmd("gather -cm -bc -cl -sd",
map {
close TEMPLATE;
open(TEMPLATE, ">$estdir/$cgi.conf") ||
error("write $estdir/$cgi.conf: $!");
- my $template=HTML::Template->new(
- filename => "$config{templatedir}/estseek.conf"
- );
+ my $template=template("estseek.conf");
eval q{use Cwd 'abs_path'};
$template->param(
index => $estdir,