Labs/Ubiquity/Writing A Search Command: Difference between revisions
(→parser) |
|||
Line 17: | Line 17: | ||
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]] | 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, | To provide a consistent search experience, mSC 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 === | === charset === |
Revision as of 03:32, 21 October 2009
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, mSC 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 mSC how to parse the data returned by the search provider.
NB: all selectors used in the following sections are either paths into the json data in dot-notation, or jQuery selectors. Note that the latter are NOT CSS selectors albeit very similar. Some features you might be used to from CSS are missing, whilst others still are added. Which you should use depend on your choice of #type
type
mSC supports two types of parsers, namely "json" and "html". If not specified, it assumes you want the html parser.
container
If using the html parser, this must be a selector that matches each result, thus returning a list of result containers. When using the json parser it must match the parent of all the results, ie: "responseData.results".
It is important to note that in the case of the html parser, all details for each individual result must be contained in each container.