on master help sign in
[enh] add official site link to the top of the infobox - closes #1644
commit29960aa1d912f365846731c9aca166b5b7879d02 authorAdam Tauber <asciimoo@gmail.com> dateTue 9 Jun 2020, 23:49 (6 years ago) parent6c06286
2 files changed+7−4
searx/engines/wikidata.py+6−4 searx/templates/oscar/infobox.html+1
searx/engines/wikidata.py+6−4
@@ -414,11 +414,13 @@ def add_url(urls, result, id_cache, property_id=None, default_label=None, url_pr
414414 # append urls
415415 for url in links:
416416 if url is not None:
417− urls.append({'title': default_label or label,
418− 'url': url})
417+ u = {'title': default_label or label, 'url': url}
418+ if property_id == 'P856':
419+ u['official'] = True
420+ u['domain'] = url.split('/')[2]
421+ urls.append(u)
419422 if results is not None:
420− results.append({'title': default_label or label,
421− 'url': url})
423+ results.append(u)
422424
423425
424426def get_imdblink(result, url_prefix):
searx/templates/oscar/infobox.html+1
@@ -2,6 +2,7 @@
22<div class="panel panel-default infobox">
33 <div class="panel-heading">{{- "" -}}
44 <h4 class="panel-title infobox_part"><bdi>{{ infobox.infobox }}</bdi></h4>{{- "" -}}
5+ {% for u in infobox.urls %}{% if u.official %} <a href="{{ u.url }}">{{ u.domain }}</a>{% endif %}{% endfor %}
56 </div>
67 <div class="panel-body">
78 {% if infobox.img_src %}<img class="img-responsive center-block infobox_part" src="{{ image_proxify(infobox.img_src) }}" alt="{{ infobox.infobox }}" />{% endif %}