alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

genatom.sh (1475B) [raw]


      1 #!/bin/sh
      2 # genatom.sh -- generate atom.xml
      3 set -e
      4 
      5 # All posts are a item (.It) in the list, and linked via .Xr
      6 POSTS=$(sed '/SEE ALSO/q' blog.7 | grep -A1 '\.It' | grep '\.Xr' | sed 's/^\.Xr \([^ ]*\) 7/\1/')
      7 # Assume dates are 1-1
      8 DATES=$(grep -o '[0-9]\{1,2\}/[0-9]\{1,2\}/[0-9]\{4\}' blog.7 \
      9     | sed -e 's#\([0-9]\{2\}\)/\([0-9]\{2\}\)/\([0-9]\{4\}\)#\3-\1-\2#')
     10 
     11 cat <<HEADER
     12 <?xml version="1.0" encoding="utf-8"?>
     13 <feed xmlns="http://www.w3.org/2005/Atom">
     14   <title>Alex Karle's blog(7)</title>
     15   <link rel="alternate" type="text/html" href="https://alexkarle.com/blog.html"/>
     16   <id>https://alexkarle.com/atom.xml</id>
     17   <link rel="self" type="application/atom+xml" href="https://alexkarle.com/atom.xml"/>
     18   <author>
     19     <name>Alex Karle</name>
     20   </author>
     21 HEADER
     22 
     23 set $DATES
     24 printf "  %s\n" "<updated>${1}T00:00:00Z</updated>"
     25 for p in $POSTS; do
     26     d="$1"
     27     shift
     28     cat <<ENTRY
     29   <entry>
     30     <title>$p</title>
     31     <link rel="alternate" type="text/html" href="https://alexkarle.com/$p.html"/>
     32     <id>https://alexkarle.com/$p.html</id>
     33     <updated>${d}T00:00:00Z</updated>
     34     <published>${d}T00:00:00Z</published>
     35     <content type="html">
     36     <![CDATA[
     37 ENTRY
     38     # Print fragment (no need for escapes -- in CDATA
     39     mandoc -Thtml -O'fragment,man=%N.html;https://man.openbsd.org/%N.%S' $p.7 \
     40         | sed '/<td class="head-vol">Miscellaneous Information Manual<\/td>/d'
     41     cat <<EOENTRY
     42     ]]>
     43     </content>
     44   </entry>
     45 EOENTRY
     46 done
     47 printf "</feed>\n"