1
0
Fork 0

add atom feeds for tags

This commit is contained in:
Brian Gough 2010-12-24 15:43:47 +00:00 committed by Andy Wingo
parent efc25df8f4
commit a4bad7a561
2 changed files with 19 additions and 5 deletions

View file

@ -55,6 +55,7 @@
page-debug page-debug
page-search page-search
page-feed-atom page-feed-atom
page-feed-atom-tag
page-debug page-debug
page-not-found)) page-not-found))
@ -314,10 +315,10 @@
,(request-relative-path-str (pk 'not-found request)))) ,(request-relative-path-str (pk 'not-found request))))
#:status 404)) #:status 404))
(define (page-feed-atom request body index)
(let ((last-modified (let ((posts (published-posts index 1))) (define (atom-feed-from-posts request body index posts)
(and (pair? posts) (let ((last-modified (and (pair? posts)
(post-timestamp (car posts)))))) (post-timestamp (car posts)))))
(cond (cond
((let ((since (request-if-modified-since request))) ((let ((since (request-if-modified-since request)))
(and since (>= (date->timestamp since) last-modified))) (and since (>= (date->timestamp since) last-modified)))
@ -334,4 +335,16 @@
(map (map
(lambda (post) (lambda (post)
(atom-entry 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)))

View file

@ -54,6 +54,7 @@
((POST archives year! month! day! post!) page-new-comment) ((POST archives year! month! day! post!) page-new-comment)
((GET feed) page-feed-atom) ((GET feed) page-feed-atom)
((GET feed atom) page-feed-atom) ((GET feed atom) page-feed-atom)
((GET feed atom tag!) page-feed-atom-tag)
((POST search) page-search) ((POST search) page-search)
((GET tags) page-show-tags) ((GET tags) page-show-tags)
((GET tags tag!) page-show-tag) ((GET tags tag!) page-show-tag)