#!/bin/sh

THISDIR=`dirname "$0"`
INDIR="$THISDIR/../wiki"

ROOT="Departure"

MAPPING='--mapping WikiPedia https://en.wikipedia.org/wiki/'
THEME='--theme mercurial'

if [ "$1" = '--web' ] ; then
    DOCINDEX=
    shift 1
else
    DOCINDEX='--document-index index.html'
fi

if [ "$1" = '-o' ] ; then
    OUTDIR="$2"
    shift 2
else
    OUTDIR="$THISDIR/../html"
fi

FILENAMES=${*:-'--all'}

moinconvert --input-dir "$INDIR" \
            --input-page-sep '--' \
            --output-dir "$OUTDIR" \
            --root "$ROOT" \
            --format html \
            --macros \
            $DOCINDEX \
            $MAPPING \
            $THEME \
            $FILENAMES
