#! /bin/sh
DB_STYLESHEET=/home/dcm/dsssl/gdp-both.dsl
HTML_STYLESHEET=/usr/lib/sgml/stylesheets/nwalsh-modular/test/docbook.css
ADMON_GRAPHICS=/usr/lib/sgml/stylesheets/nwalsh-modular/images/*.gif

case $1 in
    -d) DB_STYLESHEET=$2
        shift 2 
    ;;
esac

if [ $# -gt 2 ]
then
  echo "Usage: `basename $0` [filename.sgml]" >&2
  exit 1
fi

output="`echo $1 | sed 's,\.sgml$,.html,;s,\.sgm$,.html,'`"

echo "working on ../$1"

(jade -t sgml -ihtml -d ${DB_STYLESHEET}\#html -V nochunks ./$1 > $output)

echo "about to copy cascading stylesheet and admon graphics to temp dir"
cp ${HTML_STYLESHEET} ./
mkdir ./stylesheet-images
cp ${ADMON_GRAPHICS} ./stylesheet-images
echo "ouput will be $output"

exit 0

if [ $# -eq 1 ]
then
  if [ ! -r $1 ]
  then
    echo Cannot read \"$1\".  Exiting. >&2
    exit 1
  fi
  if echo $1 | egrep -i '\.sgml$|\.sgm$' >/dev/null 2>&1
  then
    output="`echo $1 | sed 's,\.sgml$,.html,;s,\.sgm$,.html,'`"
    # if we have a filename argument let us improve the
    # temporary filename, sine gv and ghostview will display it.
    # this TMPFN has $1 embedded in it
    TMPFN=`echo $1 | sed 's/\.sgml//'`_dbnochunkstmp$$
  fi
fi

if [ $1 = `basename $1` ]; then
  echo "working on ../$1"
  (jade -t sgml -ihtml -d ${DB_STYLESHEET}\#html -V nochunks ./$1 > $output)
else
  echo "working on $1"
  (jade -t sgml -ihtml -d ${DB_STYLESHEET}\#html -V nochunks $1 > $output)
fi

if [ -f ${TMPFN}.ps ]
then
  if [ $# -eq 1 ]
  then
    if [ -n "$output" ]
    then
      mv ${TMPFN}.html $output
    else
      mv ${TMPFN}.html dbnochunks.html
    fi
  else
    cat ${TMPFN}.html
  fi
fi

echo "about to copy cascading stylesheet and admon graphics to temp dir"
cp ${HTML_STYLESHEET} ./
mkdir ./stylesheet-images
cp ${ADMON_GRAPHICS} ./stylesheet-images
echo "ouput will be $output"

rm -f ${TMPFN}*

exit 0
