43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
-
-
+
+
-
+
-
+
-
+
-
+
-
+
|
(date->string now #t)))
(string-append timestamp "Z"))
;; Get the data out of the SQLite cache as vectors
(define (fetch-rows)
(define fields '(pagenode title_plain published updated author doc_html))
(define select #<<---
SELECT `path`, `title`, `published`, `updated`, `author`, `entry-contents` FROM
(SELECT `pagenode` AS `path`,
SELECT `path`, `title`, `published`, `updated`, `author`, `entry_contents` FROM
(SELECT `page` AS `path`,
`title_plain` AS `title`,
`published`,
`updated`,
`author`,
`doc_html` AS `entry-contents`
`doc_html` AS `entry_contents`
FROM `articles`
UNION
SELECT `pagenode` || '#' || `note_id` AS `path`,
SELECT `page` || '#' || `html_anchor` AS `path`,
`title_plain` AS `title`,
`date` AS `published`,
`published`,
"" AS `updated`,
`author`,
`content_html` as `entry-contents`
`content_html` as `entry_contents`
FROM `notes`)
ORDER BY `published` DESC LIMIT ~a
---
)
(query-rows (sqltools:dbc) (format select feed-item-limit)))
(query-rows cache-conn (format select feed-item-limit)))
(define (vector->rss-item vec)
(match-define
(vector path title published updated author contents) vec)
(define entry-url (string-append feed-site-url web-root path))
(define update-ts
(cond [(non-empty-string? updated) updated]
|
97
98
99
100
101
102
103
104
105
|
97
98
99
100
101
102
103
104
|
-
|
(name ,feed-author)
(email ,@(email-encode feed-author-email)))
,@(map vector->rss-item (fetch-rows))))
(string-append "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
(xexpr->string feed-xpr)))
(define (main)
(spell-of-summoning!) ; Turn on the cache DB connection
(display-to-file (rss-feed) "feed.xml" #:mode 'text #:exists 'replace))
|