]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - IkiWiki/Plugin/google.pm
meta: Security fix; add missing sanitization of author and authorurl. Thanks, Raúl...
[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                         section => "web",
21                 },
22 }
24 sub checkconfig () {
25         if (! length $config{url}) {
26                 error(sprintf(gettext("Must specify %s when using the %s plugin"), "url", 'google'));
27         }
28         
29         # This is a mass dependency, so if the search form template
30         # changes, every page is rebuilt.
31         add_depends("", "templates/googleform.tmpl");
32 }
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;
47                 }
49                 $template->param(searchform => $form);
50         }
51 }
53 1