From 052b5592a2b480daa8363541c32e97e96bac5732 Mon Sep 17 00:00:00 2001 From: Nicolas Gelot Date: Thu, 16 May 2019 21:54:48 +0200 Subject: [PATCH] Fix first page render This pathc fixes the render of the first page. This one have to display general results plus a sample of 5 images and 2 videos. Previously, torrent and videos results were included. This change is related to the comment https://gitlab.e.foundation/e/cloud/my-spot/issues/30#note_10233 --- searx/webapp.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/searx/webapp.py b/searx/webapp.py index 23188fc83..d82401fa5 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -510,16 +510,10 @@ def index(): results_copy = copy.deepcopy(search_data.results) if is_general_first_page: - for res in results_copy: - if res.get('category') == 'images': - if len(images) < 5: - images.append(res) - results_copy.remove(res) - elif res.get('category') == 'videos': - if len(videos) < 2: - videos.append(res) - results_copy.remove(res) - elif res.get('category') is None: + images = [r for r in results_copy if r.get('category') == 'images'][:5] + videos = [r for r in results_copy if r.get('category') == 'videos'][:2] + for res in search_data.results: + if res.get('category') != 'general': results_copy.remove(res) # output -- GitLab