aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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