mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00

The intention of this patch is to improve modularization & documentation of the implementations about the *result* items. This patch does not contain any functional change! Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
# lint: pylint
|
|
"""Suggestion item in the result list. The suggestion result item is used in
|
|
the :origin:`infobox.html <searx/templates/simple/results.html>` template.
|
|
|
|
A sugestion item is a dictionary type with dedicated keys and values.
|
|
|
|
.. code:: python
|
|
|
|
results.append({
|
|
'suggestion' : str,
|
|
})
|
|
|
|
The context ``suggestions`` of the HTML template is a set of dictionaries:
|
|
|
|
.. code:: python
|
|
|
|
suggestions = [
|
|
{
|
|
'url' : str,
|
|
'title' : str,
|
|
},
|
|
{...},
|
|
...
|
|
]
|
|
|
|
url : ``str``
|
|
The SearXNG search URL for the suggestion term.
|
|
|
|
title : ``str``
|
|
The 'suggestion' string append by the engine.
|
|
|
|
"""
|
|
|
|
from typing import Set
|
|
|
|
|
|
def is_suggestion(result):
|
|
"""Returns ``True`` if result type is :py:obj:`.suggestion`, otherwise
|
|
``False``
|
|
|
|
In the result list a suggestion item is identified by the existence of the
|
|
key ``suggestion``.
|
|
"""
|
|
return 'suggestion' in result
|
|
|
|
|
|
class Suggestions(Set):
|
|
"""Set of suggestions in the :py:obj:`.container.ResultContainer`"""
|