aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-05-23 11:34:51 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-05-23 11:34:51 +0200
commitb429058b0c737616c3d804d97a3c7e2dcbf69737 (patch)
treeed08acd3ab0b6a7966879858b0c22e0ac08c3e2c
parentDisplay unread articles for one feed. (diff)
downloadnewspipe-b429058b0c737616c3d804d97a3c7e2dcbf69737.tar.gz
newspipe-b429058b0c737616c3d804d97a3c7e2dcbf69737.tar.bz2
newspipe-b429058b0c737616c3d804d97a3c7e2dcbf69737.zip
Bootstrap badge to display the number of unread articles by feed.
-rw-r--r--pyaggr3g470r/templates/home.html9
-rw-r--r--pyaggr3g470r/views.py5
2 files changed, 10 insertions, 4 deletions
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index f10d4e11..94e4d736 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -7,14 +7,19 @@
{% for feed in result|sort(attribute="title") %}
<div class="row">
<div class="col-md-6 col-md-offset-3">
- <h1>{{ feed.title|safe }}</h1>
+ <h1>{{ feed.title|safe }}
+ {% if unread[feed.id] != 0 %}
+ <a href="/unread/{{ feed.id }}" title="Unread articles"><span class="badge">{{ unread[feed.id] }}</span></a>
+ {% endif %}</h1>
<a href="/articles/{{ feed.id }}/100"><i class="glyphicon glyphicon-th-list" title="{{ _('More articles') }}"></i></a>
<a href="/feed/{{ feed.id }}"><i class="glyphicon glyphicon-info-sign" title="{{ _('Details') }}"></i></a>
<a href="/edit_feed/{{ feed.id }}"><i class="glyphicon glyphicon-edit" title="{{ _('Edit this feed') }}"></i></a>
{% if feed.enabled %}
<a href="/fetch/{{ feed.id }}"><i class="glyphicon glyphicon-cloud-download" title="{{ _('Fetch this feed') }}"></i></a>
{% endif %}
- <a href="/mark_as_read/{{ feed.id }}"><i class="glyphicon glyphicon-check" title="{{ _('Mark all as read') }}"></i></a>
+ {% if unread[feed.id] != 0 %}
+ <a href="/mark_as_read/{{ feed.id }}"><i class="glyphicon glyphicon-check" title="{{ _('Mark all as read') }}"></i></a>
+ {% endif %}
</div>
</div>
{% for number in range(0, feed.articles.all()|count-(feed.articles.all()|count % 3), 3) %}
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index 24175024..ec3fcf35 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -213,8 +213,9 @@ def home():
The home page lists most recent articles of all feeds.
"""
user = User.query.filter(User.email == g.user.email).first()
- result = []
+ result, unread = [], {}
for feed in user.feeds:
+ unread[feed.id] = Article.query.filter(Article.user_id == g.user.id, Article.feed_id == feed.id, Article.readed == False).count()
new_feed = Feed()
new_feed.id = feed.id
new_feed.title = feed.title
@@ -223,7 +224,7 @@ def home():
Article.feed_id == feed.id).order_by(desc("Article.date")).limit(9)
result.append(new_feed)
unread_articles = len(Article.query.filter(Article.user_id == g.user.id, Article.readed == False).all())
- return render_template('home.html', result=result, head_title=unread_articles)
+ return render_template('home.html', result=result, unread=unread, head_title=unread_articles)
@app.route('/fetch/', methods=['GET'])
@app.route('/fetch/<int:feed_id>', methods=['GET'])
bgstack15