gengopher.sh (920B) [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 # Remove/move some non-phlog cruft 17 mv $PHLOG/intro.txt $DEPLOY/intro.txt 18 rm $PHLOG/template.txt 19 20 # Set the mtimes so they show nicely in the directory listing 21 # by parsing the .Dd lines using grep(1) and date(1) 22 # TODO: create a real gophermap for this directory based on blog(7) 23 for f in $PHLOG/*.txt; do 24 grep '\.Dd' $WWW/`basename $f .txt`.7 \ 25 | grep -v Mdocdate \ 26 | sed "s#\.Dd #$f #" 27 done > /tmp/mtimes 28 29 IFS=" " # tab to split file/date for read (see ksh(1)) 30 while read f d; do 31 touch -m -d `date -j -f "%b %d, %Y" "+%Y-%m-%dT%H:%M:%S" "$d"` "$f" 32 done < /tmp/mtimes