From 2de2910a2a8311f27fc243cefacb20b601d280b2 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Fri, 3 Sep 2010 10:58:37 +0200 Subject: Added history page with a tag clouds. --- pyAggr3g470r.py | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) (limited to 'pyAggr3g470r.py') diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 08250b87..aed658c8 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -11,8 +11,11 @@ import os import time import sqlite3 import cherrypy +import calendar import threading +from collections import Counter + import utils import feedgetter import PyQRNative @@ -151,6 +154,7 @@ class Root: """ html = """
\n""" html += """Management
\n""" + html += """History
\n""" html += """Fetch all feeds
\n""" html += """Mark articles as read\n""" html += """
\n""" + + if querystring == "all": + html += "

Chose a year


\n" + if "year" in querystring: + the_year = querystring.split('-')[0].split(':')[1] + if "month" in querystring: + the_month = querystring.split('-')[1].split(':')[1] + html += "

Articles of "+ calendar.month_name[int(the_month)] + \ + ", "+ the_year +".


\n" + + timeline = Counter() + for rss_feed_id in self.feeds.keys(): + for article in self.articles[rss_feed_id]: + + if querystring == "all": + timeline[article[1].encode('utf-8').split(' ')[0].split('-')[0]] += 1 + + elif querystring[:4] == "year": + + if article[1].encode('utf-8').split(' ')[0].split('-')[0] == the_year: + timeline[article[1].encode('utf-8').split(' ')[0].split('-')[1]] += 1 + + if "month" in querystring: + if article[1].encode('utf-8').split(' ')[0].split('-')[1] == the_month: + if article[5] == "0": + # not readed articles are in bold + not_read_begin = "" + not_read_end = "" + else: + not_read_begin = "" + not_read_end = "" + + if article[7] == "1": + like = """ """ + else: + like = "" + + html += article[1].encode('utf-8') + \ + " - " + not_read_begin + \ + """%s""" % \ + (rss_feed_id, article[0].encode('utf-8'), \ + utils.clear_string(article[2].encode('utf-8'))) + \ + not_read_end + like + \ + "
\n" + + if querystring == "all": + query = "year" + elif "year" in querystring: + query = "year:" + the_year + "-month" + if "month" not in querystring: + html += '
' + \ + utils.tag_cloud([(elem, timeline[elem]) for elem in timeline.keys()], \ + query) + '
' + + html += "
\n" + html += htmlfooter + return html + + history.exposed = True + + def plain_text(self, target): """ Display an article in plain text (without HTML tags). -- cgit