Add an optional "sort" argument to meta titles, defaulting to the title
[ikiwiki] / IkiWiki / Plugin / google.pm
1 #!/usr/bin/perl
2 package IkiWiki::Plugin::google;
3
4 use warnings;
5 use strict;
6 use IkiWiki 3.00;
7 use URI;
8
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 }
14
15 sub getsetup () {
16         return
17                 plugin => {
18                         safe => 1,
19                         rebuild => 1,
20                         section => "web",
21                 },
22 }
23
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
30 my $form;
31 sub pagetemplate (@) {
32         my %params=@_;
33         my $page=$params{page};
34         my $template=$params{template};
35
36         # Add search box to page header.
37         if ($template->query(name => "searchform")) {
38                 if (! defined $form) {
39                         my $searchform = template("googleform.tmpl", blind_cache => 1);
40                         $searchform->param(url => $config{url});
41                         $form=$searchform->output;
42                 }
43
44                 $template->param(searchform => $form);
45         }
46 }
47
48 1