summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authora01200356 <a01200356@itesm.mx>2016-04-17 16:21:44 -0500
committera01200356 <a01200356@itesm.mx>2016-04-17 16:34:46 -0500
commit6dca14e95d08479fb49314cb4093be36ac49cf94 (patch)
tree0c2e1de4480e31dd0bb523e400193069e192d39c /searx
parent8d335dbdaedd6113242e785e8fabac86128d069a (diff)
downloadsearxng-6dca14e95d08479fb49314cb4093be36ac49cf94.tar.gz
searxng-6dca14e95d08479fb49314cb4093be36ac49cf94.zip
[enh] multilingual duckduckgo_definitions
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/duckduckgo_definitions.py7
-rw-r--r--searx/templates/oscar/infobox.html6
2 files changed, 9 insertions, 4 deletions
diff --git a/searx/engines/duckduckgo_definitions.py b/searx/engines/duckduckgo_definitions.py
index 793e97d22..dc25d416f 100644
--- a/searx/engines/duckduckgo_definitions.py
+++ b/searx/engines/duckduckgo_definitions.py
@@ -1,5 +1,6 @@
import json
from urllib import urlencode
+from re import sub
from lxml import html
from searx.utils import html_to_text
from searx.engines.xpath import extract_text
@@ -19,8 +20,8 @@ def result_to_text(url, text, htmlResult):
def request(query, params):
- # TODO add kl={locale}
params['url'] = url.format(query=urlencode({'q': query}))
+ params['headers']['Accept-Language'] = params['language']
return params
@@ -103,6 +104,10 @@ def response(resp):
urls.append({'title': search_res.get('DefinitionSource'),
'url': definitionURL})
+ # to merge with wikidata's infobox
+ if infobox_id:
+ infobox_id = sub(r'^http:', r'https:', infobox_id)
+
# entity
entity = search_res.get('Entity', None)
# TODO continent / country / department / location / waterfall /
diff --git a/searx/templates/oscar/infobox.html b/searx/templates/oscar/infobox.html
index 606a5d22c..c72cfb638 100644
--- a/searx/templates/oscar/infobox.html
+++ b/searx/templates/oscar/infobox.html
@@ -1,9 +1,9 @@
<div class="panel panel-default infobox">
<div class="panel-heading">
- <bdi><h4 class="panel-title infobox_part">{{ infobox.infobox }}</h4></bdi>
+ <bdi><h4 class="panel-title infobox_part">{{ infobox.infobox }}</h4></bdi>
</div>
<div class="panel-body">
- <bdi>
+ <bdi>
{% if infobox.img_src %}<img class="img-responsive center-block infobox_part" src="{{ image_proxify(infobox.img_src) }}" alt="{{ infobox.infobox }}" />{% endif %}
{% if infobox.content %}<p class="infobox_part">{{ infobox.content }}</p>{% endif %}
@@ -29,6 +29,6 @@
{% endfor %}
</div>
{% endif %}
- </bdi>
+ </bdi>
</div>
</div>