Add maxage config option.
authorAdam Sampson <ats@offog.org>
Sat, 20 Sep 2003 22:29:01 +0000 (22:29 +0000)
committerAdam Sampson <ats@offog.org>
Sat, 20 Sep 2003 22:29:01 +0000 (22:29 +0000)
Allow maxarticles to be 0.

NEWS
config
rawdoglib/rawdog.py

diff --git a/NEWS b/NEWS
index bfbe943fa349ec14ff579d9da13ddf776285c22b..1a2df34f108a3b449784b4d55fb46cc54e1320fc 100644 (file)
--- 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 9aefcbaaa62792d27f5b16b247b20324facdf59e..4a6f637b493054310fa44e76d5d5717d1722972e 100644 (file)
--- 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
index 16134116c0f8bb7cb60ad1581cd8b55af0cea7bf..6545ff1b5b361109fdb632279ae20c17baf69526 100644 (file)
@@ -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 <a href="mailto:azz@us-lot.org">Adam Sampson</a>.</p>
                                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]