4 [blog.gemtext :as gemtext]))
6 (defn feed-page [posts]
10 [:quote "Writing about things, sometimes"]
13 (let [{:keys [title date slug]} post
14 url (str "gemini://gemini.omarpolo.com/post/" slug ".gmi")]
15 [:link url (str (time/fmt-iso8601 date) " - " title)])))))
17 (defn with-page [_ & body]
24 [:text "-- text: CC-BY-SA-4.0; code: public domain unless specified otherwise"]
25 [:text "For comments, write at < blog at omarpolo dot com > or @op@bsd.network in the fediverse."]
26 [:link "//git.omarpolo.com/blog/" "Capsule proudly assembled with Clojure"])))
28 (defn with-default-template [_ & body]
31 [:quote "Writing about things, sometimes"]
34 [:link "/tags.gmi" "All Tags"]
35 [:link "/pages/projects.gmi" "Projects"]
40 [{:keys [full? title-with-link?]}
41 {:keys [title date slug tags short body toot music xkcd] :as post}]
44 [:link (str "/post/" slug ".gmi") (str (time/fmt-iso8601 date) " - " title)]
45 [(if full? :header-1 :header-2) title])
50 [:text (str "Written while listening to “" (:title music) "”"
51 (when-let [by (:by music)]
55 [:text (str "Published: " (time/fmt-iso8601 date))])
56 [:text "Tagged with:"]
57 (map #(vector :link (str "/tag/" (name %) ".gmi") (str "#" (name %)))
60 [:link (str "https://xkcd.com/" xkcd) (format "Relevant XKCD – #%d" xkcd)])
63 (gemtext/parse body)))
66 (defn home-page [{:keys [posts has-next has-prev nth]}]
67 (with-default-template
69 [:text "Welcome to my gemlog! Sometimes I remember that I have a blog and post something here. My main interests are computer science, operating systems (BSDs in particular), programming languages (especially C, Go, LISP in its various incarnations). I also have an Italian capsule where I write about more casual stuff:"]
70 [:link "gemini://it.omarpolo.com" "l'angolo di yumh"]
72 [:text "Some Gemini services on this capsule:"]
73 [:link "/cgi/man" "Look up a manpage"]
74 [:link "/cgi/gempkg" "Browse the OpenBSD ports tree"]
76 [:header-2 "Recent posts"]
78 (map (partial post-fragment {:title-with-link? true})
88 [:link (str "/" (inc nth) ".gmi")
91 (defn custom-page [{:keys [body]}]
92 (apply with-default-template (gemtext/parse body)))
94 (defn post-page [{:keys [title short] :as post}]
96 [:link ".." "↩ back to the index"]
98 (post-fragment {:full? true}
101 (defn tags-page [tags]
102 (with-default-template
103 [:header-2 "All tags"]
105 (map #(vector :link (str "/tag/" (name %) ".gmi") (str "#" (name %)))
107 (compare (.toLowerCase (name a))
108 (.toLowerCase (name b)))) tags))))
110 (defn tag-page [tag posts]
111 (with-default-template
112 [:header-2 (format "Posts tagged with #%s" tag)]
114 [:text "Note: not every post is currently available over Gemini."]
116 (map (partial post-fragment {:title-with-link? true})