[project @ 2000-05-12 12:56:45 by rrt]
[ghc-hetmet.git] / glafp-utils / docbook / db2html
1 #! /bin/sh
2
3 DB_STYLESHEET=$SGML_TOP/stylesheets/cygnus-both.dsl
4 HTML_STYLESHEET=$SGML_TOP/stylesheets/nwalsh-modular/test/docbook.css
5 ADMON_GRAPHICS=$SGML_TOP/stylesheets/nwalsh-modular/images/*.gif
6
7 output=db2html-dir
8 TMPDIR=DBTOHTML_OUTPUT_DIR$$
9
10 echo TMPDIR is $TMPDIR
11
12 # Dave Mason's option to specify a different stylesheet
13 case $1 in
14     -d) DB_STYLESHEET=$2
15         shift 2
16         ;;
17 esac
18
19 echo "Using stylesheet: \"${DB_STYLESHEET}\""
20
21 if [ $# -gt 2 ]
22 then
23   echo "Usage: `basename $0` [filename.sgml]" >&2
24   exit 1
25 fi
26
27 if [ $# -eq 1 ]
28 then
29   if [ ! -r $1 ]
30   then
31     echo Cannot read \"$1\".  Exiting. >&2
32     exit 1
33   fi
34   if echo $1 | egrep -i '\.sgml$|\.sgm$' >/dev/null 2>&1
35   then
36     # now make sure that the output directory is always a subdirectory
37     # of hte current directory
38     echo
39     input_file=`basename $1`
40     output="`echo $input_file | sed 's,\.sgml$,,;s,\.sgm$,,'`"
41     echo "input file was called $input_file -- output will be in $output"
42     echo
43   fi
44 fi
45
46 # we used to generate a single file, but with the modular DB_STYLESHEETs
47 # it's best to make a new directory with several html files in it
48 #cat $* | jade -d $DB_STYLESHEET -t sgml -V nochunks > $TMPFN
49
50 mkdir $TMPDIR
51 SAVE_PWD=`pwd`
52 if [ $1 = `basename $1` ]; then
53   echo "working on ../$1"
54   (cd $TMPDIR; jade -t sgml -ihtml -d ${DB_STYLESHEET}\#html ../$1; cd $SAVE_PWD)
55 else
56   echo "working on $1"
57   (cd $TMPDIR; jade -t sgml -ihtml -d ${DB_STYLESHEET}\#html $1; cd $SAVE_PWD)
58 fi
59
60 if [ $# -eq 1 ]
61 then
62   if [ -d ${output}.junk ]
63   then
64     /bin/rm -rf ${output}.junk
65   fi
66   if [ -d ${output} ]
67   then
68     mv $output ${output}.junk
69   fi
70   echo "about to copy cascading stylesheet and admon graphics to temp dir"
71   cp ${HTML_STYLESHEET} ${TMPDIR}/
72   mkdir ${TMPDIR}/stylesheet-images
73   cp ${ADMON_GRAPHICS} ${TMPDIR}/stylesheet-images
74   echo "about to rename temporary directory to $output"
75   mv ${TMPDIR} $output
76 else
77   cat $TMPDIR/*
78 fi
79
80 rm -rf $TMPDIR
81
82 exit 0