aboutsummaryrefslogtreecommitdiff
path: root/pyaggr3g470r
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-02-05 19:55:31 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-02-05 19:55:31 +0100
commitb045592c9f93572a3feb08cbfbeb7a928df280e2 (patch)
tree2a8dd6525a714495b0b7fcf0ad1f01ea78218d6a /pyaggr3g470r
parentGive an idea of the importance of a feed compared to the whole database. (diff)
downloadnewspipe-b045592c9f93572a3feb08cbfbeb7a928df280e2.tar.gz
newspipe-b045592c9f93572a3feb08cbfbeb7a928df280e2.tar.bz2
newspipe-b045592c9f93572a3feb08cbfbeb7a928df280e2.zip
Display last 'n' articles.
Diffstat (limited to 'pyaggr3g470r')
-rw-r--r--pyaggr3g470r/templates/articles.html6
-rw-r--r--pyaggr3g470r/templates/home.html2
-rw-r--r--pyaggr3g470r/views.py9
3 files changed, 12 insertions, 5 deletions
diff --git a/pyaggr3g470r/templates/articles.html b/pyaggr3g470r/templates/articles.html
index eb4701d7..97b06f6a 100644
--- a/pyaggr3g470r/templates/articles.html
+++ b/pyaggr3g470r/templates/articles.html
@@ -5,7 +5,11 @@
<h2><a href="{{ feed.site_link }}">{{ feed.title|safe }}</a></h2>
<a href="/feed/{{ feed.oid }}"><i class="glyphicon glyphicon-info-sign" title="Details"></i></a>
<a href="/edit_feed/{{ feed.oid }}"><i class="glyphicon glyphicon-edit" title="Edit this feed"></i></a>
- <h3>{{ feed.articles|count }} articles.</h3>
+ {% if nb_articles == -1 %}
+ <h3>{{ feed.articles|count }} articles.</h3>
+ {% else %}
+ <h3>Last {{ feed.articles|count }} articles. See <a href="/articles/{{ feed.oid }}">all articles</a>.</h3>
+ {% endif %}
</div>
{% if feed.articles|count == 0 %}
<h1>No articles.</h1>
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index 25cb5012..9117bce9 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -8,7 +8,7 @@
<div class="row">
<div class="col-md-6 col-md-offset-3">
<h1>{{ feed.title|safe }}</h1>
- <a href="/articles/{{ feed.oid }}"><i class="glyphicon glyphicon-th-list" title="All articles"></i></a>
+ <a href="/articles/{{ feed.oid }}/100"><i class="glyphicon glyphicon-th-list" title="More articles"></i></a>
<a href="/feed/{{ feed.oid }}"><i class="glyphicon glyphicon-info-sign" title="Details"></i></a>
<a href="/edit_feed/{{ feed.oid }}"><i class="glyphicon glyphicon-edit" title="Edit this feed"></i></a>
{% if feed.enabled %}
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index f77b49e2..02495311 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -242,13 +242,16 @@ def delete(article_id=None):
flash('Impossible to delete the article.', 'danger')
return redirect(url_for('home'))
-@app.route('/articles/<feed_id>', methods=['GET'])
+@app.route('/articles/<feed_id>/', methods=['GET'])
+@app.route('/articles/<feed_id>/<int:nb_articles>', methods=['GET'])
@login_required
-def articles(feed_id=None):
+def articles(feed_id=None, nb_articles=-1):
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('articles.html', feed=feed)
+ if nb_articles != -1:
+ feed.articles = feed.articles[0:nb_articles]
+ return render_template('articles.html', feed=feed, nb_articles=nb_articles)
@app.route('/favorites/', methods=['GET'])
@login_required
bgstack15