diff options
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r-- | pyaggr3g470r/templates/about.html | 2 | ||||
-rw-r--r-- | pyaggr3g470r/templates/feed.html | 2 | ||||
-rwxr-xr-x | pyaggr3g470r/utils.py | 2 | ||||
-rw-r--r-- | 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 @@ <div class="jumbotron"> <p>This software is under GPLv3 license. You are welcome to copy, modify or redistribute the <a href="https://bitbucket.org/cedricbonhomme/pyaggr3g470r/">source code</a> - according to the <a href="http://www.gnu.org/licenses/gpl-3.0.txt">GPLv3</a> license.</pa> + according to the <a href="http://www.gnu.org/licenses/gpl-3.0.txt">GPLv3</a> license.</p> </div> </div><!-- /.container --> {% 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 @@ <p>This feed contains {{ feed.articles|count }} <a href="/articles/{{ feed.oid }}">articles</a>.</p> <p>Address of the feed: <a href="{{ feed.link }}">{{ feed.link }}</a>.</p> <p>Address of the site: <a href="{{ feed.site_link }}">{{ feed.site_link }}</a>.</p> + <h3>Tag cloud</h3> + <div>{{ tag_cloud|safe }}</div> </div> </div><!-- /.container --> {% 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/<feed_id>', 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/<article_id>', methods=['GET']) @login_required |