]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/search.pm
more links
[git.ikiwiki.info.git] / IkiWiki / Plugin / search.pm
index 213ed45ff29c00c19769cbee3ec00faf991ae667..c79d4046954535ce340169cf9169b89c1e75ba6a 100644 (file)
@@ -9,6 +9,8 @@ use IkiWiki;
 sub import { #{{{
        IkiWiki::hook(type => "checkconfig", id => "hyperestraier",
                call => \&checkconfig);
 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",
        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");
                }
        }
                        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" />
 <form method="get" action="$IkiWiki::config{cgiurl}" id="searchform">
 <div>
 <input type="text" name="phrase" value="" size="16" />
@@ -32,7 +42,8 @@ sub checkconfig () { #{{{
 <input type="hidden" name="do" value="hyperestraier" />
 </div>
 </form>
 <input type="hidden" name="do" value="hyperestraier" />
 </div>
 </form>
-};
+});
+       }
 } #}}}
 
 sub delete (@) { #{{{
 } #}}}
 
 sub delete (@) { #{{{
@@ -79,9 +90,7 @@ sub estcfg () { #{{{
        close TEMPLATE;
        open(TEMPLATE, ">$estdir/$cgi.conf") ||
                error("write $estdir/$cgi.conf: $!");
        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,
        eval q{use Cwd 'abs_path'};
        $template->param(
                index => $estdir,