2 package IkiWiki::Plugin::google;
10 hook(type => "getsetup", id => "google", call => \&getsetup);
11 hook(type => "checkconfig", id => "google", call => \&checkconfig);
12 hook(type => "pagetemplate", id => "google", call => \&pagetemplate);
25 if (! length $config{url}) {
26 error(sprintf(gettext("Must specify %s when using the %s plugin"), "url", 'google'));
29 # This is a mass dependency, so if the search form template
30 # changes, every page is rebuilt.
31 add_depends("", "templates/googleform.tmpl");
35 sub pagetemplate (@) {
37 my $page=$params{page};
38 my $template=$params{template};
40 # Add search box to page header.
41 if ($template->query(name => "searchform")) {
42 if (! defined $form) {
43 my $searchform = template("googleform.tmpl", blind_cache => 1);
44 $searchform->param(url => $config{url});
45 $searchform->param(html5 => $config{html5});
46 $form=$searchform->output;
49 $template->param(searchform => $form);