forked from a-machine/report-gaffm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start-viewer.bat
50 lines (47 loc) · 1.14 KB
/
start-viewer.bat
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
45
46
47
48
49
50
@echo off
if not "%~1" == "--help" if not "%~1" == "-h" if not "%~1" == "/?" goto START
echo.
echo Usage: %~n0 [^<document URL^> [^<parameter^>=^<value^> ...] ]
echo.
echo Start a local web server and open Vivliostyle Viewer in browser.
echo.
echo Options:
echo.
echo ^<document URL^> URL or a file path relative to the viewer URL.
echo.
echo ^<parameter^>=^<value^> ... option parameters for the viewer.
echo.
echo Example: %~n0 /example/mybook.html bookMode=true renderAllPages=false
echo.
echo -h, --help
echo.
echo See Vivliostyle User Guide for details.
echo.
exit /b 0
:START
setlocal enableDelayedExpansion
set ABS_DIR=%~dp0
set REL_DIR=!ABS_DIR:%CD%\=!
if "%REL_DIR%" == "%ABS_DIR%" (
set ROOT_DIR=%ABS_DIR:~0,3%
set REL_DIR=%REL_DIR:~3%
cd /d !ROOT_DIR!
)
set VIEWER="%REL_DIR%viewer/"
if not "%~1" == "" (
set VIEWER=%VIEWER%"#src=%~1"
)
:LOOP
shift
set PARAM="%~1"
if not %PARAM% == "" (
set VIEWER=%VIEWER%"&"%PARAM%
echo %PARAM% | findstr "=" || (
set VIEWER=!VIEWER!"=%~2"
shift
)
goto LOOP
)
set VIEWER=%VIEWER:""=%
set VIEWER=%VIEWER:\=/%
call "%REL_DIR%start-webserver" %VIEWER% 8000