From 4d70994cc2ec8f5d731055182f315d52377d1af3 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 25 Apr 2021 12:26:43 -0400 Subject: [PATCH] cleanup: Move gen* scripts to bin/ Now that I've introduced src/kiosk.c (our first directory!), it feels natural to move scripts to bin/ (especially as I look to add more...) --- .gitignore | 6 +++--- Makefile | 5 ++--- bin/genatom.sh | 47 +++++++++++++++++++++++++++++++++++++++++++++++ bin/gengopher.sh | 32 ++++++++++++++++++++++++++++++++ genatom.sh | 47 ----------------------------------------------- gengopher.sh | 32 -------------------------------- use-feeds.7 | 2 +- 7 files changed, 85 insertions(+), 86 deletions(-) create mode 100755 bin/genatom.sh create mode 100755 bin/gengopher.sh delete mode 100755 genatom.sh delete mode 100755 gengopher.sh diff --git a/.gitignore b/.gitignore index ef6650f..859c651 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ # generated html from man pages *.html -# atom feed is generated by ./genatom.sh +# atom feed is generated by ./bin/genatom.sh atom.xml # jam-tuesday hits generated by jam-tuesday/stats.sh jam-tuesday/greatest-hits -# binaries -bin/ +# kiosk binary +bin/kiosk diff --git a/Makefile b/Makefile index 331d736..fb88819 100644 --- a/Makefile +++ b/Makefile @@ -22,14 +22,13 @@ clean: index.html: ln -sf intro.html $@ -atom.xml: blog.7 genatom.sh - ./genatom.sh > $@ +atom.xml: blog.7 bin/genatom.sh + ./bin/genatom.sh > $@ jam-tuesday/greatest-hits: $(SETS) jam-tuesday/stats.sh (date; echo; ./jam-tuesday/stats.sh) > $@ bin/kiosk: src/kiosk.c - mkdir -p bin $(CC) $(CFLAGS) -DMANDIR="\"`pwd`\"" src/kiosk.c -o $@ $(HTML): Makefile diff --git a/bin/genatom.sh b/bin/genatom.sh new file mode 100755 index 0000000..56a22ac --- /dev/null +++ b/bin/genatom.sh @@ -0,0 +1,47 @@ +#!/bin/sh +# genatom.sh -- generate atom.xml +set -e + +# All posts are a item (.It) in the list, and linked via .Xr +POSTS=$(sed '/SEE ALSO/q' blog.7 | grep -A1 '\.It' | grep '\.Xr' | sed 's/^\.Xr \([^ ]*\) 7/\1/') +# Assume dates are 1-1 +DATES=$(grep -o '[0-9]\{1,2\}/[0-9]\{1,2\}/[0-9]\{4\}' blog.7 \ + | sed -e 's#\([0-9]\{2\}\)/\([0-9]\{2\}\)/\([0-9]\{4\}\)#\3-\1-\2#') + +cat <
+ + Alex Karle's blog(7) + + https://alexkarle.com/atom.xml + + + Alex Karle + +HEADER + +set $DATES +printf " %s\n" "${1}T00:00:00Z" +for p in $POSTS; do + d="$1" + shift + cat < + $p + + https://alexkarle.com/$p.html + ${d}T00:00:00Z + ${d}T00:00:00Z + + Miscellaneous Information Manual<\/td>/d' + cat < + + +EOENTRY +done +printf "\n" diff --git a/bin/gengopher.sh b/bin/gengopher.sh new file mode 100755 index 0000000..5b7726a --- /dev/null +++ b/bin/gengopher.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# generates my gopherhole based on the checkout of the files +# in the html area +set -e + +WWW=/var/www/htdocs/akcom +DEPLOY=/var/gopher +PHLOG=$DEPLOY/phlog + +# First generate the content +for f in $WWW/*.7; do + # col -b to strip backspace underlines, see mandoc(1) + mandoc -Tascii -Owidth=72 $f | col -b > $PHLOG/`basename $f .7`.txt +done + +# Remove/move some non-phlog cruft +mv $PHLOG/intro.txt $DEPLOY/intro.txt +rm $PHLOG/template.txt + +# Set the mtimes so they show nicely in the directory listing +# by parsing the .Dd lines using grep(1) and date(1) +# TODO: create a real gophermap for this directory based on blog(7) +for f in $PHLOG/*.txt; do + grep '\.Dd' $WWW/`basename $f .txt`.7 \ + | grep -v Mdocdate \ + | sed "s#\.Dd #$f #" +done > /tmp/mtimes + +IFS=" " # tab to split file/date for read (see ksh(1)) +while read f d; do + touch -m -d `date -j -f "%b %d, %Y" "+%Y-%m-%dT%H:%M:%S" "$d"` "$f" +done < /tmp/mtimes diff --git a/genatom.sh b/genatom.sh deleted file mode 100755 index 56a22ac..0000000 --- a/genatom.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -# genatom.sh -- generate atom.xml -set -e - -# All posts are a item (.It) in the list, and linked via .Xr -POSTS=$(sed '/SEE ALSO/q' blog.7 | grep -A1 '\.It' | grep '\.Xr' | sed 's/^\.Xr \([^ ]*\) 7/\1/') -# Assume dates are 1-1 -DATES=$(grep -o '[0-9]\{1,2\}/[0-9]\{1,2\}/[0-9]\{4\}' blog.7 \ - | sed -e 's#\([0-9]\{2\}\)/\([0-9]\{2\}\)/\([0-9]\{4\}\)#\3-\1-\2#') - -cat <
- - Alex Karle's blog(7) - - https://alexkarle.com/atom.xml - - - Alex Karle - -HEADER - -set $DATES -printf " %s\n" "${1}T00:00:00Z" -for p in $POSTS; do - d="$1" - shift - cat < - $p - - https://alexkarle.com/$p.html - ${d}T00:00:00Z - ${d}T00:00:00Z - - Miscellaneous Information Manual<\/td>/d' - cat < - - -EOENTRY -done -printf "\n" diff --git a/gengopher.sh b/gengopher.sh deleted file mode 100755 index 5b7726a..0000000 --- a/gengopher.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# generates my gopherhole based on the checkout of the files -# in the html area -set -e - -WWW=/var/www/htdocs/akcom -DEPLOY=/var/gopher -PHLOG=$DEPLOY/phlog - -# First generate the content -for f in $WWW/*.7; do - # col -b to strip backspace underlines, see mandoc(1) - mandoc -Tascii -Owidth=72 $f | col -b > $PHLOG/`basename $f .7`.txt -done - -# Remove/move some non-phlog cruft -mv $PHLOG/intro.txt $DEPLOY/intro.txt -rm $PHLOG/template.txt - -# Set the mtimes so they show nicely in the directory listing -# by parsing the .Dd lines using grep(1) and date(1) -# TODO: create a real gophermap for this directory based on blog(7) -for f in $PHLOG/*.txt; do - grep '\.Dd' $WWW/`basename $f .txt`.7 \ - | grep -v Mdocdate \ - | sed "s#\.Dd #$f #" -done > /tmp/mtimes - -IFS=" " # tab to split file/date for read (see ksh(1)) -while read f d; do - touch -m -d `date -j -f "%b %d, %Y" "+%Y-%m-%dT%H:%M:%S" "$d"` "$f" -done < /tmp/mtimes diff --git a/use-feeds.7 b/use-feeds.7 index fa3683d..4b70bf4 100644 --- a/use-feeds.7 +++ b/use-feeds.7 @@ -88,7 +88,7 @@ What I can say is that after the initial confusion of how to escape the embedded HTML in the XML feed, it was pretty smooth sailing. .Pp The full implementation is in -.Lk https://alexkarle.com/git/alexkarle.com/file/genatom.sh.html genatom.sh +.Lk https://alexkarle.com/git/alexkarle.com/file/bin/genatom.sh.html genatom.sh and basically boils down to: .Bl -enum -compact .It -- libgit2 1.1.1