Labs/Ubiquity/Writing A Search Command

Documentation of CmdUtils.makeSearchCommand

name

The name of the search command, ie: "Google"

url

The url of the search provider, with the string "{QUERY}" (without the quotes representing the search word, ie: "http://www.google.com/search?q={QUERY}". If the provider uses POST instead of GET, see #postData.

icon

The icon used for the search command. If not provided, the favicon (favicon.ico) located at the root of the search providers domain will be used instead.

description

A description of your search command. If not provided, one will be generated from a localized template and the name of your search command.

preview

An optional preview string or function that can be used to display results in the Ubiquity preview. For more info see Labs/Ubiquity/Ubiquity_0.5_Author_Tutorial#Adding_a_Preview

To provide a consistent search experience, makeSearchCommand can generate a preview for you with minimal work on your part. For more information on this, see #parser. If you leave out both preview and parser, the provided or generated description will be used instead.

charset

If you intended input and response cannot be represented properly by UTF-8, you can provide the required charset as a string. It must be a charset supported by nsIScriptableUnicodeConverter which should be all of the IANA Character sets

postData

Supplying postData will make Ubiquity use POST instead of GET when retrieving the results. It can be either a string ie: "q={QUERY}&hl=en" or as an object ie: {"q": "{QUERY}", "hl": "en"}

parser

The parser makes it easy for you as a developer to provide an interactive preview with search results, consistent with other Ubiquity search commands.

Via a number of options, you can tell makeSearchCommand how to parse the data returned by the search provider.

NB: all selectors used in the following sections are NOT CSS selectors, but jQuery selectors. They are very similar, but some features you might be used to from CSS are missing, whilst others still are added.

container

A selector that matches each result, thus returning a list of result containers.

It is important to note that all details for each individual result must be contained in each container.

title

preview

thumbnail

maxResults

href

baseurl

type

Examples