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:
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:
time.struct_time
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:
images.html
¶
The images are displayed as small thumbnails in the main results list.
- title
str
Title of the image.
- thumbnail_src
str
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_src
str
URL of the full size image.
- content:
str
Description of the image.
- author:
str
Name of the author of the image.
- img_format
str
The format of the image (e.g.
png
).- source
str
Source of the image.
- filesize:
str
Size of bytes in
human readable
notation (e.g.MB
for 1024 * 1024 Bytes filesize).- url
str
URL of the page from where the images comes from (source).
videos.html
¶
Displays result fields from:
Additional fields used in the videos.html:
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')
.- 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, 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.
- country_code
- 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 engineopenstreetmap.py
, but it is not used in themap.html
template yet.- type
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'}
code.html
¶
Displays result fields from:
Additional fields used in the code.html:
files.html
¶
Displays result fields from:
Additional fields used in the code.html:
- filename, size, time:
str
Filename, Filesize and Date of the file.
- mtype
audio
|video
|str
Mimetype type of the file.
- subtype
str
Mimetype / subtype of the file.
- abstract
str
Abstract of the file.
- author
str
Name of the author of the file
- embedded
str
URL of an embedded media type (
audio
orvideo
) / is collapsible.
products.html
¶
Displays result fields from:
Additional fields used in the products.html:
Answer results¶
See Answer Results
Suggestion results¶
Correction results¶
Infobox results¶
See Infobox Results