💾 Archived View for lyk.so › systems › gemini › tinylog captured on 2023-06-16 at 16:17:59. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
Updated 2022-02-07
For adding entries to my tinylog and mirroring them to station.martinrue.com, I use this script:
#!/usr/bin/env sh set -e echo "GEMINI_CERT GEMINI_KEY GEMINI_TINYLOG_LOCAL GEMINI_TINYLOG_REMOTE GEMINI_STATION_CSRF_TOKEN" | while read const; do if [ ! "$(eval "echo "$(echo "\$const")"")" ]; then >&2 echo "Required variable undefined: $const" exit 1 fi done stationpost="gemini://station.martinrue.com/$GEMINI_STATION_CSRF_TOKEN/post" # Mirror to station.martinrue.com if the post is not a tinylog reply if (! echo "$@" | head -n1 | grep -iq "^re: "); then urlencoded="$(echo -n "$@" | perl -MURI::Escape -ne 'print uri_escape($_)')" stationurl="$stationpost?$urlencoded" # Don't exceed the maximum post length on Station. urllen="$(printf "%s" "$stationurl" | wc -c)" if [ "$urllen" -gt "1024" ]; then >&2 echo "ERROR: The post URL exceeds 1024 bytes. The URL was $urllen bytes long. Trim down your post and try again." exit 1 fi gemget --cert $GEMINI_CERT --key $GEMINI_KEY $stationurl -o - > /dev/null fi ed $log <<EOF /## i ## $(date -u +'%F %H:%M UTC') $@ . w q EOF # Setting SSH_AUTH_SOCK to an empty string for this command in order to bypass # the Ledger SSH agent, since we're using a key file rather than a hardware fob # to authenticate here. The user associated with this keyfile on the server can # *only* write to the tinylog file. SSH_AUTH_SOCK='' scp $GEMINI_TINYLOG_LOCAL $GEMINI_TINYLOG_REMOTE
This script first checks to see if the post appears to be a tinylog reply. If it isn't, it uses Perl to URL-encode the entry and checks the length of the resulting URL for posting to Station. If it's not longer than the Gemini protocol limit of 1024 bytes, it uses gemget to post the entry to station.martinrue.com. Then it opens my tinylog in ed, finds the first occurrence of "##", enters insert mode on the line above it, enters the date in the format suggested by bacardi55's RFC, the arguments to the script, and a blank line, leaves insert mode, writes, and quits. Finally it uses scp to upload the updated tinylog to my gemsite over ssh.
For consuming tinylogs, I use bacardi55's gtl client and autosubscribe to tinylogs in that project's Known-tinylogs.md file using the following script:
#!/usr/bin/env sh set -e cd ~/.config/gtl temp="$(mktemp -d)" trap 'rm -fr "$temp"' EXIT INT HUP # Ensure subs file is sorted cat subs | sort > "$temp/sorted" mv "$temp/sorted" subs # Ensure a "blocked" file exists touch blocked curl -s https://codeberg.org/bacardi55/gemini-tinylog-rfc/raw/branch/main/Known-tinylogs.md \ | grep "* gemini://" \ | sed "s/^\* //g" \ | sort \ > "$temp/known" comm -13 blocked "$temp/known" > "$temp/new-subs-file" comm -13 subs "$temp/new-subs-file" > "$temp/new-logs" if [ "$(cat "$temp/new-logs")" != "" ]; then echo "Subscribing to:" cat "$temp/new-logs" else echo "No new tinylogs." fi mv "$temp/new-subs-file" subs
update-tinylog-subscriptions.sh
It adds to my ~/.config/gtl/subs file any new URL and alias pairs in Known-tinylogs.md that don't match any lines in my ~/.config/gtl/blocked file.