OpenSearch

Summary: Add OpenSearch autodiscovery & suggestions to PmWiki
Version: 2009-02-20
Prerequisites: PmWiki 2.2.0 (untested on earlier)
Status: beta
Maintainer: Eemeli Aro
Categories: Searching
Discussion: OpenSearch-Talk?

Questions answered by this recipe

  • How can my site be searched using the browser's own search box?
  • How can I quickly go to a page on my site by just typing a few characters from its name?

Description

This recipe implements the OpenSearch description document, its autodiscovery from wiki pages, and the OpenSearch suggestions extension that allows for search term autocompletion/autosuggestion.

To install this recipe

  • download opensearch.phpΔ to your cookbook directory
  • add the following to your config file:
    include_once("$FarmD/cookbook/opensearch.php");

Configuration

The following variables may be set in your config file to configure the way OpenSearch works.

$OpenSearchUrl
default: $ScriptUrl
The base URL to add the actions to. For example, if you have a separate search page you might want to set this to "$ScriptUrl/Search" or whatever else is applicable.
$OpenSearchData
default: array( 'ShortName' => substr( $WikiTitle, 0, 16 ), 'Description' => "Search $WikiTitle" )
An array of XML elements to include on the OpenSearch description document, accessible using action=opensearchdescription. Please see the specification for details. The only required elements are the two included by default, along with the Url element that is added automatically.

Notes

The autocompletion only works for page names at the moment, in order to make the script as fast as possible. As eg. Firefox doesn't support the Query URL part of the JSON autocompletion reply, the default search action is overloaded to recognise a fully valid page name as a search term, and redirect to it.

At least for now, search results are only provided in the same HTML output as PmWiki normally produces. RSS and/or Atom feeds could be done, using customized PageList output.

As the recipe doesn't include any JavaScript or other front-end code, functionality is largely left to the user client (for now!). Autocompletion ought to work in Firefox and Google Chrome, everything else should also work in IE7 and up. Please refer to the browsers' own documentation for instructions how to add search engines.

Release Notes

See Also

Contributors

Comments

See discussion at OpenSearch-Talk?

User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.