From 7e2e3124941ce0ec35bfd841f64f60a2afe71d09 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sun, 17 Nov 2013 21:39:52 +0100 Subject: Restored tag cloud per feed. --- pyaggr3g470r/templates/about.html | 2 +- pyaggr3g470r/templates/feed.html | 2 ++ pyaggr3g470r/utils.py | 2 +- pyaggr3g470r/views.py | 7 ++++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pyaggr3g470r/templates/about.html b/pyaggr3g470r/templates/about.html index 41dbe20c..3b4a310b 100644 --- a/pyaggr3g470r/templates/about.html +++ b/pyaggr3g470r/templates/about.html @@ -4,7 +4,7 @@

This software is under GPLv3 license. You are welcome to copy, modify or redistribute the source code - according to the GPLv3 license. + according to the GPLv3 license.

{% endblock %} diff --git a/pyaggr3g470r/templates/feed.html b/pyaggr3g470r/templates/feed.html index e08ac159..7abd133f 100644 --- a/pyaggr3g470r/templates/feed.html +++ b/pyaggr3g470r/templates/feed.html @@ -8,6 +8,8 @@

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

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

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

+

Tag cloud

+
{{ tag_cloud|safe }}
{% endblock %} \ No newline at end of file diff --git a/pyaggr3g470r/utils.py b/pyaggr3g470r/utils.py index 10614b05..10db7639 100755 --- a/pyaggr3g470r/utils.py +++ b/pyaggr3g470r/utils.py @@ -143,7 +143,7 @@ def top_words(articles, n=10, size=5): wordre = re.compile(r'\b\w{%s,}\b' % size, re.I) for article in articles: for word in [elem.lower() for elem in - wordre.findall(clear_string(article["article_content"])) \ + wordre.findall(clear_string(article.content)) \ if elem.lower() not in stop_words]: words[word] += 1 return words.most_common(n) diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py index a7c99c99..d44b3d60 100644 --- a/pyaggr3g470r/views.py +++ b/pyaggr3g470r/views.py @@ -38,6 +38,7 @@ from forms import SigninForm, AddFeedForm from pyaggr3g470r import app, db +import utils import feedgetter import models import search as fastsearch @@ -124,10 +125,14 @@ def feeds(): @app.route('/feed/', methods=['GET']) @login_required def feed(feed_id=None): + word_size = 5 user = models.User.objects(email=g.user.email, feeds__oid=feed_id).first() for feed in user.feeds: if str(feed.oid) == feed_id: - return render_template('feed.html', feed=feed) + 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', feed=feed, tag_cloud=tag_cloud) @app.route('/article/', methods=['GET']) @login_required -- cgit