~akarle/alexkarle.com

ref: 5c1fd5edca840e3ec2f8a80b8fed763d30cfa11a alexkarle.com/bin/genatom.sh -rwxr-xr-x 1.6 KiB
5c1fd5edAlex Karle blog: Change listing format to -tag list (grid) 3 months ago
                                                                                
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
#!/bin/sh
# genatom.sh -- generate atom.xml
set -e

REPO=$(dirname "$(dirname "$0")")

# Find fixlinks in either bin or the out-of-tree obj build
PATH="$REPO/bin:$REPO/obj/bin:$PATH"

# All posts are a item (.It) in the list, and linked via .Xr
POSTS=$(sed '/SEE ALSO/q' "$REPO/blog.7" | grep -A1 '\.It' | grep '\.Xr' | sed 's/^\.Xr \([^ ]*\) 7/\1/')

cat <<HEADER
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Alex Karle's blog(7)</title>
  <link rel="alternate" type="text/html" href="https://alexkarle.com/blog.html"/>
  <id>https://alexkarle.com/atom.xml</id>
  <link rel="self" type="application/atom+xml" href="https://alexkarle.com/atom.xml"/>
  <author>
    <name>Alex Karle</name>
  </author>
HEADER

for p in $POSTS; do
    d=$(date -juf"%b %d, %Y" +%F "$(grep '^\.Dd' "$REPO/$p.7"  | cut -d' ' -f2-)")
    if [ -z "$printed_update" ]; then
        printed_update=1
        printf "  %s\n" "<updated>${d}T00:00:00Z</updated>"
    fi
    cat <<ENTRY
  <entry>
    <title>$p</title>
    <link rel="alternate" type="text/html" href="https://alexkarle.com/$p.html"/>
    <id>https://alexkarle.com/$p.html</id>
    <updated>${d}T00:00:00Z</updated>
    <published>${d}T00:00:00Z</published>
    <content type="html">
    <![CDATA[
ENTRY
    # Print fragment (no need for escapes -- in CDATA
    mandoc -Thtml -O'fragment,man=%N.html;https://man.openbsd.org/%N.%S' "$REPO/$p.7" \
        | sed '/<td class="head-vol">Miscellaneous Information Manual<\/td>/d' \
        | fixlinks
    cat <<EOENTRY
    ]]>
    </content>
  </entry>
EOENTRY
done
printf "</feed>\n"