| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | MYNAME=@PACKAGE_NAME@ |
|---|
| 4 | |
|---|
| 5 | print_usage() |
|---|
| 6 | { |
|---|
| 7 | cat << EOM |
|---|
| 8 | ${MYNAME} convert DocBook XML to html for Vine Linux. |
|---|
| 9 | |
|---|
| 10 | Usage: ${MYNAME} [OPTION]... TARGET |
|---|
| 11 | |
|---|
| 12 | -c, --css=CSSURI change link of cascading style sheet to CSSURI |
|---|
| 13 | -i, --imagedir=IMAGEDIR change directory of common images. |
|---|
| 14 | -w, --web change xsl style sheet for web |
|---|
| 15 | --clean remove html files (ignore TARGET) |
|---|
| 16 | --help display help and exit |
|---|
| 17 | --version output version information and exit |
|---|
| 18 | EOM |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | print_version() |
|---|
| 22 | { |
|---|
| 23 | cat << EOM |
|---|
| 24 | ${MYNAME} 0.9.1 |
|---|
| 25 | |
|---|
| 26 | Copyright (C) 2011 Project Vine. |
|---|
| 27 | This is free software; see the source for copying conditions. There is NO |
|---|
| 28 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 29 | |
|---|
| 30 | Written by Yasumichi Akahoshi <yasumichi@vinelinux.org> |
|---|
| 31 | EOM |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | ORG_CSS=@CSSFILE@ |
|---|
| 35 | ORG_IMGDIR=@IMAGEDIR@ |
|---|
| 36 | TARGET= |
|---|
| 37 | STYLE=@STYLE@ |
|---|
| 38 | OPTIONS="--stringparam chunker.output.indent yes" |
|---|
| 39 | |
|---|
| 40 | # |
|---|
| 41 | # parse arguments. |
|---|
| 42 | # |
|---|
| 43 | if [ -z "$*" ]; then |
|---|
| 44 | print_usage |
|---|
| 45 | exit 1 |
|---|
| 46 | fi |
|---|
| 47 | |
|---|
| 48 | while [ ! -z "$*" ]; do |
|---|
| 49 | case $1 in |
|---|
| 50 | -c|--css) |
|---|
| 51 | NEW_CSS=$2 |
|---|
| 52 | shift |
|---|
| 53 | ;; |
|---|
| 54 | -i|--imagedir) |
|---|
| 55 | NEW_IMGDIR=$2 |
|---|
| 56 | shift |
|---|
| 57 | ;; |
|---|
| 58 | -w|--web) |
|---|
| 59 | STYLE=/usr/share/sgml/docbook/vine-style-xsl/web.xsl |
|---|
| 60 | ;; |
|---|
| 61 | --help) |
|---|
| 62 | print_usage |
|---|
| 63 | exit |
|---|
| 64 | ;; |
|---|
| 65 | --version) |
|---|
| 66 | print_version |
|---|
| 67 | exit |
|---|
| 68 | ;; |
|---|
| 69 | --clean) |
|---|
| 70 | rm *.html |
|---|
| 71 | exit |
|---|
| 72 | ;; |
|---|
| 73 | *) |
|---|
| 74 | if [ -z "${TARGET}" ]; then |
|---|
| 75 | TARGET=$1 |
|---|
| 76 | OPTIONS="${OPTIONS} --stringparam db.chunk.basename `basename $TARGET .xml`" |
|---|
| 77 | else |
|---|
| 78 | echo "Too many targets." >&2 |
|---|
| 79 | echo >&2 |
|---|
| 80 | print_usage |
|---|
| 81 | exit 1 |
|---|
| 82 | fi |
|---|
| 83 | ;; |
|---|
| 84 | esac |
|---|
| 85 | shift |
|---|
| 86 | done |
|---|
| 87 | |
|---|
| 88 | if [ -z $TARGET ]; then |
|---|
| 89 | echo "No target" |
|---|
| 90 | exit 1 |
|---|
| 91 | fi |
|---|
| 92 | |
|---|
| 93 | # |
|---|
| 94 | # convert DocBook XML to html |
|---|
| 95 | # |
|---|
| 96 | xsltproc ${OPTIONS} ${STYLE} ${TARGET} |
|---|
| 97 | |
|---|
| 98 | # |
|---|
| 99 | # replace URI of cascading style sheet |
|---|
| 100 | # |
|---|
| 101 | if [ -n "${NEW_CSS}" ]; then |
|---|
| 102 | sed -i "s|${ORG_CSS}|${NEW_CSS}|" *.html |
|---|
| 103 | fi |
|---|
| 104 | |
|---|
| 105 | # |
|---|
| 106 | # replace directory of common images |
|---|
| 107 | # |
|---|
| 108 | if [ -n "${NEW_IMGDIR}" ]; then |
|---|
| 109 | sed -i "s|${ORG_IMGDIR}|${NEW_IMGDIR}|" *.html |
|---|
| 110 | fi |
|---|
| 111 | |
|---|
| 112 | # vi:syntax=sh |
|---|