db2html.sh 1.94 KB
Newer Older
rrt's avatar
rrt committed
1
if [ ! -f "$DOCBOOK_CATALOG" ] ; then
2
3
  echo "CATALOG file not set up; see installation guide for details."
  exit 1
rrt's avatar
rrt committed
4
fi
rrt's avatar
rrt committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

HTML_STYLESHEET=$HTML_DIR/html/docbook.css
ADMON_GRAPHICS=$HTML_DIR/html/images/*.gif

output=db2html-dir
TMPDIR=DBTOHTML_OUTPUT_DIR$$

echo TMPDIR is $TMPDIR

# Dave Mason's option to specify a different stylesheet
case $1 in
    -d) DB_STYLESHEET=$2
        shift 2
	;;
esac

echo "Using stylesheet: \"${DB_STYLESHEET}\""

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

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
    # now make sure that the output directory is always a subdirectory
    # of hte current directory
    echo
    input_file=`basename $1`
    output="`echo $input_file | sed 's,\.sgml$,,;s,\.sgm$,,'`"
    echo "input file was called $input_file -- output will be in $output"
    echo
  fi
fi

# we used to generate a single file, but with the modular DB_STYLESHEETs
# it's best to make a new directory with several html files in it
#cat $* | jade -d $DB_STYLESHEET -t sgml -V nochunks > $TMPFN

mkdir $TMPDIR
SAVE_PWD=`pwd`
if [ $1 = `basename $1` ]; then
  echo "working on ../$1"
rrt's avatar
rrt committed
56
  (cd $TMPDIR; $JADE -t sgml -ihtml -d ${DB_STYLESHEET}\#html -c $DOCBOOK_CATALOG ../$1; cd $SAVE_PWD)
rrt's avatar
rrt committed
57
58
else
  echo "working on $1"
rrt's avatar
rrt committed
59
  (cd $TMPDIR; $JADE -t sgml -ihtml -d ${DB_STYLESHEET}\#html -c $DOCBOOK_CATALOG $1; cd $SAVE_PWD)
rrt's avatar
rrt committed
60
61
62
63
64
65
fi

if [ $# -eq 1 ]
then
  if [ -d ${output}.junk ]
  then
rrt's avatar
rrt committed
66
    rm -rf ${output}.junk
rrt's avatar
rrt committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  fi
  if [ -d ${output} ]
  then
    mv $output ${output}.junk
  fi
  echo "about to copy cascading stylesheet and admon graphics to temp dir"
  cp ${HTML_STYLESHEET} ${TMPDIR}/
  mkdir ${TMPDIR}/stylesheet-images
  cp ${ADMON_GRAPHICS} ${TMPDIR}/stylesheet-images
  echo "about to rename temporary directory to $output"
  mv ${TMPDIR} $output
else
  cat $TMPDIR/*
fi

rm -rf $TMPDIR

exit 0