#!/bin/ksh
echo Content-type: text/html
echo ""
DOC_REQ=${REQUEST_URI##*:}
DOC_LANG=${DOC_REQ:%%/*}
DOC_NAME=${DOC_REQ##*/}
DOC_URI=/man/manoh/${DOC_NAME}
DOC_URI_ES=/man/es/manoh/${DOC_NAME}
if [ ${DOC_LANG} = "es" ]; then
if [ -f ${DOCUMENT_ROOT}/${DOC_URI_ES} ]; then
DOC_PATH=${DOCUMENT_ROOT}/${DOC_URI_ES}
elif [ -f ${DOCUMENT_ROOT}/${DOC_URI_ES}.oh ]; then
DOC_PATH=${DOCUMENT_ROOT}/${DOC_URI_ES}.oh
fi
fi
if [ ${#DOC_PATH} -eq 0 ]; then
if [ -f ${DOCUMENT_ROOT}/${DOC_URI} ]; then
DOC_PATH=${DOCUMENT_ROOT}/${DOC_URI}
elif [ -f ${DOCUMENT_ROOT}/${DOC_URI}.oh ]; then
DOC_PATH=${DOCUMENT_ROOT}/${DOC_URI}.oh
fi
fi
if [[ ${HTTP_USER_AGENT} = "curl"* ]] ; then
if [ ${#DOC_PATH} -gt 0 ]; then
/bin/mandoc ${DOC_PATH}
else
help="${help}use :[es/][FILENAME][.oh]\n"
help="${help}:history,:history.oh,:es/historial,:es/historial.oh"
data_en=$(ls -F ${DOCUMENT_ROOT}/man/manoh | /bin/grep -v "/$" )
data_es=$(ls -F ${DOCUMENT_ROOT}/man/es/manoh | /bin/grep -v "/$" | /bin/sed "s@^@es/@")
data="${data_en}\n${data_es}\n"
fi
echo -e "${data}${help}"
else
if [ ${#DOC_PATH} -gt 0 ]; then
/bin/mandoc -T html -O style=/css/style.css,man=/%N.html ${DOC_PATH}
else
cat ${DOCUMENT_ROOT}/man/manoh/menu.oh ${DOCUMENT_ROOT}/man/manoh/errors/404.oh | /bin/grep -v "OH_FILETEXT" | mandoc -T html -O style=/css/style.css,man=/%N.html
fi
fi