~earboxer/cgi-bin

5060e4a19af7f38ffc998c3afd1ac1d76dcaa6ce — Zach DeCook 2 years ago 48230d7
Bookmark: Add a script to create bookmarks
2 files changed, 30 insertions(+), 0 deletions(-)

A bookmark.sh
M index.gmi
A bookmark.sh => bookmark.sh +28 -0
@@ 0,0 1,28 @@
#!/bin/sh
# Place this script in your /cgi-bin to get your own bookmark writing script!

# Have your host key put here for yourself.
authorized="SHA256:09CC327F3DDB21AE3BA4D0F38A6757236C8C2965A90539C640E14EB087955071 Gerbil@laptop"

# Authorization guard.
if ! test "$REMOTE_USER"; then
	printf '60 Try again with a client cert!\r\n'
	exit
elif ! test "$(printf "$authorized" | grep "^$TLS_CLIENT_HASH ")"; then
	printf '20 text/plain\r\n'
	# Or, look, I did it for you!
	cat "$0" | sed "s/^authorized=.*/authorized=\"$TLS_CLIENT_HASH $REMOTE_USER\"/g"
	exit
fi

# Input guard.
if ! test "$QUERY_STRING"; then
	printf '10 Enter URL and title\r\n'
	exit
fi

dirname="$(dirname "$(realpath "$0")")"

echo "=>$QUERY_STRING" >> "$dirname/../bookmarks.gmi"

printf '30 ../bookmarks.gmi\r\n'

M index.gmi => index.gmi +2 -0
@@ 11,6 11,8 @@ printf '20 text/gemini \r\n
## misc
=> /cgi-bin/oebindex.sh Index for Open English Bible current completed books

=> /cgi-bin/bookmark.sh I use this script to edit bookmarks.gmi

# source code for all this
=> https://git.sr.ht/~earboxer/cgi-bin
'