#!/bin/sh

if [ -e ./config.sh ]; then
    . ./config.sh
fi

[ -z "$baseURL" ] &&
    export baseURL="$PWD" 

echo baseURL="$baseURL"

find . -name '*.gmi' |
    while read -r file; do
        htmlfile=$(dirname "$file")/$(basename "$file" .gmi).html
        if [ ! -e "$htmlfile" ] ||
            [ -n "$(find "$file" -newer "$htmlfile")" ] ||
            [ "$1" = "-f" ]; then
            echo "Creando $htmlfile"
            ./gmi2html "$file" > "$htmlfile"
        fi
    done