From 7937218be66f1fb3eff02bce308a4e5c78ba6672 Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Tue, 9 Dec 2014 02:36:53 +0100 Subject: [PATCH 01/62] Use human readable date For DoB and DoD, wikipedia use a non standard ISO format, not easily readable. Now the date is displayed in an human readable form, using the language setting as locale if available. If not, it uses the default locale. --- searx/engines/wikidata.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/searx/engines/wikidata.py b/searx/engines/wikidata.py index ab799e6ce..bda80cdca 100644 --- a/searx/engines/wikidata.py +++ b/searx/engines/wikidata.py @@ -1,6 +1,9 @@ import json from requests import get from urllib import urlencode +import locale +import time +import dateutil.parser result_count = 1 wikidata_host = 'https://www.wikidata.org' @@ -35,6 +38,16 @@ def response(resp): language = resp.search_params['language'].split('_')[0] if language == 'all': language = 'en' + + try: + locale.setlocale(locale.LC_ALL, str(resp.search_params['language'])) + except: + try: + locale.setlocale(locale.LC_ALL, 'en_US') + except: + pass + pass + url = url_detail.format(query=urlencode({'ids': '|'.join(wikidata_ids), 'languages': language + '|en'})) @@ -164,10 +177,12 @@ def getDetail(jsonresponse, wikidata_id, language): date_of_birth = get_time(claims, 'P569', None) if date_of_birth is not None: + date_of_birth = dateutil.parser.parse(date_of_birth[8:]).strftime(locale.nl_langinfo(locale.D_FMT)) attributes.append({'label': 'Date of birth', 'value': date_of_birth}) date_of_death = get_time(claims, 'P570', None) if date_of_death is not None: + date_of_death = dateutil.parser.parse(date_of_death[8:]).strftime(locale.nl_langinfo(locale.D_FMT)) attributes.append({'label': 'Date of death', 'value': date_of_death}) if len(attributes) == 0 and len(urls) == 2 and len(description) == 0: From 0bfc793194f44cc3c0e6fdeb9dc9c00c448c0324 Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Fri, 12 Dec 2014 19:09:02 +0100 Subject: [PATCH 02/62] Add a variable with all the icons of the theme Add for the template a list of available icons in the current theme. --- searx/webapp.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/searx/webapp.py b/searx/webapp.py index 541975573..bb412df69 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -291,6 +291,11 @@ def index(): for engine in result['engines']: if engine in favicons: result['favicon'] = engine + + mypath = searx_dir+"/static/"+get_current_theme_name()+"/img/" + favs=[] + for (dirpath, dirnames, filenames) in os.walk(mypath): + favs.extend(filenames) # TODO, check if timezone is calculated right if 'publishedDate' in result: @@ -344,7 +349,8 @@ def index(): suggestions=search.suggestions, answers=search.answers, infoboxes=search.infoboxes, - theme=get_current_theme_name() + theme=get_current_theme_name(), + favicons=favs ) From 3b88adf8b6782341d83a090ce94fe16328b19062 Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Fri, 12 Dec 2014 19:12:37 +0100 Subject: [PATCH 03/62] Use the new way of finding an icon --- searx/templates/oscar/result_templates/default.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/templates/oscar/result_templates/default.html b/searx/templates/oscar/result_templates/default.html index 0f090d862..dd537fd75 100644 --- a/searx/templates/oscar/result_templates/default.html +++ b/searx/templates/oscar/result_templates/default.html @@ -1,6 +1,6 @@ {% from 'oscar/macros.html' import icon %} -

{% if result['favicon'] %}{{ result['favicon'] }} {% endif %}{{ result.title|safe }}

+

{% if result['favicon']~".png" in favicons %}{{ result['favicon'] }} {% endif %}{{ result.title|safe }}

{% if result.publishedDate %}{% endif %} {{ icon('link') }} {{ _('cached') }} From 3ffe6014ed491e47e779fa90ae8e7bb1d8eff849 Mon Sep 17 00:00:00 2001 From: Cqoicebordel Date: Fri, 12 Dec 2014 19:13:40 +0100 Subject: [PATCH 04/62] Use the new way of finding the favicon --- searx/templates/oscar/result_templates/images.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/searx/templates/oscar/result_templates/images.html b/searx/templates/oscar/result_templates/images.html index 7689f9f58..3bdc13645 100644 --- a/searx/templates/oscar/result_templates/images.html +++ b/searx/templates/oscar/result_templates/images.html @@ -7,7 +7,7 @@