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 developer at hand, details must still be taken from the .
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
engine_data_form
The engine_data_form macro is used in 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 .
default.html
Displays result fields from:
Additional fields used in the :
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>.
torrent.html
Displays result fields from:
Additional fields used in the :
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 :
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\_code[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
: [Country code](https://wiki.openstreetmap.org/wiki/Country_code) of the object.
locality[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
: 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,
}
```
type[`str`](https://docs.python.org/3/builtins/stdtypes.html#str)
: 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 :
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 :
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'}
products.html
Displays result fields from:
Additional fields used in the :
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
Correction results
Infobox results
See Infobox Results
Copyright © SearXNG team
Made with Furo
