searchengine modules

How to add a search engine

Miro allows users to do searches against sites that return RSS data for search queries.

Search engine data is stored in .xml files in resources/searchengines/. Here’s an example search engine:

<searchengine>
    <id>5min</id>
    <displayname>5min</displayname>
    <url>http://www.5min.com/Rss/Search/%s</url>
    <sort>11</sort>
</searchengine>

id

A unique id string that identifies this specific search engine.

displayname

The name that appears in Miro in the search engine drop down.

url

The url to use to do the search. There are several things that can be expanded in the search url:

  • %s expands to the search terms
  • %a expands to 1 or 0 regarding whether or not to filter adult content
  • %l expands to the number of search results to return

sort

This is the integer denoting the position this search engine takes in the list of search engines.

To create a new search engine, do the following:

  1. create an xml file for the search engine that gets placed in resources/searchengines/.
  2. create a 16 pixel by 16 pixel 8-bit/color non-interlaced PNG image for the search icon. The name of this file must be search_icon_<id>.png where <id> is the id of the search engine. For example, search_icon_5min.png. This icon gets placed in resources/images/.
  3. When you’re happy with your search engine data, create a bug in bugzilla for someone to add the new search engine and attach the .xml and .png files to it.

searchengines - search engines module

miro.searchengines – This module holds SearchEngineInfo and related helper functions.

class miro.searchengines.SearchEngineInfo(name, title, url, sort_order=0, filename=None)

Defines a search engine in Miro.

Note

Don’t instantiate this yourself–search engines are defined by .xml files in the resources/searchengines/ directory.

get_request_url(query, filterAdultContents, limit)
Returns the request url expanding the query, filter adult content, and results limit place holders.
miro.searchengines.create_engines()
Creates all the search engines specified in the resources/searchengines/ directory and the theme searchengines directory. After doing that, it adds an additional “Search All” engine.
miro.searchengines.get_engine_for_name(name)
Returns the SearchEngineInfo instance for the given id. If no such search engine exists, returns None.
miro.searchengines.get_last_engine()
Checks the preferences and returns the SearchEngine object of that name or None.
miro.searchengines.get_search_engines()
Returns the list of SearchEngineInfo instances.
miro.searchengines.set_last_engine(engine)
Takes a SearchEngineInfo or search engine id and persists it to preferences.

Table Of Contents

Previous topic

Miro and i18n

Next topic

utility modules

This Page