aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-20 15:31:12 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-09-20 15:31:12 +0200
commit2abfc7c43131e0366137b27b0b75132da6ef6582 (patch)
treecd313c9c1a80fb64508b2e17b660b8108452cbce /src
parentFew improvemnts for the tag cloud of the user's profile pages. (diff)
downloadnewspipe-2abfc7c43131e0366137b27b0b75132da6ef6582.tar.gz
newspipe-2abfc7c43131e0366137b27b0b75132da6ef6582.tar.bz2
newspipe-2abfc7c43131e0366137b27b0b75132da6ef6582.zip
simple test of a 'popular' page.
Diffstat (limited to 'src')
-rw-r--r--src/web/templates/popular.html13
-rw-r--r--src/web/views/views.py13
2 files changed, 26 insertions, 0 deletions
diff --git a/src/web/templates/popular.html b/src/web/templates/popular.html
new file mode 100644
index 00000000..6b2e9001
--- /dev/null
+++ b/src/web/templates/popular.html
@@ -0,0 +1,13 @@
+{% extends "layout.html" %}
+{% block content %}
+<div class="container">
+ <h1>Popular feeds</h1>
+ <ul class="list-group">
+ {% for feed in popular %}
+ <li class="list-group-item">
+ <a href="{{ feed[0] }}">{{ feed[0] }}</a> <span class="badge">{{ feed[1] }}</span>
+ </li>
+ {% endfor %}
+</ul>
+</div><!-- /.container -->
+{% endblock %}
diff --git a/src/web/views/views.py b/src/web/views/views.py
index a7c842d7..c3425a17 100644
--- a/src/web/views/views.py
+++ b/src/web/views/views.py
@@ -1,9 +1,11 @@
import logging
+from collections import Counter
from flask import (request, render_template, flash,
url_for, redirect, current_app)
from flask_babel import gettext
from conf import API_ROOT
+from web.controllers import FeedController
from web.lib.view_utils import etag_match
logger = logging.getLogger(__name__)
@@ -40,6 +42,17 @@ def handle_sqlalchemy_assertion_error(error):
return error.args[0], 400
+@current_app.route('/popular', methods=['GET'])
+@etag_match
+def popular():
+ feeds = FeedController().read().all()
+ counter = Counter()
+ for feed in feeds:
+ counter[feed.link] += 1
+ print(counter.most_common(50))
+ return render_template('popular.html', popular=counter.most_common(50))
+
+
@current_app.route('/about', methods=['GET'])
@etag_match
def about():
bgstack15