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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/bin/sh
blogtitle="ben's space"
urlroot="https://bvnf.space/blog"
urlblog="https://bvnf.space/blog/"
# HEADER
cat << EOF
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>$blogtitle</title>
<link>$urlblog</link>
<copyright>CC-BY 4.0</copyright>
<language>en</language>
<lastBuildDate>$(date "+%a, %e %b %Y %H:%M:%S %z")</lastBuildDate>
EOF
ls -r -- *.txt *.gmi *.html | while read -r f; do
unset date title desc link in
# hack for same-day posts
case "$f" in
007*) time="01" ;;
*) time="00" ;;
esac
case "$f" in
index.html) continue ;;
*.txt)
link="$urlroot/$f"
in="${f%.txt}.7"
date="$(grep '^[.]Dd' "$in" | cut -c 5-)"
date="$(date -ju -f "%B %d, %Y" +"%a, %d %b %Y 00:00:${time:-00} %z" "$date")"
title="$(grep '^[.]Nm' "$in" | cut -c 5-)"
desc=" - $(grep '^[.]Nd' "$in" | cut -c 5-)"
;;
*.gmi)
link="gemini://gemini.bvnf.space/blog/${f#[0-9][0-9][0-9]-}"
title="$(sed 1q "$f")"
date="$(date -ju -f "%B %d, %Y" +"%a, %d %b %Y 00:00:${time:-00} %z" "$(sed 1d "$f")")"
;;
*.html)
link="$urlroot/$f"
title="$(sed -n 's/.*<title>\(.*\)<\/title>.*/\1/p' "$f")"
date="$(date -ju +"%a, %d %b %Y 00:00:${time:-00} %z" "$(sed -n 's/^.*written \([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\).*$/\1\2\30000/p' "$f")")"
;;
*) continue ;;
esac
cat <<EOF
<item>
<title>$title</title>
<link>$link</link>
<pubDate>$date</pubDate>
</item>
EOF
done
# FOOTER
cat << EOF
</channel>
</rss>
EOF
|