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