From 6c559d487f96a85194e432248a4055945157ef82 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Fri, 5 Feb 2010 13:10:45 +0100 Subject: Unread articles are now in bold (new field in the SQLite database). New tabs for articles's description are opened with the _rel=noreferrer_ option in order to separates processes (useful with Chromium). --- feedgetter.py | 8 +++++--- pyAggr3g470r.py | 38 +++++++++++++++++++++++++++++++++----- var/feed.lst | 3 +++ 3 files changed, 41 insertions(+), 8 deletions(-) diff --git a/feedgetter.py b/feedgetter.py index a16585d8..b65a25e9 100644 --- a/feedgetter.py +++ b/feedgetter.py @@ -44,7 +44,8 @@ class FeedGetter(object): self.c.execute('''create table if not exists rss_feed (article_date text, article_title text, \ article_link text PRIMARY KEY, article_description text, \ - feed_title text, feed_site_link text)''') + feed_title text, feed_site_link text, \ + article_readed text)''') self.conn.commit() self.c.close() @@ -110,13 +111,14 @@ class FeedGetter(object): article_id = sha256_hash.hexdigest() try: - self.c.execute('insert into rss_feed values (?,?,?,?,?,?)', (\ + self.c.execute('insert into rss_feed values (?,?,?,?,?,?,?)', (\ datetime(*article.updated_parsed[:6]), \ article.title.encode('utf-8'), \ article.link.encode('utf-8'), \ description, \ a_feed.feed.title.encode('utf-8'), \ - a_feed.feed.link.encode('utf-8'))) + a_feed.feed.link.encode('utf-8'), \ + "0")) except sqlite3.IntegrityError: pass diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index fe2ad47b..d12fc942 100644 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -69,10 +69,20 @@ class Root: # The main page display only 10 articles by feeds. for article in self.dic[rss_feed_id][:10]: + + if article[7] == "0": + # not readed articles are in bold + not_read_begin = "" + not_read_end = "" + else: + not_read_begin = "" + not_read_end = "" + html += article[1].encode('utf-8') + " - " + \ - '' + article[2].encode('utf-8') + "" + \ - """ - [description]""" % (article[0].encode('utf-8'),) + \ + not_read_begin + \ + """ - %s""" % \ + (article[0].encode('utf-8'), article[2].encode('utf-8')) + \ + not_read_end + \ "
\n" html += "
\n" @@ -105,6 +115,9 @@ class Root: for rss_feed_id in self.dic.keys(): for article in self.dic[rss_feed_id]: if article_id == article[0]: + + self.mark_as_read(article[3]) + html += """

%s from %s


""" % \ (article[2].encode('utf-8'), rss_feed_id, article[5].encode('utf-8')) description = article[4].encode('utf-8') @@ -151,7 +164,7 @@ class Root: pass # The key of dic is the id of the feed: - # dic[feed_if] = (article_id, article_date, article_title, article_link, article_description, feed_title, feed_link) + # dic[feed_id] = (article_id, article_date, article_title, article_link, article_description, feed_title, feed_link) dic = {} if list_of_articles is not None: for article in list_of_articles: @@ -161,7 +174,8 @@ class Root: sha256_hash.update(article[2].encode('utf-8')) article_id = sha256_hash.hexdigest() - article_tuple = (article_id, article[0], article[1], article[2], article[3], article[4], article[5]) + article_tuple = (article_id, article[0], article[1], \ + article[2], article[3], article[4], article[5], article[6]) if feed_id not in dic: dic[feed_id] = [article_tuple] @@ -175,6 +189,20 @@ class Root: return dic return dic + def mark_as_read(self, article_link): + """ + Mark an article as read by setting the value of the field + 'article_readed' of the SQLite database to 1. + """ + try: + conn = sqlite3.connect("./var/feed.db", isolation_level = None) + c = conn.cursor() + c.execute("UPDATE rss_feed SET article_readed=1 WHERE article_link='" + article_link + "'") + conn.commit() + c.close() + except Exception, e: + pass + index.exposed = True m.exposed = True f.exposed = True diff --git a/var/feed.lst b/var/feed.lst index fb8efcd6..02fc20c5 100644 --- a/var/feed.lst +++ b/var/feed.lst @@ -18,3 +18,6 @@ http://www.le-tigre.net/spip.php?page=backend http://formats-ouverts.org/rss.php http://lwn.net/headlines/newrss http://kernelnewbies.org/RecentChanges?action=rss_rc&ddiffs=1&unique=1 +http://www.kroah.com/log/index.rss +http://www.lessentiel.lu/rss/news.tmpl +http://www.jeffersonswheel.org/?feed=rss2 -- cgit