From a4bad7a5619a2df7d520742d911fa452fbc25a9c Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Fri, 24 Dec 2010 15:43:47 +0000 Subject: add atom feeds for tags --- tekuti/page.scm | 23 ++++++++++++++++++----- tekuti/web.scm | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tekuti/page.scm b/tekuti/page.scm index 6e0b322..f59cae2 100644 --- a/tekuti/page.scm +++ b/tekuti/page.scm @@ -55,6 +55,7 @@ page-debug page-search page-feed-atom + page-feed-atom-tag page-debug page-not-found)) @@ -314,10 +315,10 @@ ,(request-relative-path-str (pk 'not-found request)))) #:status 404)) -(define (page-feed-atom request body index) - (let ((last-modified (let ((posts (published-posts index 1))) - (and (pair? posts) - (post-timestamp (car posts)))))) + +(define (atom-feed-from-posts request body index posts) + (let ((last-modified (and (pair? posts) + (post-timestamp (car posts))))) (cond ((let ((since (request-if-modified-since request))) (and since (>= (date->timestamp since) last-modified))) @@ -334,4 +335,16 @@ (map (lambda (post) (atom-entry post)) - (published-posts index 10)))))))) + posts))))))) + + +(define (page-feed-atom request body index) + (atom-feed-from-posts request body index (published-posts index 10))) + +(define (page-feed-atom-tag request body index tag) + (let* ((tags (assq-ref index 'tags)) + (posts (filter-mapn (lambda (key) + (post-from-key (assq-ref index 'master) key)) + (hash-ref tags tag '()) + 10))) + (atom-feed-from-posts request body index posts))) diff --git a/tekuti/web.scm b/tekuti/web.scm index fcd227d..e1519d7 100644 --- a/tekuti/web.scm +++ b/tekuti/web.scm @@ -54,6 +54,7 @@ ((POST archives year! month! day! post!) page-new-comment) ((GET feed) page-feed-atom) ((GET feed atom) page-feed-atom) + ((GET feed atom tag!) page-feed-atom-tag) ((POST search) page-search) ((GET tags) page-show-tags) ((GET tags tag!) page-show-tag) -- cgit v1.2.3-54-g00ecf