mirror of
https://github.com/searxng/searxng
synced 2024-01-01 19:24:07 +01:00
wikipedia wikidata infobox + disable wikisource
by default switch wikipedia and wikidata to infobox only disable wikisource by default
This commit is contained in:
parent
b4e0d2eedc
commit
299a3fc7b0
3 changed files with 42 additions and 13 deletions
|
@ -31,6 +31,8 @@ if TYPE_CHECKING:
|
||||||
|
|
||||||
traits: EngineTraits
|
traits: EngineTraits
|
||||||
|
|
||||||
|
display_type = "list"
|
||||||
|
|
||||||
# about
|
# about
|
||||||
about = {
|
about = {
|
||||||
"website": 'https://wikidata.org/',
|
"website": 'https://wikidata.org/',
|
||||||
|
@ -268,7 +270,7 @@ def get_results(attribute_result, attributes, language):
|
||||||
for url in value.split(', '):
|
for url in value.split(', '):
|
||||||
infobox_urls.append({'title': attribute.get_label(language), 'url': url, **attribute.kwargs})
|
infobox_urls.append({'title': attribute.get_label(language), 'url': url, **attribute.kwargs})
|
||||||
# "normal" results (not infobox) include official website and Wikipedia links.
|
# "normal" results (not infobox) include official website and Wikipedia links.
|
||||||
if attribute.kwargs.get('official') or attribute_type == WDArticle:
|
if display_type == "list" and (attribute.kwargs.get('official') or attribute_type == WDArticle):
|
||||||
results.append({'title': infobox_title, 'url': url, "content": infobox_content})
|
results.append({'title': infobox_title, 'url': url, "content": infobox_content})
|
||||||
# update the infobox_id with the wikipedia URL
|
# update the infobox_id with the wikipedia URL
|
||||||
# first the local wikipedia URL, and as fallback the english wikipedia URL
|
# first the local wikipedia URL, and as fallback the english wikipedia URL
|
||||||
|
@ -307,7 +309,7 @@ def get_results(attribute_result, attributes, language):
|
||||||
|
|
||||||
if img_src is None and len(infobox_attributes) == 0 and len(infobox_urls) == 1 and len(infobox_content) == 0:
|
if 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})
|
results.append({'url': infobox_urls[0]['url'], 'title': infobox_title, 'content': infobox_content})
|
||||||
else:
|
elif display_type == "infobox":
|
||||||
results.append(
|
results.append(
|
||||||
{
|
{
|
||||||
'infobox': infobox_title,
|
'infobox': infobox_title,
|
||||||
|
|
|
@ -67,6 +67,8 @@ from searx.enginelib.traits import EngineTraits
|
||||||
|
|
||||||
traits: EngineTraits
|
traits: EngineTraits
|
||||||
|
|
||||||
|
display_type = "list"
|
||||||
|
|
||||||
# about
|
# about
|
||||||
about = {
|
about = {
|
||||||
"website": 'https://www.wikipedia.org/',
|
"website": 'https://www.wikipedia.org/',
|
||||||
|
@ -185,18 +187,21 @@ def response(resp):
|
||||||
api_result = resp.json()
|
api_result = resp.json()
|
||||||
title = utils.html_to_text(api_result.get('titles', {}).get('display') or api_result.get('title'))
|
title = utils.html_to_text(api_result.get('titles', {}).get('display') or api_result.get('title'))
|
||||||
wikipedia_link = api_result['content_urls']['desktop']['page']
|
wikipedia_link = api_result['content_urls']['desktop']['page']
|
||||||
results.append({'url': wikipedia_link, 'title': title, 'content': api_result.get('description', '')})
|
|
||||||
|
|
||||||
if api_result.get('type') == 'standard':
|
if display_type == "list":
|
||||||
results.append(
|
results.append({'url': wikipedia_link, 'title': title, 'content': api_result.get('description', '')})
|
||||||
{
|
|
||||||
'infobox': title,
|
if display_type == "infobox":
|
||||||
'id': wikipedia_link,
|
if api_result.get('type') == 'standard':
|
||||||
'content': api_result.get('extract', ''),
|
results.append(
|
||||||
'img_src': api_result.get('thumbnail', {}).get('source'),
|
{
|
||||||
'urls': [{'title': 'Wikipedia', 'url': wikipedia_link}],
|
'infobox': title,
|
||||||
}
|
'id': wikipedia_link,
|
||||||
)
|
'content': api_result.get('extract', ''),
|
||||||
|
'img_src': api_result.get('thumbnail', {}).get('source'),
|
||||||
|
'urls': [{'title': 'Wikipedia', 'url': wikipedia_link}],
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,17 @@ engines:
|
||||||
- name: wikipedia
|
- name: wikipedia
|
||||||
engine: wikipedia
|
engine: wikipedia
|
||||||
shortcut: wp
|
shortcut: wp
|
||||||
|
display_type: "list"
|
||||||
base_url: 'https://{language}.wikipedia.org/'
|
base_url: 'https://{language}.wikipedia.org/'
|
||||||
|
categories: [general]
|
||||||
|
disabled: true
|
||||||
|
|
||||||
|
- name: wikipedia.infobox
|
||||||
|
engine: wikipedia
|
||||||
|
shortcut: wpi
|
||||||
|
display_type: "infobox"
|
||||||
|
base_url: 'https://{language}.wikipedia.org/'
|
||||||
|
categories: [general]
|
||||||
|
|
||||||
- name: bilibili
|
- name: bilibili
|
||||||
engine: bilibili
|
engine: bilibili
|
||||||
|
@ -582,7 +592,18 @@ engines:
|
||||||
shortcut: wd
|
shortcut: wd
|
||||||
timeout: 3.0
|
timeout: 3.0
|
||||||
weight: 2
|
weight: 2
|
||||||
|
display_type: "list"
|
||||||
tests: *tests_infobox
|
tests: *tests_infobox
|
||||||
|
disabled: true
|
||||||
|
categories: [general]
|
||||||
|
|
||||||
|
- name: wikidata.infobox
|
||||||
|
engine: wikidata
|
||||||
|
timeout: 3.0
|
||||||
|
shortcut: wdi
|
||||||
|
weight: 2
|
||||||
|
display_type: "infobox"
|
||||||
|
categories: [general]
|
||||||
|
|
||||||
- name: duckduckgo
|
- name: duckduckgo
|
||||||
engine: duckduckgo
|
engine: duckduckgo
|
||||||
|
@ -1615,6 +1636,7 @@ engines:
|
||||||
categories: [general, wikimedia]
|
categories: [general, wikimedia]
|
||||||
base_url: "https://{language}.wikisource.org/"
|
base_url: "https://{language}.wikisource.org/"
|
||||||
search_type: text
|
search_type: text
|
||||||
|
disabled: true
|
||||||
about:
|
about:
|
||||||
website: https://www.wikisource.org/
|
website: https://www.wikisource.org/
|
||||||
wikidata_id: Q263
|
wikidata_id: Q263
|
||||||
|
|
Loading…
Add table
Reference in a new issue