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
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 :
- url
str Link URL of the result item.
- title
str Link title of the result item.
- img_src, thumbnail
str 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 :
- publishedDate
datetime.datetime The date on which the object was published.
- length:
datetime.timedelta Playing duration in seconds.
- views:
str View count in humanized number format.
- author
str Author of the title.
- metadata
str 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 :
- content
str General text of the result item.
- iframe_src
str URL of an embedded <iframe> / the frame is collapsible.
- audio_src uri,
URL of an embedded <audio controls>.
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 .
- seed
int Number of seeders.
- leech
int Number of leecher
- filesize
int Size in Bytes (rendered to human readable unit of measurement).
- files
int Number of files.
map.html
Displays result fields from:
Additional fields used in the map.html :
- content
str Description of the item.
- address_label
str Label of the address / default _('address').
- geojson GeoJSON
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, latitude
str 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 Country code of the object.
- locality
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
})
- type
str # set by some engines but unused (oscar) Tag label from OSM_KEYS_TAGS['tags'] .
- type_icon
str # 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 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 :
- content
str An abstract or excerpt from the document.
- comments
str Free text display in italic below the content.
- tags
List [str ] Free tag list.
- type
str Short description of medium type, e.g. book , pdf or html ...
- authors
List [str ] List of authors of the work (authors with a "s" suffix, the "author" is in the
result_sub_header ).
- editor
str Editor of the book/paper.
- publisher
str Name of the publisher.
- journal
str Name of the journal or magazine the article was published in.
- volume
str Volume number.
- pages
str Page range where the article is.
- number
str Number of the report or the issue number for a journal article.
- doi
str DOI number (like 10.1038/d41586-018-07848-2).
- issn
List [str ] ISSN number like 1476-4687
- isbn
List [str ] ISBN number like 9780201896831
- pdf_url
str URL to the full article, the PDF version
- html_url
str URL to full article, HTML version
packages
Displays result fields from:
Additional fields used in the packages.html :
- package_name
str The name of the package.
- version
str The current version of the package.
- maintainer
str The maintainer or author of the project.
- publishedDate
datetime Date of latest update or release.
- tags
List [str ] Free tag list.
- popularity
str The popularity of the package, e.g. rating or download count.
- license_name
str The name of the license.
- license_url
str The web location of a license copy.
- homepage
str The url of the project's homepage.
- source_code_url:
str The location of the project's source code.
- links
dict Additional links in the form of {'link_name': 'http://example.com'}
products.html
Displays result fields from:
Additional fields used in the products.html :
- content
str Description of the product.
- price
str The price must include the currency.
- shipping
str Shipping details.
- source_country
str 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