X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/af9566ff1ae55d273ff96c7ca39e34265623a55d..bd70136ca1b073e1208f6562c05ceadb44633024:/IkiWiki/Plugin/search.pm diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index c71fef76e..c8e0dd580 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -9,10 +9,12 @@ use IkiWiki; 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); } # }}} @@ -23,16 +25,24 @@ sub checkconfig () { #{{{ IkiWiki::error("Must specify $required when using the search plugin\n"); } } +} #}}} + +my $form; +sub pagetemplate (@) { #{{{ + my %params=@_; + my $page=$params{page}; + my $template=$params{template}; + + # Add search box to page header. + if ($template->query(name => "searchform")) { + if (! defined $form) { + my $searchform = IkiWiki::template("searchform.tmpl", blind_cache => 1); + $searchform->param(searchaction => $IkiWiki::config{cgiurl}); + $form=$searchform->output; + } - $IkiWiki::config{headercontent}.=qq{ -
-
- - - -
-
-}; + $template->param(searchform => $form); + } } #}}} sub delete (@) { #{{{ @@ -41,11 +51,11 @@ sub delete (@) { #{{{ IkiWiki::estcfg(); } #}}} -sub render (@) { #{{{ +sub change (@) { #{{{ IkiWiki::debug("updating hyperestraier search index"); IkiWiki::estcmd("gather -cm -bc -cl -sd", map { - $IkiWiki::config{destdir}."/".$IkiWiki::renderedfiles{IkiWiki::pagename($_)} + Encode::encode_utf8($IkiWiki::config{destdir}."/".$IkiWiki::renderedfiles{IkiWiki::pagename($_)}) } @_ ); IkiWiki::estcfg(); @@ -79,9 +89,7 @@ sub estcfg () { #{{{ 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,