From 1deca6e194f20762321b54e9dbe454514e96ebf6 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Tue, 23 Feb 2010 08:15:08 +0100 Subject: Minor improvements. --- pyAggr3g470r.py | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) (limited to 'pyAggr3g470r.py') diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 372e1e76..15ff7299 100644 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -55,8 +55,8 @@ class Root: html += """Fetch all feeds\n
\n""" html += """Mark all articles as read\n
\n""" html += """Management of feed\n""" - html += """
\n""" + html += """
\n""" html += "
\n" html += """Your feeds (%s):
\n""" % len(self.dic.keys()) for rss_feed_id in self.dic.keys(): @@ -140,20 +140,23 @@ class Root: html += htmlfooter return html - def q(self, v=None): + def q(self, querystring=None): """ - Search for a feed. Simply search for the string 'v' + Search for a feed. Simply search for the string 'querystring' in the description of the article. """ - querystring = v.encode('utf-8') + param, _, value = querystring.partition(':') + feed_id = None + if param == "Feed": + feed_id, _, querystring = value.partition(':') html = htmlheader html += htmlnav html += """
""" html += """

Articles containing the string %s


""" % (querystring,) - for rss_feed_id in self.dic.keys(): - for article in self.dic[rss_feed_id][:10]: + if feed_id is not None: + for article in self.dic[rss_feed_id]: article_content = article[4].encode('utf-8') + article[2].encode('utf-8') if querystring.lower() in article_content.lower(): if article[7] == "0": @@ -168,8 +171,26 @@ class Root: " - " + not_read_begin + \ """%s""" % \ (article[0].encode('utf-8'), article[2].encode('utf-8')) + \ - not_read_end + """ from %s
\n""" % \ - (article[6].encode('utf-8'), article[5].encode('utf-8')) + not_read_end + else: + for rss_feed_id in self.dic.keys(): + for article in self.dic[rss_feed_id]: + article_content = article[4].encode('utf-8') + article[2].encode('utf-8') + if querystring.lower() in article_content.lower(): + 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') + \ + " - " + not_read_begin + \ + """%s""" % \ + (article[0].encode('utf-8'), article[2].encode('utf-8')) + \ + not_read_end + """ from %s
\n""" % \ + (article[6].encode('utf-8'), article[5].encode('utf-8')) html += "
" html += htmlfooter return html @@ -215,8 +236,8 @@ class Root: html += htmlnav html += """
\n""" html += """Mark all articles from this feed as read""" % (feed_id,) - html += """
\n
\n""" + html += """
\n
\n""" % (feed_id,) html += "
\n" html += """Your feeds (%s):
\n""" % len(self.dic.keys()) for rss_feed_id in self.dic.keys(): -- cgit