diff options
author | cedricbonhomme <devnull@localhost> | 2012-05-01 10:25:12 +0200 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2012-05-01 10:25:12 +0200 |
commit | a98707659b4b07791fd82b0b7d64ce46b9f6ad22 (patch) | |
tree | 1877ef644153dd4ae6805b2eeb6ba9115f078a0d /source | |
parent | Updated default configuration file. (diff) | |
download | newspipe-a98707659b4b07791fd82b0b7d64ce46b9f6ad22.tar.gz newspipe-a98707659b4b07791fd82b0b7d64ce46b9f6ad22.tar.bz2 newspipe-a98707659b4b07791fd82b0b7d64ce46b9f6ad22.zip |
Minor bugfix: links to previous and following articles were wrong.
Diffstat (limited to 'source')
-rwxr-xr-x | source/pyAggr3g470r.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index a9434fba..fb20d95e 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -479,20 +479,24 @@ class Root: f.save("./var/qrcode/"+article_id+".png") # Previous and following articles - articles_list = articles.distinct("article_id") + previous, following = None, None + liste = self.mongo.get_articles_from_collection(feed_id) + for current_article in self.mongo.get_articles_from_collection(feed_id): + articles.next() + if current_article["article_id"] == article_id: + break + following = current_article + if following is None: + following = liste[liste.count()-1] try: - following = articles[articles_list.index(article_id) - 1] - html += """<div style="float:right;"><a href="/article/%s:%s" title="%s"><img src="/img/following-article.png" /></a></div>\n""" % \ - (feed_id, following["article_id"], following["article_title"]) - except Exception, e: - print e - try: - previous = articles[articles_list.index(article_id) + 1] - except: - previous = articles[0] - finally: - html += """<div style="float:left;"><a href="/article/%s:%s" title="%s"><img src="/img/previous-article.png" /></a></div>\n""" % \ - (feed_id, previous["article_id"], previous["article_title"]) + previous = articles.next() + except StopIteration: + previous = liste[0] + + html += """<div style="float:right;"><a href="/article/%s:%s" title="%s"><img src="/img/following-article.png" /></a></div>\n""" % \ + (feed_id, following["article_id"], following["article_title"]) + html += """<div style="float:left;"><a href="/article/%s:%s" title="%s"><img src="/img/previous-article.png" /></a></div>\n""" % \ + (feed_id, previous["article_id"], previous["article_title"]) html += "\n</div>\n" |