-- Leo's gemini proxy

-- Connecting to git.thebackupbox.net:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: fmrl
action: commit
revision:
path_from:
revision_from: 23cc6823f9ba00b3da77c537d5cf63059fe516ef:
path_to:
revision_to:

git.thebackupbox.net

fmrl

git://git.thebackupbox.net/fmrl

commit 23cc6823f9ba00b3da77c537d5cf63059fe516ef
Author: epoch <epoch@hack.thebackupbox.net>
Date:   Tue Feb 8 09:46:32 2022 +0000

    server-side converter to svg so fmrl statuses can be put into forum signatures.. or whatever

diff --git a/fmrl-svg.cgi b/fmrl-svg.cgi
new file mode 100755
index 0000000000000000000000000000000000000000..ce5c34f5fde764a801f66459d206c49a63aeca7d
--- /dev/null
+++ b/fmrl-svg.cgi
@@ -0,0 +1,33 @@
+#!/bin/sh
+user="$(printf "%s\n" "$QUERY_STRING" | tr '&' '\n' | grep ^user= | cut -d= -f2-)"
+host="${HTTP_HOST}"
+if [ -z "$user" ];then
+  printf 'Content-Type: text/plain\r\n\r\n'
+else
+  file="/var/www/fmrl/.users/$user"
+  last_modified="$(stat -c '%Y' "${file}")"
+  if [ "${HTTP_IF_MODIFIED_SINCE}" ];then
+    if_modified_since="$(date "+%s" --date="$(printf '%s\n' "${HTTP_IF_MODIFIED_SINCE}" | cut -d+ -f1)")"
+    if [ "${if_modified_since}" -ge "${last_modified}" ];then
+      printf 'Status: 304 Not Modified\r\n\r\n'
+      exit 0
+    fi
+  fi
+  u_avatar="$(jq -r .avatar.original < "$file")"
+  u_name="$(jq -r .name < "$file" | html_entities_encode)"
+  u_emoji="$(jq -r .emoji < "$file" | html_entities_encode)"
+  u_status="$(jq -r .status < "$file" | html_entities_encode)"
+  u_media="$(jq -r .media < "$file" | html_entities_encode)"
+  u_media_type="$(jq -r .media_type < "$file" | tr -cd '0-9')"
+  media_verb="reading,watching,watching,listening to,listening to,playing"
+  u_media_verb="$(printf "%s\n" "$media_verb" | cut -d, -f${u_media_type})"
+  printf "Expires: %s\r\n" "$(rfc7231date)"
+  printf "Content-Type: image/svg+xml\r\n\r\n"
+  printf '<svg width="600px" height="60px" viewBox="0 0 600 60" xmlns="http://www.w3.org/2000/svg">\r\n'
+  printf '<rect width="600px" height="60px" fill="black" />'
+  printf '<image width="48" height="48" x="6" y="6" href="%s"/>' "$u_avatar"
+  printf '<text x="56" y="18" fill="lime" stroke="green">fmrl status for: %s &lt;%s@%s&gt;</text>' "$u_name" "$user" "$host"
+  printf '<text x="56" y="36" fill="lime" stroke="green">%s %s</text>' "$u_emoji" "$u_status"
+  printf '<text font-size="smaller" x="56" y="52" fill="lime" stroke="green">%s %s</text>' "$u_media_verb" "$u_media"
+  printf '</svg>'
+fi

-----END OF PAGE-----

-- Response ended

-- Page fetched on Sun Jun 2 16:05:21 2024