1 ;;; Copyright © 2019 Amin Bandali <bandali@gnu.org>
3 ;;; This program is free software; you can redistribute it and/or
4 ;;; modify it under the terms of the GNU General Public License as
5 ;;; published by the Free Software Foundation; either version 3 of the
6 ;;; License, or (at your option) any later version.
8 ;;; This program is distributed in the hope that it will be useful,
9 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 ;;; General Public License for more details.
13 ;;; You should have received a copy of the GNU General Public License
14 ;;; along with this program. If not, see
15 ;;; <http://www.gnu.org/licenses/>.
17 (define-module (bandali feeds)
18 #:use-module (haunt builder atom) ; atom-feed
19 #:use-module (haunt builder rss) ; rss-feed
20 #:use-module (haunt post) ; post-*
21 #:use-module (ice-9 match) ; match-lambda
22 #:re-export (atom-feed
24 #:export (atom-feeds-by-tag
27 (define* (atom-feeds-by-tag #:key
29 (filter posts/reverse-chronological)
32 "Return a builder procedure that renders an atom feed for every tag
33 used in a post. All arguments are optional:
35 PREFIX: The directory in which to write the feeds
36 FILTER: The procedure called to manipulate the posts list before rendering
37 MAX-ENTRIES: The maximum number of posts to render in each feed"
39 (let ((tag-groups (posts/group-by-tag posts)))
42 ((atom-feed #:file-name (string-append prefix "/" tag ".atom")
43 #:subtitle (string-append "Tag: " tag)
45 #:max-entries max-entries
46 #:blog-prefix blog-prefix)
50 (define* (rss-feeds-by-tag #:key
52 (filter posts/reverse-chronological)
55 "Return a builder procedure that renders an rss feed for every tag
56 used in a post. All arguments are optional:
58 PREFIX: The directory in which to write the feeds
59 FILTER: The procedure called to manipulate the posts list before rendering
60 MAX-ENTRIES: The maximum number of posts to render in each feed"
62 (let ((tag-groups (posts/group-by-tag posts)))
65 ((rss-feed #:file-name (string-append prefix "/" tag ".rss")
66 #:subtitle (string-append "Tag: " tag)
68 #:max-entries max-entries
69 #:blog-prefix blog-prefix)