google: Pass the whole wiki url to google, not just the domain, so that search works...
authorJoey Hess <joey@gnu.kitenet.net>
Thu, 29 Oct 2009 22:05:58 +0000 (18:05 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Thu, 29 Oct 2009 22:05:58 +0000 (18:05 -0400)
IkiWiki/Plugin/google.pm
debian/changelog
doc/plugins/google/discussion.mdwn
templates/googleform.tmpl

index 1683220e7ed659c8857ae2aae0fcf8ff966969f7..483fa1707dca4dd60be7d8b3328f1a343b1fe026 100644 (file)
@@ -6,8 +6,6 @@ use strict;
 use IkiWiki 3.00;
 use URI;
 
-my $host;
-
 sub import {
        hook(type => "getsetup", id => "google", call => \&getsetup);
        hook(type => "checkconfig", id => "google", call => \&checkconfig);
@@ -26,11 +24,6 @@ sub 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;
@@ -43,7 +36,7 @@ sub pagetemplate (@) {
        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;
                }
 
index 4c8c4d6fc65d52e9a7d2b5695ceeb7301664b0c5..f19b4eae4cdd81448f0883cd8208948f556dbd1e 100644 (file)
@@ -8,6 +8,9 @@ ikiwiki (3.20091024) UNRELEASED; urgency=low
     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
 
index 39403f9f9b4b1de4f0d055d10468de649775f7cd..94fc36a35032c88ecf4a8ba955984aa719c171a2 100644 (file)
@@ -9,3 +9,5 @@ It works to pass the whole wiki baseurl to Google, not just the
 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]] 
index e2d4a1f43df8212051e0fa5bd67866f417a88d95..bcf1004a46cf8bd908f1c548c7fcfc8f67448531 100644 (file)
@@ -1,6 +1,6 @@
 <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>