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