]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/google.pm
httpauth: Add cgiauthurl setting that can be used to do http basic auth only when...
[git.ikiwiki.info.git] / IkiWiki / Plugin / google.pm
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);
13 }
15 sub getsetup () {
16         return
17                 plugin => {
18                         safe => 1,
19                         rebuild => 1,
20                 },
21 }
23 sub checkconfig () {
24         if (! length $config{url}) {
25                 error(sprintf(gettext("Must specify %s when using the %s plugin"), "url", 'google'));
26         }
27 }
29 my $form;
30 sub pagetemplate (@) {
31         my %params=@_;
32         my $page=$params{page};
33         my $template=$params{template};
35         # Add search box to page header.
36         if ($template->query(name => "searchform")) {
37                 if (! defined $form) {
38                         my $searchform = template("googleform.tmpl", blind_cache => 1);
39                         $searchform->param(url => $config{url});
40                         $form=$searchform->output;
41                 }
43                 $template->param(searchform => $form);
44         }
45 }
47 1