gengopher.sh (982B) [raw]
1 #!/bin/sh 2 # generates my gopherhole based on the checkout of the files 3 # in the html area 4 set -e 5 6 WWW=/var/www/htdocs/akcom 7 DEPLOY=/var/gopher 8 PHLOG=$DEPLOY/phlog 9 10 # First generate the content 11 for f in $WWW/*.7; do 12 # col -b to strip backspace underlines, see mandoc(1) 13 mandoc -Tascii -Owidth=72 $f | col -b > $PHLOG/`basename $f .7`.txt 14 done 15 16 # Copy over jam-tuesday 17 cp -a "$WWW/jam-tuesday" "$PHLOG" 18 19 # Remove/move some non-phlog cruft 20 mv $PHLOG/intro.txt $DEPLOY/intro.txt 21 rm -f $PHLOG/template.txt 22 23 # Set the mtimes so they show nicely in the directory listing 24 # by parsing the .Dd lines using grep(1) and date(1) 25 # TODO: create a real gophermap for this directory based on blog(7) 26 for f in $PHLOG/*.txt; do 27 grep '\.Dd' $WWW/`basename $f .txt`.7 \ 28 | grep -v Mdocdate \ 29 | sed "s#\.Dd #$f #" 30 done > /tmp/mtimes 31 32 IFS=" " # tab to split file/date for read (see ksh(1)) 33 while read f d; do 34 touch -m -d `date -j -f "%b %d, %Y" "+%Y-%m-%dT%H:%M:%S" "$d"` "$f" 35 done < /tmp/mtimes