]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/search.pm
inline: Call indexhtml when inlining internal pages, so their text can be indexed...
[ikiwiki.git] / IkiWiki / Plugin / search.pm
index 55edf8752a8e04c4abbe9e320f36922ad13b0884..c578b44ab2693326d083a640d18f8c88cf06b042 100644 (file)
@@ -10,7 +10,7 @@ sub import {
        hook(type => "getsetup", id => "search", call => \&getsetup);
        hook(type => "checkconfig", id => "search", call => \&checkconfig);
        hook(type => "pagetemplate", id => "search", call => \&pagetemplate);
-       hook(type => "postscan", id => "search", call => \&index);
+       hook(type => "indexhtml", id => "search", call => \&indexhtml);
        hook(type => "delete", id => "search", call => \&delete);
        hook(type => "cgi", id => "search", call => \&cgi);
 }
@@ -41,6 +41,10 @@ sub checkconfig () {
        if (! defined $config{omega_cgi}) {
                $config{omega_cgi}="/usr/lib/cgi-bin/omega/omega";
        }
+
+       # This is a mass dependency, so if the search form template
+       # changes, every page is rebuilt.
+       add_depends("", "templates/searchform.tmpl");
 }
 
 my $form;
@@ -52,8 +56,9 @@ sub pagetemplate (@) {
        # Add search box to page header.
        if ($template->query(name => "searchform")) {
                if (! defined $form) {
-                       my $searchform = template_depends("searchform.tmpl", $page, blind_cache => 1);
+                       my $searchform = template("searchform.tmpl", blind_cache => 1);
                        $searchform->param(searchaction => $config{cgiurl});
+                       $searchform->param(html5 => $config{html5});
                        $form=$searchform->output;
                }
 
@@ -63,7 +68,7 @@ sub pagetemplate (@) {
 
 my $scrubber;
 my $stemmer;
-sub index (@) {
+sub indexhtml (@) {
        my %params=@_;
 
        setupfiles();
@@ -112,7 +117,7 @@ sub index (@) {
        eval q{use HTML::Entities};
        error $@ if $@;
        $doc->set_data(
-               "url=".urlto($params{page}, "")."\n".
+               "url=".urlto($params{destpage}, "")."\n".
                "sample=".decode_entities($sample)."\n".
                "caption=".decode_entities($caption)."\n".
                "modtime=$IkiWiki::pagemtime{$params{page}}\n".