From 3ffc8b19183fbddf5b005026d2f2cbf8ae318918 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 3 May 2003 12:59:39 +0000 Subject: [PATCH] Add feeds display. --- config | 3 +++ rawdog | 33 ++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/config b/config index caa8151..b39306f 100644 --- a/config +++ b/config @@ -22,6 +22,9 @@ outputfile /home/azz/public_html/rawdog.html # minutes, where N is the shortest feed period value specified below. userefresh 1 +# Whether to show the list of active feeds in the generated HTML. +showfeeds 1 + # The feeds you want to watch, in the format "feed period url". # The period is the minimum time in minutes between updates; if less # than period minutes have passed, "rawdog update" will skip that feed. diff --git a/rawdog b/rawdog index c41278c..a67cff3 100644 --- a/rawdog +++ b/rawdog @@ -32,6 +32,11 @@ def maybe_get(hash, key): if hash.has_key(key): return hash[key] return None +def format_time(secs, config): + """Format a time and date nicely.""" + t = time.localtime(secs) + return time.strftime(config["timeformat"], t) + ", " + time.strftime(config["dayformat"], t) + class Feed: """An RSS feed.""" @@ -263,9 +268,28 @@ class Rawdog: f.write('\n') dw.close() - - print >>f, """ -' + + if config["showfeeds"]: + print >>f, """

Feeds

+
+ + + +""" + feeds = self.feeds.values() + feeds.sort(lambda a, b: cmp(a.get_html_name().lower(), b.get_html_name().lower())) + for feed in feeds: + print >>f, '' + print >>f, '' + print >>f, '' + print >>f, '' + print >>f, '' + print >>f, '' + print >>f, """
FeedRSSLast updateNext update
' + feed.get_html_link() + 'XML' + format_time(feed.last_update, config) + '' + format_time(feed.last_update + 60 * feed.period, config) + '
+
""" + + print >>f, """ @@ -302,6 +326,7 @@ def main(argv): "dayformat" : "%A, %d %B %Y", "timeformat" : "%I:%M %p", "userefresh" : 0, + "showfeeds" : 1, } for line in f.readlines(): line = line.strip() @@ -325,6 +350,8 @@ def main(argv): config["timeformat"] = l[1] elif l[0] == "userefresh": config["userefresh"] = int(l[1]) + elif l[0] == "showfeeds": + config["showfeeds"] = int(l[1]) else: print "Unknown config command: " + l[0] return 1 -- 2.35.1