mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
WIP
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
915e1399f0
commit
a7861058c5
2 changed files with 23 additions and 7 deletions
|
@ -31,8 +31,6 @@ if TYPE_CHECKING:
|
|||
|
||||
traits: EngineTraits
|
||||
|
||||
display_type = ["infobox"]
|
||||
|
||||
# about
|
||||
about = {
|
||||
"website": 'https://wikidata.org/',
|
||||
|
@ -43,6 +41,12 @@ about = {
|
|||
"results": 'JSON',
|
||||
}
|
||||
|
||||
display_type = ["infobox"]
|
||||
"""A list of display types composed from ``infobox`` and ``list``. The latter
|
||||
one will add a hit to the result list. The first one will show a hit in the
|
||||
info box. Both values can be set, or one of the two can be set."""
|
||||
|
||||
|
||||
# SPARQL
|
||||
SPARQL_ENDPOINT_URL = 'https://query.wikidata.org/sparql'
|
||||
SPARQL_EXPLAIN_URL = 'https://query.wikidata.org/bigdata/namespace/wdq/sparql?explain'
|
||||
|
@ -270,8 +274,9 @@ def get_results(attribute_result, attributes, language):
|
|||
for url in value.split(', '):
|
||||
infobox_urls.append({'title': attribute.get_label(language), 'url': url, **attribute.kwargs})
|
||||
# "normal" results (not infobox) include official website and Wikipedia links.
|
||||
if "infobox" in display_type and (attribute.kwargs.get('official') or attribute_type == WDArticle):
|
||||
if "list" in display_type and (attribute.kwargs.get('official') or attribute_type == WDArticle):
|
||||
results.append({'title': infobox_title, 'url': url, "content": infobox_content})
|
||||
|
||||
# update the infobox_id with the wikipedia URL
|
||||
# first the local wikipedia URL, and as fallback the english wikipedia URL
|
||||
if attribute_type == WDArticle and (
|
||||
|
@ -307,7 +312,13 @@ def get_results(attribute_result, attributes, language):
|
|||
# add the wikidata URL at the end
|
||||
infobox_urls.append({'title': 'Wikidata', 'url': attribute_result['item']})
|
||||
|
||||
if img_src is None and len(infobox_attributes) == 0 and len(infobox_urls) == 1 and len(infobox_content) == 0:
|
||||
if (
|
||||
"list" in display_type
|
||||
and img_src is None
|
||||
and len(infobox_attributes) == 0
|
||||
and len(infobox_urls) == 1
|
||||
and len(infobox_content) == 0
|
||||
):
|
||||
results.append({'url': infobox_urls[0]['url'], 'title': infobox_title, 'content': infobox_content})
|
||||
elif "infobox" in display_type:
|
||||
results.append(
|
||||
|
|
|
@ -67,8 +67,6 @@ from searx.enginelib.traits import EngineTraits
|
|||
|
||||
traits: EngineTraits
|
||||
|
||||
display_type = ["infobox"]
|
||||
|
||||
# about
|
||||
about = {
|
||||
"website": 'https://www.wikipedia.org/',
|
||||
|
@ -79,6 +77,11 @@ about = {
|
|||
"results": 'JSON',
|
||||
}
|
||||
|
||||
display_type = ["infobox"]
|
||||
"""A list of display types composed from ``infobox`` and ``list``. The latter
|
||||
one will add a hit to the result list. The first one will show a hit in the
|
||||
info box. Both values can be set, or one of the two can be set."""
|
||||
|
||||
send_accept_language_header = True
|
||||
"""The HTTP ``Accept-Language`` header is needed for wikis where
|
||||
LanguageConverter_ is enabled."""
|
||||
|
@ -188,7 +191,9 @@ def response(resp):
|
|||
title = utils.html_to_text(api_result.get('titles', {}).get('display') or api_result.get('title'))
|
||||
wikipedia_link = api_result['content_urls']['desktop']['page']
|
||||
|
||||
if "list" in display_type:
|
||||
if "list" in display_type or api_result.get('type') != 'standard':
|
||||
# show item in the result list if 'list' is in the display options or it
|
||||
# is a item that can't be displayed in a infobox.
|
||||
results.append({'url': wikipedia_link, 'title': title, 'content': api_result.get('description', '')})
|
||||
|
||||
if "infobox" in display_type:
|
||||
|
|
Loading…
Add table
Reference in a new issue