From b4f26c158e654bdac0c055ad3d1d1fcbee2a931f Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Wed, 1 Jan 2014 16:49:31 +0100 Subject: Displaying more information in the /feed page. --- pyaggr3g470r/templates/feed.html | 6 +++++- pyaggr3g470r/views.py | 12 +++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/templates/feed.html b/pyaggr3g470r/templates/feed.html index 7abd133f..b0f06eb6 100644 --- a/pyaggr3g470r/templates/feed.html +++ b/pyaggr3g470r/templates/feed.html @@ -8,8 +8,12 @@

This feed contains {{ feed.articles|count }} articles.

Address of the feed: {{ feed.link }}.

Address of the site: {{ feed.site_link }}.

+
+

The last article was posted {{ elapsed.days }} day(s) ago.
+ Daily average: {{ average }}, between the {{ first_post_date.strftime('%Y-%m-%d') }} and the {{ end_post_date.strftime('%Y-%m-%d') }}.

+

Tag cloud

{{ tag_cloud|safe }}
-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index e80890af..af2abc7b 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -144,7 +144,17 @@ def feed(feed_id=None): articles = feed.articles top_words = utils.top_words(articles, n=50, size=int(word_size)) tag_cloud = utils.tag_cloud(top_words) - return render_template('feed.html', head_title=feed.title, feed=feed, tag_cloud=tag_cloud) + + today = datetime.datetime.now() + last_article = articles[0].date + first_article = articles[-1].date + delta = last_article - first_article + average = round(float(len(articles)) / abs(delta.days), 2) + elapsed = today - last_article + + return render_template('feed.html', head_title=feed.title, feed=feed, tag_cloud=tag_cloud, \ + first_post_date=first_article, end_post_date=last_article , \ + average=average, delta=delta, elapsed=elapsed) @app.route('/article/', methods=['GET']) @login_required -- cgit