From b4439fea36278b24916a82db9f1883bfbd032e32 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 27 Sep 2018 23:56:56 -0700 Subject: search creator name unicode work-around --- python/fatcat/search.py | 7 +++++-- python/fatcat/templates/release_search.html | 1 - 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/python/fatcat/search.py b/python/fatcat/search.py index 959bb85f..0b038859 100644 --- a/python/fatcat/search.py +++ b/python/fatcat/search.py @@ -6,7 +6,7 @@ from fatcat import app def do_search(q, limit=20): - print("Search hit: " + q) + #print("Search hit: " + q) if limit > 100: # Sanity check limit = 100 @@ -35,12 +35,15 @@ def do_search(q, limit=20): abort(resp.status_code) content = resp.json() - print(content) + #print(content) results = [h['_source'] for h in content['hits']['hits']] for h in results: # Ensure 'contrib_names' is a list, not a single string if type(h['contrib_names']) is not list: h['contrib_names'] = [h['contrib_names'], ] + # TODO: a total hack; why is elastic sending weird surrogate + # characters? + h['contrib_names'] = [name.encode('utf8', 'ignore').decode('utf8') for name in h['contrib_names']] found = content['hits']['total'] return {"query": { "q": q }, diff --git a/python/fatcat/templates/release_search.html b/python/fatcat/templates/release_search.html index 1f78aaaf..800d550e 100644 --- a/python/fatcat/templates/release_search.html +++ b/python/fatcat/templates/release_search.html @@ -28,7 +28,6 @@ {% endif %} {% if paper.container_is_oa %}{% endif %} {% endif %} - {% else %}
-- cgit v1.2.3