~ecs/ecs.d2evs.net

c21ce371011456e657a57fd7aaf5eeb9a20fc3cf — Eyal Sawady 30 days ago 19ac88b master
oglaf.sh: initial commit
1 files changed, 22 insertions(+), 0 deletions(-)

A proxy/oglaf.sh
A proxy/oglaf.sh => proxy/oglaf.sh +22 -0
@@ 0,0 1,22 @@
#!/bin/sh
if [ "z${PATH_INFO#/img}" != "z${PATH_INFO}" ]; then
	printf "20 image/gif\r\n"
	curl -L "$(curl -L "https://oglaf.com${PATH_INFO#/img}" 2>/dev/null | hq 'sel [id=strip] | . src')" 2>/dev/null
	exit
fi

tmp="$(mktemp)"
trap "rm $tmp" EXIT

printf "20 text/gemini\r\n"

curl -Lf "https://oglaf.com$PATH_INFO/" >"$tmp" 2>/dev/null || curl -Lf "https://oglaf.com/" >"$tmp" 2>/dev/null

printf "# "
hq 'sel title | totext' <"$tmp"
printf "\n=> $SCRIPT_NAME/img$PATH_INFO image\n\n"
hq 'sel [id=strip] | . alt' <"$tmp"
printf "\n"
hq 'sel [id=strip] | . title' <"$tmp"
printf "\n=> $SCRIPT_NAME$(hq 'sel [class="\"button previous\""] | . href | path' <"$tmp") prev"
printf "\n=> $SCRIPT_NAME$(hq 'sel [class="\"button next\""] | . href | path' <"$tmp") next\n"