Add a bash script
Add a token for communitywiki.org to elpher-gemini-tokens.
This commit is contained in:
parent
25fecb9457
commit
5d0ecb3561
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
# If you set HOST, PORT, TOKEN, or PAGE as environment variables,
|
||||
# those values are used instead. If you want to edit Alex' wiki,
|
||||
# for example:
|
||||
# HOST=alexschroeder.ch PORT=1965 TOKEN=hello PAGE=Test ./gemini-wiki
|
||||
|
||||
HOST=${HOST:-communitywiki.org}
|
||||
PORT=${PORT:-1966}
|
||||
TOKEN=${TOKEN:-Elrond}
|
||||
FILE=$(tempfile)
|
||||
PAGE=${PAGE:-$(date --iso-8601=date)}
|
||||
read -p "Edit which page on $HOST? [$PAGE] "
|
||||
PAGE=${REPLY:-$PAGE}
|
||||
PAGE=$(echo "$PAGE" | perl -p -e 'chomp; s/ /_/g; s/([^A-Za-z0-9_-])/sprintf("%%%02X", ord($1))/seg')
|
||||
echo "Requesting gemini://$HOST/raw/$PAGE"
|
||||
echo "gemini://$HOST/raw/$PAGE" \
|
||||
| openssl s_client -quiet -connect $HOST:$PORT 2>/dev/null \
|
||||
| tail --lines=+2 \
|
||||
> "$FILE"
|
||||
$EDITOR "$FILE"
|
||||
SIZE=$(wc -c < "$FILE")
|
||||
read -p "Post $SIZE bytes to $PAGE? [y/n] " -n 1
|
||||
echo
|
||||
if [[ "$REPLY" == "y" ]]; then
|
||||
echo Posting it...
|
||||
(echo "titan://$HOST/raw/$PAGE;token=$TOKEN;size=$SIZE;mime=text/plain";
|
||||
cat "$FILE" ) \
|
||||
| openssl s_client -quiet -connect $HOST:$PORT 2>/dev/null
|
||||
echo Verifying gemini://$HOST/$PAGE
|
||||
echo "gemini://$HOST/$PAGE" \
|
||||
| openssl s_client -quiet -connect $HOST:$PORT 2>/dev/null
|
||||
else
|
||||
echo Abort!
|
||||
echo Your page was left here: $FILE
|
||||
fi
|
|
@ -77,7 +77,8 @@ scheme."
|
|||
(local-set-key (kbd "C-c C-k") 'gemini-write-cancel))
|
||||
|
||||
(defcustom elpher-gemini-tokens
|
||||
'(("alexschroeder.ch" . "hello"))
|
||||
'(("alexschroeder.ch" . "hello")
|
||||
("communitywiki.org" . "Elrond"))
|
||||
"An alist of hostnames and authorization tokens
|
||||
used when writing Gemini pages."
|
||||
:type '(alist :key-type (string :tag "Host") :value-type (string :tag "Token"))
|
||||
|
|
Loading…
Reference in New Issue