Commits

Cédric Bonhomme  committed 30022ef

Restored tag cloud per feed.

  • Participants
  • Parent commits 59e9db3

Comments (0)

Files changed (4)

File pyaggr3g470r/templates/about.html

     <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 %}

File pyaggr3g470r/templates/feed.html

         <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 %}

File pyaggr3g470r/utils.py

     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)

File pyaggr3g470r/views.py

 from pyaggr3g470r import app, db
 
 
+import utils
 import feedgetter
 import models
 import search as fastsearch
 @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