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