[bknr-cvs] hans changed trunk/bknr/web/src/

BKNR Commits bknr at bknr.net
Sat Jul 19 06:05:57 UTC 2008


Revision: 3511
Author: hans
URL: http://bknr.net/trac/changeset/3511

Tweaks to make RSS channel controllable by query parameters.

U   trunk/bknr/web/src/packages.lisp
U   trunk/bknr/web/src/rss/rss.lisp

Modified: trunk/bknr/web/src/packages.lisp
===================================================================
--- trunk/bknr/web/src/packages.lisp	2008-07-18 21:34:47 UTC (rev 3510)
+++ trunk/bknr/web/src/packages.lisp	2008-07-19 06:05:56 UTC (rev 3511)
@@ -19,7 +19,7 @@
 	   #:start-cron))
 
 (defpackage :bknr.rss
-  (:use :cl :cl-user :cl-ppcre :bknr.utils :bknr.xml :puri :cxml-xmls :bknr.datastore :bknr.indices :cxml)
+  (:use :cl :cl-user :cl-ppcre :bknr.utils :bknr.xml :puri :hunchentoot :bknr.datastore :bknr.indices :cxml)
   (:export ;; channel
 
 	   #:rss-channel

Modified: trunk/bknr/web/src/rss/rss.lisp
===================================================================
--- trunk/bknr/web/src/rss/rss.lisp	2008-07-18 21:34:47 UTC (rev 3510)
+++ trunk/bknr/web/src/rss/rss.lisp	2008-07-19 06:05:56 UTC (rev 3511)
@@ -111,11 +111,14 @@
 (defgeneric rss-channel-items (channel)
   (:documentation "Return all non-expired items in channel.")
   (:method ((channel rss-channel))
-    (let ((expiry-time (- (get-universal-time) (rss-channel-max-item-age channel))))
-      (remove-if (lambda (item) (or (object-destroyed-p item)
-                                    (< (rss-item-pub-date item) expiry-time)))
-                 (slot-value channel 'items)))))
-
+    (let ((days (when (boundp 'hunchentoot:*request*) (bknr.web:query-param "days"))))
+      (let ((expiry-time (- (get-universal-time) (if days
+                                                     (* 60 60 25 (parse-integer days))
+                                                     (rss-channel-max-item-age channel)))))
+        (remove-if (lambda (item) (or (object-destroyed-p item)
+                                      (< (rss-item-pub-date item) expiry-time)))
+                   (slot-value channel 'items))))))
+  
 (deftransaction rss-channel-cleanup (channel)
   "Remove expired items from the items list.  Can be used to reduce
 the memory footprint of very high volume channels."




More information about the Bknr-cvs mailing list