diff options
author | cedricbonhomme <devnull@localhost> | 2010-09-03 10:58:37 +0200 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2010-09-03 10:58:37 +0200 |
commit | 2de2910a2a8311f27fc243cefacb20b601d280b2 (patch) | |
tree | c85f0d2d4a8ffa046448df446ca296f3d06b11f0 /pyAggr3g470r.py | |
parent | Added detect_url_errors() function. (diff) | |
download | newspipe-2de2910a2a8311f27fc243cefacb20b601d280b2.tar.gz newspipe-2de2910a2a8311f27fc243cefacb20b601d280b2.tar.bz2 newspipe-2de2910a2a8311f27fc243cefacb20b601d280b2.zip |
Added history page with a tag clouds.
Diffstat (limited to 'pyAggr3g470r.py')
-rwxr-xr-x | pyAggr3g470r.py | 72 |
1 files changed, 72 insertions, 0 deletions
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 = """<div class="right inner">\n""" html += """<a href="/management/">Management</a><br />\n""" + html += """<a href="/history/">History</a><br />\n""" html += """<a href="/fetch/">Fetch all feeds</a><br />\n""" html += """<a href="/mark_as_read/All:">Mark articles as read</a>\n""" html += """<form method=get action="/q/"><input type="text" name="querystring" value=""><input @@ -573,6 +577,74 @@ class Root: language.exposed = True + def history(self, querystring="all"): + """ + History + """ + html = htmlheader() + html += htmlnav + html += """<div class="left inner">\n""" + + if querystring == "all": + html += "<h1>Chose a year</h1></br >\n" + if "year" in querystring: + the_year = querystring.split('-')[0].split(':')[1] + if "month" in querystring: + the_month = querystring.split('-')[1].split(':')[1] + html += "<h1>Articles of "+ calendar.month_name[int(the_month)] + \ + ", "+ the_year +".</h1><br />\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 = "<b>" + not_read_end = "</b>" + else: + not_read_begin = "" + not_read_end = "" + + if article[7] == "1": + like = """ <img src="/css/img/heart.png" title="I like this article!" />""" + else: + like = "" + + html += article[1].encode('utf-8') + \ + " - " + not_read_begin + \ + """<a href="/description/%s:%s" rel="noreferrer" target="_blank">%s</a>""" % \ + (rss_feed_id, article[0].encode('utf-8'), \ + utils.clear_string(article[2].encode('utf-8'))) + \ + not_read_end + like + \ + "<br />\n" + + if querystring == "all": + query = "year" + elif "year" in querystring: + query = "year:" + the_year + "-month" + if "month" not in querystring: + html += '<div style="width: 35%; overflow:hidden; text-align: justify">' + \ + utils.tag_cloud([(elem, timeline[elem]) for elem in timeline.keys()], \ + query) + '</div>' + + html += "<hr />\n" + html += htmlfooter + return html + + history.exposed = True + + def plain_text(self, target): """ Display an article in plain text (without HTML tags). |