From b244701ad7e4b2e27802d5c5b661db86f2549610 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Mon, 1 Feb 2010 22:05:06 +0100 Subject: Release 0.4. The main page display only 10 articles by feeds. For each feeds a page present the list of all articles. The SQLite base is smaller than before (removed hashed value). And a lot of improvements. --- pyAggr3g470r.py | 61 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 15 deletions(-) (limited to 'pyAggr3g470r.py') diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index bb4dbcea..1f01115f 100644 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -2,11 +2,12 @@ #-*- coding: utf-8 -*- __author__ = "Cedric Bonhomme" -__version__ = "$Revision: 0.3 $" +__version__ = "$Revision: 0.4 $" __date__ = "$Date: 2010/02/01 $" __copyright__ = "Copyright (c) 2010 Cedric Bonhomme" __license__ = "GPLv3" +import base64 import sqlite3 import cherrypy import ConfigParser @@ -22,17 +23,18 @@ bindhost = "0.0.0.0" cherrypy.config.update({ 'server.socket_port': 12556, 'server.socket_host': bindhost}) -path = { '/css/style.css': {'tools.staticfile.on': True, 'tools.staticfile.filename':path+'css/style.css'} - } +path = { '/css/style.css': {'tools.staticfile.on': True, \ + 'tools.staticfile.filename':path+'css/style.css'}} htmlheader = """\n\n\n\n pyAggr3g470r - RSS Feed Reader """ -htmlfooter = """""" +htmlfooter = """This software is under GPLv3 license. + """ -htmlnav = """

pyAggr3g470r - RSS Feed Reader

pyAggr3g470r - RSS Feed Reader

pyAggr3g470r (source code) """ @@ -46,7 +48,6 @@ class Root: html = htmlheader html += htmlnav html += """
\n""" - html += """

Search

\n""" html += """
\n""" html += """Management of feed\n""" @@ -54,20 +55,25 @@ class Root: html += "Your feeds:
\n" for rss_feed in self.dic.keys(): html += """%s
\n""" % (rss_feed.encode('utf-8'), \ - rss_feed.encode('UTF-8')) + self.dic[rss_feed][0][5].encode('utf-8')) html += """
\n
\n""" for rss_feed in self.dic.keys(): html += '

' + \ - '' + rss_feed.encode('utf-8') + "

\n" + '' + self.dic[rss_feed][0][5].encode('utf-8') + "\n" - for article in self.dic[rss_feed]: + # The main page display only 10 articles by feeds. + for article in self.dic[rss_feed][:10]: html += article[1].encode('utf-8') + " - " + \ '' + article[2].encode('utf-8') + "" + \ """ - [description]""" % (article[0].encode('utf-8'),) + \ "
\n" + html += "
\n" + + html += """[All articles]""" % (rss_feed,) + html += """

Top

""" html += "
\n" html += htmlfooter return html @@ -88,7 +94,26 @@ class Root: for article in self.dic[rss_feed]: if article_id == article[0]: html += article[4].encode('utf-8') - html += """
\nComplete story""" % article[3].encode('utf-8') + html += """
\nComplete story""" % (article[3].encode('utf-8'),) + html += htmlfooter + return html + + def all_articles(self, feed_title): + """ + Display all articles of a feed ('feed_title'). + """ + html = htmlheader + html += htmlnav + html += """
""" + + for article in self.dic[feed_title]: + html += article[1].encode('utf-8') + " - " + \ + '' + article[2].encode('utf-8') + "" + \ + """ - [description]""" % (article[3].encode('utf-8'),) + \ + "
\n" + + html += """

All feeds

""" html += htmlfooter return html @@ -106,14 +131,19 @@ class Root: pass # The key of dic is the title of the feed: - # dic[feed_title] = (article_id, article_date, article_title, article_link, article_description, feed_link) + # dic[feed_title] = (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: - if article[5] not in dic: - dic[article[5]] = [(article[0], article[1], article[2], article[3], article[4], article[6])] + feed_id = base64.b64encode(article[5].encode('utf-8')) + article_id = base64.b64encode(article[2].encode('utf-8')) + + article_tuple = (article_id, article[0], article[1], article[2], article[3], article[4], article[5]) + + if feed_id not in dic: + dic[feed_id] = [article_tuple] else: - dic[article[5]].append((article[0], article[1], article[2], article[3], article[4], article[6])) + dic[feed_id].append(article_tuple) # sort articles by date for each feeds for feeds in dic.keys(): @@ -125,6 +155,7 @@ class Root: index.exposed = True f.exposed = True description.exposed = True + all_articles.exposed = True def compare(stringtime1, stringtime2): -- cgit