Simple Theme Templates

The simple template is complex, it consists of many different elements and also uses macros and include statements. The following is a rough overview that we would like to give the developerat hand, details must still be taken from the sources.

A result item can be of different media types. The media type of a result is defined by the result_type.Result.template. To set another media-type as default.html, the field template in the result item must be set to the desired type.

Result template macros

result_header

Execpt image.html and some others this macro is used in nearly all result types in the Main Result List.

Fields used in the template macro result_header:

urlstr

Link URL of the result item.

titlestr

Link title of the result item.

img_src, thumbnailstr

URL of a image or thumbnail that is displayed in the result item.

result_sub_header

Execpt image.html and some others this macro is used in nearly all result types in the Main Result List.

Fields used in the template macro result_sub_header:

publishedDatedatetime.datetime

The date on which the object was published.

length: time.struct_time

Playing duration in seconds.

views: str

View count in humanized number format.

authorstr

Author of the title.

metadatastr

Miscellaneous metadata.

engine_data_form

The engine_data_form macro is used in results,html in a HTML <form/> element. The intention of this macro is to pass data of a engine from one response to the searx.search.SearchQuery of the next request.

To pass data, engine’s response handler can append result items of typ engine_data. This is by example used to pass a token from the response to the next request:

def response(resp):
    ...
    results.append({
       'engine_data': token,
       'key': 'next_page_token',
    })
    ...
    return results

def request(query, params):
    page_token = params['engine_data'].get('next_page_token')

Main Result List

The media types of the main result type are the template files in the result_templates.

default.html

Displays result fields from:

Additional fields used in the default.html:

contentstr

General text of the result item.

iframe_srcstr

URL of an embedded <iframe> / the frame is collapsible.

audio_srcuri,

URL of an embedded <audio controls>.

images.html

The images are displayed as small thumbnails in the main results list.

titlestr

Title of the image.

thumbnail_srcstr

URL of a preview of the image.

resolution str

The resolution of the image (e.g. 1920 x 1080 pixel)

Image labels

Clicking on the preview opens a gallery view in which all further metadata for the image is displayed. Addition fields used in the images.html:

img_srcstr

URL of the full size image.

content: str

Description of the image.

author: str

Name of the author of the image.

img_formatstr

The format of the image (e.g. png).

sourcestr

Source of the image.

filesize: str

Size of bytes in human readable notation (e.g. MB for 1024 * 1024 Bytes filesize).

urlstr

URL of the page from where the images comes from (source).

videos.html

Displays result fields from:

Additional fields used in the videos.html:

iframe_srcstr

URL of an embedded <iframe> / the frame is collapsible.

The videos are displayed as small thumbnails in the main results list, there is an additional button to collaps/open the embeded video.

contentstr

Description of the code fragment.

torrent.html

Displays result fields from:

Additional fields used in the torrent.html:

magnetlink:

URL of the magnet link.

torrentfile

URL of the torrent file.

seedint

Number of seeders.

leechint

Number of leecher

filesizeint

Size in Bytes (rendered to human readable unit of measurement).

filesint

Number of files.

map.html

Displays result fields from:

Additional fields used in the map.html:

contentstr

Description of the item.

address_labelstr

Label of the address / default _('address').

geojsonGeoJSON

Geometries mapped to HTMLElement.dataset (data-map-geojson) and used by Leaflet.

boundingbox[ min-lon, min-lat, max-lon, max-lat]

A bbox area defined by min longitude , min latitude , max longitude and max latitude. The bounding box is mapped to HTMLElement.dataset (data-map-boundingbox) and is used by Leaflet.

longitude, latitudestr

Geographical coordinates, mapped to HTMLElement.dataset (data-map-lon, data-map-lat) and is used by Leaflet.

address{...}

A dicticonary with the address data:

address = {
    'name'          : str,  # name of object
    'road'          : str,  # street name of object
    'house_number'  : str,  # house number of object
    'postcode'      : str,  # postcode of object
    'country'       : str,  # country of object
    'country_code'  : str,
    'locality'      : str,
}
country_codestr

Country code of the object.

localitystr

The name of the city, town, township, village, borough, etc. in which this object is located.

links[link1, link2, ...]

A list of links with labels:

links.append({
    'label'       : str,
    'url'         : str,
    'url_label'   : str,  # set by some engines but unused (oscar)
})
data[data1, data2, ...]

A list of additional data, shown in two columns and containing a label and value.

data.append({
   'label'   : str,
   'value'   : str,
   'key'     : str,  # set by some engines but unused
})
typestr # set by some engines but unused (oscar)

Tag label from OSM_KEYS_TAGS[‘tags’].

type_iconstr # set by some engines but unused (oscar)

Type’s icon.

osm{...}

OSM-type and OSM-ID, can be used to Lookup OSM data (Nominatim). There is also a discussion about “place_id is not a persistent id” and the perma_id.

osm = {
    'type': str,
    'id':   str,
}
typestr

Type of osm-object (if OSM-Result).

id :

ID of osm-object (if OSM-Result).

Hint

The osm property is set by engine openstreetmap.py, but it is not used in the map.html template yet.

paper.html

Displays result fields from:

Additional fields used in the paper.html:

contentstr

An abstract or excerpt from the document.

commentsstr

Free text display in italic below the content.

tagsList[str]

Free tag list.

typestr

Short description of medium type, e.g. book, pdf or html

authorsList[str]

List of authors of the work (authors with a “s” suffix, the “author” is in the result_sub_header).

editorstr

Editor of the book/paper.

publisherstr

Name of the publisher.

journalstr

Name of the journal or magazine the article was published in.

volumestr

Volume number.

pagesstr

Page range where the article is.

numberstr

Number of the report or the issue number for a journal article.

doistr

DOI number (like 10.1038/d41586-018-07848-2).

issnList[str]

ISSN number like 1476-4687

isbnList[str]

ISBN number like 9780201896831

pdf_urlstr

URL to the full article, the PDF version

html_urlstr

URL to full article, HTML version

packages

Displays result fields from:

Additional fields used in the packages.html:

package_namestr

The name of the package.

versionstr

The current version of the package.

maintainerstr

The maintainer or author of the project.

publishedDatedatetime

Date of latest update or release.

tagsList[str]

Free tag list.

popularitystr

The popularity of the package, e.g. rating or download count.

license_namestr

The name of the license.

license_urlstr

The web location of a license copy.

homepagestr

The url of the project’s homepage.

source_code_url: str

The location of the project’s source code.

linksdict

Additional links in the form of {'link_name': 'http://example.com'}

code.html

Displays result fields from:

Additional fields used in the code.html:

contentstr

Description of the code fragment.

codelines[line1, line2, ...]

Lines of the code fragment.

code_languagestr

Name of the code language, the value is passed to pygments.lexers.get_lexer_by_name.

repositorystr

URL of the repository of the code fragment.

files.html

Displays result fields from:

Additional fields used in the code.html:

filename, size, time: str

Filename, Filesize and Date of the file.

mtypeaudio | video | str

Mimetype type of the file.

subtypestr

Mimetype / subtype of the file.

abstractstr

Abstract of the file.

authorstr

Name of the author of the file

embeddedstr

URL of an embedded media type (audio or video) / is collapsible.

products.html

Displays result fields from:

Additional fields used in the products.html:

contentstr

Description of the product.

pricestr

The price must include the currency.

shippingstr

Shipping details.

source_countrystr

Place from which the shipment is made.

Answer results

See Answer Results

Suggestion results

See Suggestion Results

Correction results

See Correction Results

Infobox results

See Infobox Results