#!/bin/sh
printf '%s\\n\\r' "Content-type: text/html"
die() {
printf '%s error: %s\\n\\r' "$(basename "$0")" "$@"
exit
}
if [ ! "$QUERY_STRING" ]; then
die "No 'file' parameter"
fi
./gemget -o - "$QUERY_STRING" | ./gmi2html.awk
(EDIT: use better example)
new code:
#!/bin/sh
page="$(echo "$QUERY_STRING" | sed 's/page\\?=//')"
style="https://unpkg.com/sakura.css/css/sakura-dark.css"
title="Aoi's Gemini Proxy - ${page}"
title_err="Aoi's Gemini Proxy - Error"
printf "%s %s\\n\\r" "Content-type: text/html"
if [ -z "$page" ]; then
echo "<!DOCTYPE html><html><head><link rel=stylesheet href=$style><title>$title_err</title></head>"
echo "<body><p>Usage: <code>$(basename $0)/page?=gemini://envs.net</code></p><p>Note: This proxy is half-baked on purpose</p>"
echo "</body></html>"
else
echo "<!DOCTYPE html><html><head><link rel=stylesheet href=$style><title>$title</title></head>"
echo "<body>$(./gemget -o - ${page} | ./gmi2html)</body>"
echo "<br><hr><footer><details><summary>Proxied by <a href=https://git.sr.ht/~novaburst/cgi-gemini-proxy>cgi-gemini-proxy</a></summary></details></footer></body></html>"
fi
page=
parameter, haha