aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2014-01-12 10:59:35 +0100
committerCédric Bonhomme <cedric@cedricbonhomme.org>2014-01-12 10:59:35 +0100
commit6058ac1fc751fcdacd87096d2e491f5437b3265c (patch)
tree4840a5a738bcc2c7a7099be1713edf84545db02a
parentKeep the MongoDB database and Whoosh index synchronized. (diff)
downloadnewspipe-6058ac1fc751fcdacd87096d2e491f5437b3265c.tar.gz
newspipe-6058ac1fc751fcdacd87096d2e491f5437b3265c.tar.bz2
newspipe-6058ac1fc751fcdacd87096d2e491f5437b3265c.zip
It is now possible to feth only one feed.
-rw-r--r--pyaggr3g470r/feedgetter.py8
-rw-r--r--pyaggr3g470r/templates/home.html1
-rw-r--r--pyaggr3g470r/views.py5
3 files changed, 10 insertions, 4 deletions
diff --git a/pyaggr3g470r/feedgetter.py b/pyaggr3g470r/feedgetter.py
index abfa7994..8e1a2e58 100644
--- a/pyaggr3g470r/feedgetter.py
+++ b/pyaggr3g470r/feedgetter.py
@@ -69,11 +69,15 @@ class FeedGetter(object):
feedparser.USER_AGENT = conf.USER_AGENT
self.user = models.User.objects(email=email).first()
- def retrieve_feed(self):
+ def retrieve_feed(self, feed_id=None):
"""
Parse the file 'feeds.lst' and launch a thread for each RSS feed.
"""
- for current_feed in [feed for feed in self.user.feeds if feed.enabled]:
+ feeds = [feed for feed in self.user.feeds if feed.enabled]
+ if feed_id != None:
+ feeds = [feed for feed in feeds if str(feed.oid) == feed_id]
+ print len(feeds)
+ for current_feed in feeds:
try:
# launch a new thread for the RSS feed
thread = threading.Thread(None, self.process, \
diff --git a/pyaggr3g470r/templates/home.html b/pyaggr3g470r/templates/home.html
index c3548e79..72ea1abc 100644
--- a/pyaggr3g470r/templates/home.html
+++ b/pyaggr3g470r/templates/home.html
@@ -11,6 +11,7 @@
<a href="/articles/{{ feed.oid }}"><i class="glyphicon glyphicon-th-list" title="All articles"></i></a>
<a href="/feed/{{ feed.oid }}"><i class="glyphicon glyphicon-eye-open" title="Details"></i></a>
<a href="/edit_feed/{{ feed.oid }}"><i class="glyphicon glyphicon-edit" title="Edit this feed"></i></a>
+ <a href="/fetch/{{ feed.oid }}"><i class="glyphicon glyphicon-cloud-download" title="Fetch this feed"></i></a>
</div>
</div>
{% for number in range(0, feed.articles|length-(feed.articles|length % 3), 3) %}
diff --git a/pyaggr3g470r/views.py b/pyaggr3g470r/views.py
index b0977c65..e44da631 100644
--- a/pyaggr3g470r/views.py
+++ b/pyaggr3g470r/views.py
@@ -104,13 +104,14 @@ def home():
return render_template('home.html', user=user, feeds=feeds)
@app.route('/fetch/', methods=['GET'])
+@app.route('/fetch/<feed_id>', methods=['GET'])
@login_required
-def fetch():
+def fetch(feed_id=None):
"""
Triggers the download of news.
"""
feed_getter = feedgetter.FeedGetter(g.user.email)
- feed_getter.retrieve_feed()
+ feed_getter.retrieve_feed(feed_id)
flash("New articles retrieved.", 'success')
return redirect(url_for('home'))
bgstack15