use IkiWiki 3.00;
use URI;
-my $host;
-
sub import {
hook(type => "getsetup", id => "google", call => \&getsetup);
hook(type => "checkconfig", id => "google", call => \&checkconfig);
if (! length $config{url}) {
error(sprintf(gettext("Must specify %s when using the %s plugin"), "url", 'google'));
}
- my $uri=URI->new($config{url});
- if (! $uri || ! defined $uri->host) {
- error(gettext("Failed to parse url, cannot determine domain name"));
- }
- $host=$uri->host;
}
my $form;
if ($template->query(name => "searchform")) {
if (! defined $form) {
my $searchform = template("googleform.tmpl", blind_cache => 1);
- $searchform->param(sitefqdn => $host);
+ $searchform->param(url => $config{url});
$form=$searchform->output;
}
url is uri-encoded. Most browsers other than MSIE don't care, but it's
the right thing to do.
* Add a spec file to allow building rpm from the source package.
+ * google: Pass the whole wiki url to google, not just the domain,
+ so that search works correctly for wikis that are located in
+ subdirectories of domains.
-- Joey Hess <joeyh@debian.org> Mon, 26 Oct 2009 11:53:32 -0400
domain, and appears to be legal. I've got a wiki that'd benefit
(it's a few directories down from the root). Can the plugin be
tweaked to do this? --[[schmonz]]
+
+> Done. --[[Joey]]
<form method="get" action="http://www.google.com/search" id="searchform">
<div>
- <input name="sitesearch" value="<TMPL_VAR SITEFQDN>" type="hidden" />
+ <input name="sitesearch" value="<TMPL_VAR URL>" type="hidden" />
<input name="q" value="" id="searchbox" size="16" maxlength="255" type="text" />
</div>
</form>