#!/bin/sh

WEBSERVER='aquaria'

build() {
	[[ ! ${VIRTUAL_ENV} ]] && NO_VENV=1 && source ./.venv/bin/activate
	pelican
	retval=$?
	[[ ${NO_VENV} ]] && deactivate
	return $retval
}

upload() {
	rsync -avz --delete output/* ${WEBSERVER}:~/web/haemka.de/
}

build
if [ $? == 0 ]; then
    while getopts u param
    do
        case "$param" in
            u) upload ;;
            *) echo "Not implemented: $1" >&2 && exit 1 ;;
        esac
    done
fi


