blob: 6a8072e95fbdfa7c011977a692a7fd308476ae3a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
(ns rss
(:require [clojure.data.xml :as xml])
(:import [java.time ZonedDateTime ZoneId]
[java.time.format DateTimeFormatter]))
(def title "Jake's Blog")
(defn fmt [year month day zone]
(.format (ZonedDateTime/of year month day 0 0 0 0 (ZoneId/of zone)) (DateTimeFormatter/ISO_OFFSET_DATE_TIME)))
(defn entries []
(sorted-map
[2025 10 8 "America/New_York"]
{:title "Quotes from The Second Sex"
:path "second-sex-quotes"
:summary "My favorite quotes from Simone de Beauvior's \"The Second Sex\""}))
(defn feed []
(xml/element
:feed {:xmlns "http://www.w3.org/2005/Atom"}
(xml/element :id {} "https://www.jakezerrer.com/feed.atom")
(xml/element :title {} title)
;; TODO: Updated
(xml/element :updated {} (apply fmt (first (last (entries)))))
(xml/element
:author
{}
(xml/element :name {} "Jake Zerrer"))
(xml/element :link {:rel "self" :href "https://www.jakezerrer.com/feed.atom"})
(for [[updated {:keys [title path summary]}] (entries)]
(let [[year month day zone] updated]
(xml/element
:entry
{}
(xml/element :id {} (str "https://www.jakezerrer.com/" path))
(xml/element :title {} title)
(xml/element :updated {} (fmt year month day zone))
(xml/element :link {:rel "alternate" :href (str "https://www.jakezerrer.com/" path)})
(xml/element :summary {} summary))))))
(defn emit []
(xml/emit-str (feed)))
(comment
(emit))
|