X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/157df8591f03ade7504ad732446f125ae8609b05..119e3e209dc2be25920d89e470a1e8d7b5d98f7b:/IkiWiki/Plugin/search.pm diff --git a/IkiWiki/Plugin/search.pm b/IkiWiki/Plugin/search.pm index 213ed45ff..751c75ab5 100644 --- a/IkiWiki/Plugin/search.pm +++ b/IkiWiki/Plugin/search.pm @@ -9,6 +9,8 @@ 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 => "change", id => "hyperestraier", @@ -23,8 +25,16 @@ sub checkconfig () { #{{{ 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{
-}; +}); + } } #}}} sub delete (@) { #{{{ @@ -45,7 +56,7 @@ 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 +90,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,