From e5677b163b88d12ce7a94f03cb61ada236a5dd2b Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 1 Dec 2013 23:43:12 +0100 Subject: Minor improvements for the /search page. --- pyaggr3g470r/search.py | 2 +- pyaggr3g470r/templates/search.html | 1 + pyaggr3g470r/views.py | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/search.py b/pyaggr3g470r/search.py index 4a8df1d9..4b8602f7 100644 --- a/pyaggr3g470r/search.py +++ b/pyaggr3g470r/search.py @@ -111,7 +111,7 @@ def search(term): results = searcher.search(query, limit=None) for article in results: result_dict[article["feed_id"]].append(article["article_id"]) - return result_dict + return result_dict, len(results) def nb_documents(): """ diff --git a/pyaggr3g470r/templates/search.html b/pyaggr3g470r/templates/search.html index 93fe5062..e62cd45b 100644 --- a/pyaggr3g470r/templates/search.html +++ b/pyaggr3g470r/templates/search.html @@ -4,6 +4,7 @@ {% if feeds|count == 0 %}

No results.

{% else %} +

{{ nb_articles }} {% if nb_articles !=1 %} results {% else %} result {% endif %} for {{ query }}

{% for feed in feeds|sort(attribute="title") %}
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index 98362d05..cdbc1a45 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -262,7 +262,7 @@ def search(): result = [] query = request.args.get('query', None) if query != None: - results = fastsearch.search(query) + results, nb_articles = fastsearch.search(query) for feed_id in results: for feed in user.feeds: if str(feed.oid) == feed_id: @@ -271,7 +271,7 @@ def search(): current_article = models.Article.objects(id=article_id).first() feed.articles.append(current_article) result.append(feed) - return render_template('search.html', feeds=result) + return render_template('search.html', feeds=result, nb_articles=nb_articles, query=query) @app.route('/management/', methods=['GET']) @login_required -- cgit