From 515980eae5fe512a1e177c401d399706529d522f Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sat, 20 Sep 2003 22:29:01 +0000 Subject: [PATCH] Add maxage config option. Allow maxarticles to be 0. --- NEWS | 4 ++++ config | 5 +++++ rawdoglib/rawdog.py | 10 +++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index bfbe943..1a2df34 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,10 @@ the user to specify their own template. Added --dir option for people who want two lots of rawdog state (for two sets of feeds, for instance). +Added "maxage" config option for people who want "only items added in +the last hour", and made it possible to disable maxarticles by setting +it to 0. + - rawdog 1.2 Updated feedparser to 2.5.2, which fixes a bug that was making rawdog diff --git a/config b/config index 9aefcba..4a6f637 100644 --- a/config +++ b/config @@ -4,8 +4,13 @@ # directory. # The maximum number of articles to show on the generated page. +# Set this to 0 for no limit. maxarticles 200 +# The maximum age in minutes of articles to show on the generated page. +# Set this to 0 for no limit. +maxage 0 + # The format to write day headings in. (See "man strftime" if you want to # change this.) dayformat %A, %d %B diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index 1613411..6545ff1 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -247,6 +247,7 @@ class Config: "feedslist" : [], "outputfile" : "output.html", "maxarticles" : 200, + "maxage" : 0, "dayformat" : "%A, %d %B %Y", "timeformat" : "%I:%M %p", "userefresh" : 0, @@ -288,6 +289,8 @@ class Config: self["outputfile"] = l[1] elif l[0] == "maxarticles": self["maxarticles"] = int(l[1]) + elif l[0] == "maxage": + self["maxage"] = int(l[1]) elif l[0] == "dayformat": self["dayformat"] = l[1] elif l[0] == "timeformat": @@ -429,12 +432,17 @@ by Adam Sampson.

return i return cmp(a.hash, b.hash) articles.sort(compare) - articles = articles[:config["maxarticles"]] + if config["maxarticles"] != 0: + articles = articles[:config["maxarticles"]] f = StringIO() dw = DayWriter(f, config) for article in articles: + age = (now - article.added) / 60 + if config["maxage"] != 0 and age > config["maxage"]: + break + dw.time(article.added) feed = self.feeds[article.feed] -- 2.35.1