Blame


1 a803b55b 2020-03-30 op (ns blog.rss
2 b75f3ee4 2020-10-03 op (:require
3 b75f3ee4 2020-10-03 op [blog.gemtext :as gemtext]
4 b75f3ee4 2020-10-03 op [blog.time :as time]
5 b75f3ee4 2020-10-03 op [clojure.data.xml :refer :all]
6 b75f3ee4 2020-10-03 op [commonmark-hiccup.core :refer [markdown->hiccup default-config]]
7 b75f3ee4 2020-10-03 op [hiccup.core :as hiccup]))
8 a803b55b 2020-03-30 op
9 bade790b 2020-11-05 op (defn item [linkfn {:keys [title date slug tags short body gemtext?]}]
10 bade790b 2020-11-05 op (let [link (linkfn slug)]
11 a803b55b 2020-03-30 op [:item
12 a803b55b 2020-03-30 op [:title title]
13 bade790b 2020-11-05 op (when body
14 bade790b 2020-11-05 op [:description
15 bade790b 2020-11-05 op [:-cdata
16 bade790b 2020-11-05 op (hiccup/html
17 bade790b 2020-11-05 op (if gemtext?
18 bade790b 2020-11-05 op (-> body gemtext/parse gemtext/to-hiccup)
19 bade790b 2020-11-05 op (markdown->hiccup default-config body)))]])
20 a803b55b 2020-03-30 op [:guid link]
21 a803b55b 2020-03-30 op [:link link]
22 a803b55b 2020-03-30 op [:pubDate (time/fmt-rfc-2822 date)]]))
23 a803b55b 2020-03-30 op
24 bade790b 2020-11-05 op (defn feed [linkfn posts]
25 a803b55b 2020-03-30 op (indent-str
26 a803b55b 2020-03-30 op (sexp-as-element
27 a803b55b 2020-03-30 op [:rss {:version "2.0" :xmlns:atom "http://www.w3.org/2005/Atom"}
28 a803b55b 2020-03-30 op [:channel
29 a803b55b 2020-03-30 op [:title "yumh"]
30 a803b55b 2020-03-30 op [:description "Writing about things, sometimes"]
31 a803b55b 2020-03-30 op [:link "https://www.omarpolo.com"]
32 a803b55b 2020-03-30 op ;; fails to validate?
33 a803b55b 2020-03-30 op ;; [:atom:link {:href "https://www.omarpolo.com/rss.xml" :ref "self" :type "application/rss+xml"} nil]
34 bade790b 2020-11-05 op (map (partial item linkfn)
35 bade790b 2020-11-05 op posts)]])))