source: projects/vine-manual-build/trunk/vine-manual-build.in @ 4209

Revision 4209, 1.9 KB checked in by yasumichi, 13 years ago (diff)

・-i,-cオプションで共通画像用ディレクトリの位置、CSSファイルの位置を変更できるようにした。
・-wオプションで web.xsl を使うようにした。
・--help,--version オプションの追加

Line 
1#!/bin/bash
2
3MYNAME=@PACKAGE_NAME@
4
5print_usage()
6{
7cat << EOM
8${MYNAME} convert DocBook XML to html for Vine Linux.
9
10Usage: ${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
18EOM
19}
20
21print_version()
22{
23cat << EOM
24${MYNAME} 0.9.1
25
26Copyright (C) 2011 Project Vine.
27This is free software; see the source for copying conditions.  There is NO
28warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
29
30Written by Yasumichi Akahoshi <yasumichi@vinelinux.org>
31EOM
32}
33
34ORG_CSS=@CSSFILE@
35ORG_IMGDIR=@IMAGEDIR@
36TARGET=
37STYLE=@STYLE@
38OPTIONS="--stringparam chunker.output.indent yes"
39
40#
41# parse arguments.
42#
43if [ -z "$*" ]; then
44        print_usage
45        exit 1
46fi
47
48while [ ! -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
86done
87
88if [ -z $TARGET ]; then
89        echo "No target"
90        exit 1
91fi
92
93#
94# convert DocBook XML to html
95#
96xsltproc ${OPTIONS} ${STYLE} ${TARGET}
97
98#
99# replace URI of cascading style sheet
100#
101if [ -n "${NEW_CSS}" ]; then
102        sed -i "s|${ORG_CSS}|${NEW_CSS}|" *.html
103fi
104
105#
106# replace directory of common images
107#
108if [ -n "${NEW_IMGDIR}" ]; then
109        sed -i "s|${ORG_IMGDIR}|${NEW_IMGDIR}|" *.html
110fi
111
112# vi:syntax=sh
Note: See TracBrowser for help on using the repository browser.