-- Leo's gemini proxy

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

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: uritools
action: commit
revision:
path_from:
revision_from: 9705a81be3e6a7d63909074ab45b862b46c6d88f:
path_to:
revision_to:

git.thebackupbox.net

uritools

git://git.thebackupbox.net/uritools

commit 9705a81be3e6a7d63909074ab45b862b46c6d88f
Author: epoch <epoch@hack.thebackupbox.net>
Date:   Mon Oct 12 09:16:57 2020 +0000

    urititle now will show content-type of gemini links if it isn't text/gemini

diff --git a/urititle b/urititle

index 510c7cd81a98a8d777c13185fdcaa6d59de5184c..

index ..f6f93eab5904e203c93e33b4f91b5b92d6ac84ca 100755

--- a/urititle
+++ b/urititle
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 scheme=$(printf "%s\n" "$1" | uricut -s)
 path=$(printf "%s\n" "$1" | uricut -p)
 qs=$(printf "%s\n" "$1" | uricut -q)
@@ -37,7 +37,17 @@ if [ "$port" ];then
   fi
   ;;
 gemini)
-  printf "title: %s\n" "$(gemini-get "$1" | grep '^#' | head -n1 | sed 's/^#* *//g')"
+  first=1
+  gemini-get "$1" | while read -r line;do
+    if [ "$first" ];then
+      unset first
+      if ! printf "%s\n" "$line" | grep '^[^ ]* text/gemini' 2>&1 >/dev/null;then
+        printf "title: %s\n" "$(printf "%s\n" "$line" | tr '\t' ' ' | tr -s ' ' | cut '-d ' -f2-)"
+      fi
+    else
+      printf "title: %s\n" "$(printf "%s\n" "$line" | grep '^#' | sed 's/^#* *//g')"
+    fi
+  done | head -n1
   ;;
 magnet)
   printf "title: %s\n" "$(printf "%s\n" "$1" | tr '&' '\n' | grep ^dn= | cut -d= -f2- | uriunescape)"

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

-- Response ended

-- Page fetched on Sun Jun 2 14:38:14 2024