xref: /freebsd/contrib/libxo/xohtml/xohtml.sh.in (revision 7ef62cebc2f965b0f640263e179276928885e33d)
1#!/bin/sh
2#
3# Copyright (c) 2014, Juniper Networks, Inc.
4# All rights reserved.
5# This SOFTWARE is licensed under the LICENSE provided in the
6# ../Copyright file. By downloading, installing, copying, or otherwise
7# using the SOFTWARE, you agree to be bound by the terms of that
8# LICENSE.
9# Phil Shafer, July 2014
10#
11
12BASE=@XO_SHAREDIR@
13VERSION=@LIBXO_VERSION@
14CMD=cat
15DONE=
16WEB=http://juniper.github.io/libxo/${VERSION}/xohtml
17
18do_help () {
19    echo "xohtml: wrap libxo-enabled output in HTML"
20    echo "Usage: xohtml [options] [command [arguments]]"
21    echo "Valid options are:"
22    echo "    -b <basepath> | --base <basepath>"
23    echo "    -c <command> | --command <command>"
24    echo "    -f <output-file> | --file <output-file>"
25    exit 1
26}
27
28while [ -z "$DONE" -a ! -z "$1" ]; do
29    case "$1" in
30        -b|--base)
31            shift;
32            BASE="$1";
33	    shift;
34            ;;
35        -c|--command)
36            shift;
37            CMD="$1";
38	    shift;
39            ;;
40        -f|--file)
41            shift;
42            FILE="$1";
43	    shift;
44	    exec > "$FILE";
45            ;;
46        -w|--web)
47            shift;
48            BASE="${WEB}";
49            ;;
50
51	-*)
52	    do_help
53	    ;;
54	*)
55	    DONE=1;
56	    XX=$1;
57	    shift;
58	    CMD="$XX --libxo=html $@"
59	    ;;
60    esac
61done
62
63if [ "$CMD" = "cat" -a -t 0 ]; then
64    do_help
65fi
66
67echo '<html>'
68echo '<head>'
69echo '<meta http-equiv="content-type" content="text/html; charset=utf-8"/>'
70echo '<link rel="stylesheet" href="'$BASE'/xohtml.css">'
71echo '<link rel="stylesheet" href="'$BASE'/external/jquery.qtip.css"/>'
72echo '<script type="text/javascript" src="'$BASE'/external/jquery.js"></script>'
73echo '<script type="text/javascript" src="'$BASE'/external/jquery.qtip.js"></script>'
74echo '<script type="text/javascript" src="'$BASE'/xohtml.js"></script>'
75echo '<script>'
76echo '</script>'
77echo '</head>'
78echo '<body>'
79
80$CMD
81
82echo '</body>'
83echo '</html>'
84
85exit 0
86