A few days have passed since my first post Making a search command – the easy way!, and a few new features have been implemented, most of which were suggested by readers – so keep up filling the suggestion box!
Picture this
Most notably, it is now possible to include a thumbnail in the preview, which will be automatically formatted and inserted to the left of the preview text. This is especially useful for search-sites which display images to help identify the result – such as books, cd, movies, etc…
As an example, here is the Wikipedia command redone with this enhancement:
CmdUtils.makeSearchCommand({
name: "Amazon",
url: "http://www.amazon.com/s/ref=nb_ss_gw?url=search-alias%3Dstripbooks&field-keywords={QUERY}",
parser: {container: "div.listView",
title: "div.productTitle a",
preview: "div.productTitle span.ptBrand",
thumbnail: "div.productImage"}
});
You will also note the lack of an icon and description, but if you try it out (in latest source) you’ll see that it makes no difference. If left out, they are automatically generated from url and name respectively.
Correcting errors
Some sites (like Amazon) have a tendency to return weird results in the middle of the set, without any real indication that it isn’t an actual result, and this can cause the parser to become confused (say, if the number of titles and the number of preview do not match up, which belongs to which?), and before, it would give you a warning in console and then most likely die before returning any output to the user. Now, it will fall back to just supplying a list of titles, and explain to the user why the previews are missing.
What’s next?
The next thing I’ll be looking into, is allowing makeSearchCommand to use services that return JSON encoded data. This will enable us to use APIs made public by many search engines instead of scraping the HTML, and is a feature that has not only been requested by early adopters, but will also make it possible (and/or easier) to switch over to this new parser system for all of our default search commands.
As usual, I encourage you all to try out the new features, and see if anything breaks or behaves unexpectedly. And of course, if they do: let me know!
[...] Geeks By Nature because we just can’t help it… « Making a search command – part 2 [...]
Could you pleasee provide more information on this topic??? Also your site is amazing. Best regards…
@Mel
Sure thing – this is the updated documentation of makeSearchCommand: https://wiki.mozilla.org/Labs/Ubiquity/Writing_A_Search_Command
Some of it only applies to the development version of Ubiquity, though I am afraid I cannot tell you exactly what has made it in and what hasn’t.
Best regards,
Christian