scripts for my gemini capsule
Bookmark: Add a script to create bookmarks
| -rwxr-xr-x | bookmark.sh | 28 | ||||
| -rwxr-xr-x | index.gmi | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/bookmark.sh b/bookmark.sh new file mode 100755 index 0000000..b8d6a0d --- /dev/null +++ b/bookmark.sh @@ -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' @@ -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 ' |