From 53fa99369d923ef632bc340b8dffdc807f2e97a8 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sun, 19 Dec 2010 17:10:19 +0100 Subject: Improvement of the history page. --- pyAggr3g470r.py | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 253b2d50..27fd2286 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -200,9 +200,9 @@ class Root: if feed.nb_unread_articles != 0: html += """     Unread article(s) (%s)""" % (feed.feed_id, feed.nb_unread_articles) if feed.mail == "0": - html += """
\nStay tuned""" % (feed.feed_id,) + html += """
\nStay tuned""" % (feed.feed_id,) else: - html += """
\nStop staying tuned""" % (feed.feed_id,) + html += """
\nStop staying tuned""" % (feed.feed_id,) html += """

Top

""" html += "
\n" html += htmlfooter @@ -609,10 +609,7 @@ class Root: nb_unread += 1 if new_feed_section is True: new_feed_section = False - html += """

%s -

\n""" % \ + html += """

%s

\n""" % \ (feed.feed_id, feed.feed_site_link, feed.feed_title, feed.feed_link, feed.feed_image) # descrition for the CSS ToolTips @@ -716,6 +713,16 @@ class Root: like = """ """ else: like = "" + # Descrition for the CSS ToolTips + article_content = utils.clear_string(article.article_description) + if article_content: + description = " ".join(article_content[:500].split(' ')[:-1]) + else: + description = "No description." + # Title of the article + article_title = article.article_title + if len(article_title) >= 110: + article_title = article_title[:110] + " ..." if new_feed_section is True: new_feed_section = False @@ -725,10 +732,10 @@ class Root: target="_blank">\n""" % \ (feed.feed_id, feed.feed_site_link, feed.feed_title, feed.feed_link, feed.feed_image) - html += article.article_date + " - " + not_read_begin + \ - """%s""" % \ - (feed.feed_id, article.article_id, \ - utils.clear_string(article.article_title)) + not_read_end + like + "
\n" + html += article.article_date + " - " + \ + """%s%s%s%s""" % \ + (feed.feed_id, article.article_id, not_read_begin, \ + article_title, not_read_end, description) + like + "
\n" if querystring == "all": query = "year" @@ -835,7 +842,7 @@ class Root: html += "

You are receiving e-mails for the following feeds:

\n" for feed in self.feeds.values(): if feed.mail == "1": - html += """\t%s - Stop
\n""" % \ + html += """\t%s - Stop
\n""" % \ (feed.feed_id, feed.feed_title, feed.feed_id) html += """

Notifications are sent to: %s

""" % \ (utils.mail_to, utils.mail_to) @@ -856,21 +863,15 @@ class Root: if feed_id not in self.feeds.keys(): return self.error_page("This feed do not exists.") conn = sqlite3.connect(utils.sqlite_base, isolation_level = None) - c = conn.cursor() - if action == "start": - try: - c.execute("UPDATE feeds SET mail=1 WHERE feed_site_link='" + - self.feeds[feed_id].feed_site_link + "'") - except: - return self.error_page("Error") - else: - try: - c.execute("UPDATE feeds SET mail=0 WHERE feed_site_link='" + - self.feeds[feed_id].feed_site_link + "'") - except: - return self.error_page("Error") - conn.commit() - c.close() + try: + c = conn.cursor() + c.execute("""UPDATE feeds SET mail=%s WHERE feed_site_link='%s'""" % \ + (action, self.feeds[feed_id].feed_site_link)) + except: + return self.error_page("Error") + finally: + conn.commit() + c.close() return self.index() mail_notification.exposed = True -- cgit