Added my site, even though it's in an early state
[ikiwiki.git] / IkiWiki / Plugin / google.pm
blob68cde261c66748c5d32475657986ce9d465fbbbf
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::google;
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
7 use URI;
9 sub import {
10 hook(type => "getsetup", id => "google", call => \&getsetup);
11 hook(type => "checkconfig", id => "google", call => \&checkconfig);
12 hook(type => "pagetemplate", id => "google", call => \&pagetemplate);
15 sub getsetup () {
16 return
17 plugin => {
18 safe => 1,
19 rebuild => 1,
20 section => "web",
24 sub checkconfig () {
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");
34 my $form;
35 sub pagetemplate (@) {
36 my %params=@_;
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);