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 /utils.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 'utils.py')
-rwxr-xr-x | utils.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -15,6 +15,7 @@ import hashlib import sqlite3 import operator import urlparse +import calendar import smtplib from email.mime.text import MIMEText @@ -120,14 +121,22 @@ def top_words(dic_articles, n=10, size=5): words[word] += 1 return words.most_common(n) -def tag_cloud(tags): +def tag_cloud(tags, query="word_count"): """ Generates a tags cloud. """ tags.sort(key=operator.itemgetter(0)) - return ' '.join([('<font size="%d"><a href="/q/?querystring=%s" title="Count: %s">%s</a></font>\n' % \ + if query == "word_count": + return ' '.join([('<font size="%d"><a href="/q/?querystring=%s" title="Count: %s">%s</a></font>\n' % \ (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), word, count, word)) \ for (word, count) in tags]) + if query == "year": + return ' '.join([('<font size="%d"><a href="/history/?querystring=%s:%s" title="Count: %s">%s</a></font>\n' % \ + (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, count, word)) \ + for (word, count) in tags]) + return ' '.join([('<font size="%d"><a href="/history/?querystring=%s:%s" title="Count: %s">%s</a></font>\n' % \ + (min(1 + count * 7 / max([tag[1] for tag in tags]), 7), query, word, count, calendar.month_name[int(word)])) \ + for (word, count) in tags]) def send_mail(mfrom, mto, feed_title, message): """Send the warning via mail |