forked from a-machine/manual-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart-viewer
44 lines (33 loc) · 982 Bytes
/
start-viewer
1
2
3
4
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
#!/bin/sh
if [ "$1" = "--help" -o "$1" = "-h" ]; then
echo "
Usage: $(basename "$0") [<document URL> [<parameter>=<value> ...] ]
Start a local web server and open Vivliostyle Viewer in browser.
Options:
<document URL> URL or a file path relative to the viewer URL.
<parameter>=<value> ... option parameters for the viewer.
Example: $(basename "$0") /example/mybook.html bookMode=true renderAllPages=false
-h, --help
See Vivliostyle User Guide for details.
"
exit 0
fi
ABS_DIR=$(cd "$(dirname "$0")"; pwd)
REL_DIR=.
if [ "$ABS_DIR" != "$PWD" ]; then
REL_DIR=${ABS_DIR#$PWD/}
fi
if [ "$REL_DIR" = "$ABS_DIR" ]; then
ROOT_DIR=/
if [ "$(uname -o 2>/dev/null)" = 'Msys' -a "${ABS_DIR:2:1}" = "/" ]; then
ROOT_DIR=${ABS_DIR:0:3}
fi
REL_DIR=${REL_DIR#$ROOT_DIR}
cd $ROOT_DIR
fi
VIEWER=$REL_DIR/viewer/
if [ $# -ne 0 ]; then
VIEWER=$VIEWER#src="$(IFS="&"; echo "$*")"
fi
VIEWER=${VIEWER// /%20}
"$ABS_DIR/start-webserver" "$VIEWER" 8000