Tags:
create new tag
, view all tags

Google Your TWiki

To use Google to search your public twiki site, copy the following code and dump it in a topic somewhere. Your TWiki.WebSearch for example.

To replace PatternSkin's Jump (aka GoBox) put it in WebTopBar. For other skins you will need to add it to the WEBTOPICLIST preference (all in one line!) or the appropiate templates/twiki.myskin.tmpl

<!-- SiteSearch Google -->
<form method="get" action="http://www.google.com/search">
<input type="hidden" name="ie" value="UTF-8" />
<input type="hidden" name="oe" value="UTF-8" />
<input type="text" name="q" size="31" maxlength="255" value="" />
<input type="submit" name="btnG" value="Google %HTTP_HOST%" />
<input type="hidden" name="domains" value="%HTTP_HOST%" />
<input type="hidden" name="sitesearch" value="%HTTP_HOST%" checked="checked" />
</form>
<!-- SiteSearch Google -->

to get this:

Adapted from: http://www.google.com/searchcode.html

To customise the results so that they confirm to your site's look and feel, you need to register for a free Google account at http://www.google.com/services/free.html and then follow the instructions they give you.

To put this in PatternSkin WebTopBar you need to change this a little bit:

</form><!-- necessary! -->
<label for="go"></label>
<!-- SiteSearch Google -->
<form method="get" action="http://www.google.com/search">
<input type="hidden" name="ie" value="UTF-8" />
<input type="hidden" name="oe" value="UTF-8" />
<input type="text" id="go" name="q" size="31" maxlength="255" value="" />
<input type="submit" name="btnG" value="Google %HTTP_HOST%" />
<input type="hidden" name="domains" value="%HTTP_HOST%" />
<input type="hidden" name="sitesearch" value="%HTTP_HOST%" checked="checked" />
</form>
<!-- SiteSearch Google -->


Why would you want to do this?

1) You're leary of the recent major SecurityAlertExecuteCommandsWithSearch vulnerability and want to protect your system by not using the internal search (note: there are other steps which can be done, like adding bin/search to .htaccess for authorized use only; although this does not catch SEARCH embedded in a topic).

2) Your system is too slow and you want to offload expensive CPU processing where ever you can.

3) You want to take advantage of Google's cache and highlighted search terms features.

-- MattWilkie - 26 Nov 2004
-- PeterThoeny - 26 Nov 2004

Discussions

I did some minor XHTML changes.

-- PeterThoeny - 26 Nov 2004

Also note htat Wikipedia replaced their search with Google search, because of "performance reasons".

-- ArthurClemens - 26 Nov 2004

added pattern skin web top bar fix -- MattWilkie - 30 Nov 2004

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2004-12-01 - MattWilkie
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.