diff options
author | cedricbonhomme <devnull@localhost> | 2012-05-17 08:54:23 +0200 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2012-05-17 08:54:23 +0200 |
commit | 71e5ba35f069c09ef9e5faba92ed35095fbf5f86 (patch) | |
tree | f233ea9cc2f8ee0a04a47a2ddbe4d97c4dbc21fc /source/pyAggr3g470r.py | |
parent | Minor bugfix in mongodb.py: delete_article function didn't delete articles. (diff) | |
download | newspipe-71e5ba35f069c09ef9e5faba92ed35095fbf5f86.tar.gz newspipe-71e5ba35f069c09ef9e5faba92ed35095fbf5f86.tar.bz2 newspipe-71e5ba35f069c09ef9e5faba92ed35095fbf5f86.zip |
Improvement: get_articles_from_collection() function can now return only the last 10 articles.
Diffstat (limited to 'source/pyAggr3g470r.py')
-rwxr-xr-x | source/pyAggr3g470r.py | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/source/pyAggr3g470r.py b/source/pyAggr3g470r.py index 6d873ccd..17cfb549 100755 --- a/source/pyAggr3g470r.py +++ b/source/pyAggr3g470r.py @@ -158,7 +158,7 @@ class Root: feed["feed_link"], feed["feed_image"]) # The main page display only 10 articles by feeds. - for article in self.mongo.get_articles_from_collection(feed["feed_id"])[:10]: + for article in self.mongo.get_articles_from_collection(feed["feed_id"], limit=10): if article["article_readed"] == False: # not readed articles are in bold not_read_begin, not_read_end = "<b>", "</b>" @@ -563,7 +563,7 @@ class Root: """ try: feed = self.mongo.get_feed(feed_id) - articles = self.mongo.get_articles_from_collection(feed_id) + articles = self.mongo.get_articles_from_collection(feed_id, limit=10) nb_articles_feed = self.mongo.nb_articles(feed_id) nb_articles_total = self.mongo.nb_articles() nb_unread_articles_feed = self.mongo.nb_unread_articles(feed_id) @@ -596,7 +596,7 @@ class Root: (str(articles[nb_articles_feed-2]["article_date"])[:10], str(articles[0]["article_date"])[:10]) html += "<br /><h1>Recent articles</h1>" - for article in articles[:10]: + for article in articles: if article["article_readed"] == False: # not readed articles are in bold not_read_begin, not_read_end = "<b>", "</b>" @@ -629,23 +629,22 @@ class Root: html += "<br />\n" html += """<a href="/articles/%s">All articles</a> """ % (feed["feed_id"],) - favs = [article for article in articles if article["article_like"] == True] - if len(favs) != 0: + + if self.mongo.nb_favorites(feed_id) != 0: html += "<br /></br /><h1>Your favorites articles for this feed</h1>" - for article in favs: - if article["like"] == True: - # descrition for the CSS ToolTips - article_content = utils.clear_string(article["article_content"]) - if article_content: - description = " ".join(article_content[:500].split(' ')[:-1]) - else: - description = "No description." + for article in self.mongo.get_favorites(feed_id): + #descrition for the CSS ToolTips + article_content = utils.clear_string(article["article_content"]) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." - # a description line per article (date, title of the article and - # CSS description tooltips on mouse over) - html += article["article_date"].ctime() + " - " + \ - """<a class="tooltip" href="/article/%s:%s" rel="noreferrer" target="_blank">%s<span class="classic">%s</span></a><br />\n""" % \ - (feed["feed_id"], article["article_id"], article["article_title"][:150], description) + # a description line per article (date, title of the article and + # CSS description tooltips on mouse over) + html += article["article_date"].ctime() + " - " + \ + """<a class="tooltip" href="/article/%s:%s" rel="noreferrer" target="_blank">%s<span class="classic">%s</span></a><br />\n""" % \ + (feed["feed_id"], article["article_id"], article["article_title"][:150], description) # This section enables the user to edit informations about |