diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2015-11-27 14:18:10 +0100 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2015-11-27 14:18:10 +0100 |
commit | fa6c3fa34d76707b5c80726674978b2d8a2c78b6 (patch) | |
tree | 435716e7d1aa191e0ccd041d021a01e026b86940 /tools | |
parent | ec5c8c182c3b46e748ca7fbe59e747c90d2ca04d (diff) | |
download | sbotools-fa6c3fa34d76707b5c80726674978b2d8a2c78b6.tar.xz |
Changed the way html generation of manpages is done
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/htmlgen.sh | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/tools/htmlgen.sh b/tools/htmlgen.sh index 70a8b88..fd4b101 100755 --- a/tools/htmlgen.sh +++ b/tools/htmlgen.sh @@ -1,21 +1,19 @@ #!/usr/bin/env bash -if [[ "$1" == "" || "$2" == "" ]]; then - echo "usage: $(basename $0) package version" +if [[ "$1" == "" ]]; then + echo "usage: $(basename $0) destdir" exit 1 fi -PACKAGE=$1 -VERSION=$2 +DESTDIR=$1 +PACKAGE="sbotools" +VERSION=$(grep '^our $VERSION' SBO-Lib/lib/SBO/Lib.pm | grep -Eo '[0-9]+(\.[0-9]+){0,1}') -if [[ ! -d $HOME/$PACKAGE-$VERSION ]]; then - echo "I do not see the $PACKAGE-$VERSION directory." - exit 1 -fi -SBO_DIR="$HOME/$PACKAGE-$VERSION" -HTML_DIR="$HOME/html_man/$PACKAGE-$VERSION" -mkdir -p $HTML_DIR +SBO_DIR=`pwd` +TMP_DIR=$(mktemp -d "/tmp/$PACKAGE.XXXXXXXXXX") +HTML_DIR="$TMP_DIR/html" +mkdir -p $DESTDIR $HTML_DIR for i in $(ls $SBO_DIR | grep '^man'); do mkdir -p $HTML_DIR/$i @@ -28,22 +26,44 @@ for i in $(ls $SBO_DIR | grep '^man'); do ( cd $HTML_DIR/$i sed -i 's/^Content-type.*$//g' * sed -i 's/^<A HREF.*Return to Main.*$//g' * - sed -i -r "s#http://localhost/cgi-bin/man/man2html\?([0-9])\+([^\"]+)#/$PACKAGE/documentation/\2\1#g" * + sed -i -r "s#http://localhost/cgi-bin/man/man2html\?([0-9])\+([^\"]+)#/$PACKAGE/documentation/\2.\1.html#g" * sed -i 's/j@dawnrazor.net/j_[at]_dawnrazor_[dot]_net/g' * sed -i 's/xocel@iquidus.org/xocel_[at]_iquidus_[dot]_org/g' * + sed -i 's/andreas.guldstrand@gmail.com/andreas_[dot]_guldstrand_[at]_gmail_[dot]_com/g' * sed -i 's/<A HREF="mailto:xocel_\[at\]_iquidus_\[dot\]_org">//g' * + sed -i 's/<A HREF="mailto:andreas_\[dot\]_guldstrand_\[at\]_gmail_\[dot\]_com">//g' * sed -i 's#\[dot\]_org</A>#[dot]_org#g' * + sed -i 's#\[dot\]_com</A>#[dot]_com#g' * sed -i 's#<A HREF="http://localhost/cgi-bin/man/man2html">man2html</A>#man2html#g' * sed -i 's/^$//g' * sed -i 's/^<HTML><HEAD>.*$//g' * sed -i 's#^</HEAD><BODY>$##g' * + sed -i 's#</BODY>##g' * + sed -i 's#</HTML>##g' * for k in $(ls); do mv $k $k.tmp cat $k.tmp | awk "\$0 !~ /^$/ { print > \"$k\"; }" rm $k.tmp + mv $k .. done ) + rmdir $HTML_DIR/$i done +template() { + SRC=$1 + TEMPLATE="$DESTDIR/template.html" + NAME=${SRC//.?.html/} + echo "Writing $DESTDIR/$SRC ($NAME)" + perl -0777 -pE 's/\@TITLE\@/'$NAME'/g; s/\@MAN\@/<>/e' $TEMPLATE $SRC > $DESTDIR/$SRC +} + +(cd $HTML_DIR + for src in $(ls) + do + template $src + done +) + echo "All done." exit 0; |