will not look for favicon.txt by default
[lace] / laced
diff --git a/laced b/laced
index ae8c8254ab76528857559fc6cc4ea7954b8a7d6e..91314a48dd23516c11db0afb315c8e1276f0d28e 100755 (executable)
--- a/laced
+++ b/laced
@@ -29,6 +29,7 @@ esc=$(echo -e "\033")
        fi
 tmpfile=$(mktemp /tmp/lace.XXXXXX)
 tmpfile2=$(mktemp /tmp/lace.XXXXXX)
+tmpfile3=$(mktemp /tmp/lace.XXXXXX)
 function reldate() {
 # stolen from https://unix.stackexchange.com/a/451216
     local SEC_PER_MINUTE=$((60))
@@ -89,13 +90,26 @@ function timeline() {
                                url="$url/"
                        fi
                        domain=$(sed 's/\/.*$//' <<< "$domain")
-                       fav=$(timeout $connectto openssl s_client -crlf -quiet -connect "$domain:1965" <<<"gemini://$domain/favicon.txt" 2>/dev/null | sed -e '1d')
+                       timeout $connectto openssl s_client -crlf -quiet -connect "$domain:1965" <<<"$url" 2>/dev/null > $tmpfile3
                        timeoutstatus=${PIPESTATUS[0]}
                        if [ $timeoutstatus -ne 124 ];then
-                       if [ ! -z "$fav" ];then
-                               user="$fav $user"
+                       local newuser=$(cat $tmpfile3 | grep -m 1 author: | awk -F ":" '{print $2}'  )
+               local newavatar=$(cat $tmpfile3 | grep -m 1 avatar: | awk -F ":" '{print $2}'  )
+                       if [[ $newuser != "" ]]
+                       then
+       newuser=$(echo "$newuser" | xargs)
+       newavatar=$(echo "$newavatar" | xargs)
+               user="$newavatar $newuser"
+       else
+       fav=$(timeout $connectto openssl s_client -crlf -quiet -connect "$domain:1965" <<<"gemini://$domain/favicon.txt" 2>/dev/null | sed -e '1d')
+if [ ! -z "$fav" ];then
+       user="$fav $user"
+       fi
+               
                        fi
-                       timeout $connectto openssl s_client -crlf -quiet -connect "$domain:1965" <<<"$url" 2>/dev/null | sed -e '1d' | sed -n '/##/,$p' | sed -e "s/^\(## .*\)$/\1\n${esc}$red$user${esc}$nc ($domain)/g" >> $tmpfile
+
+
+                       cat $tmpfile3 | sed -e '1d' | sed -n '/##/,$p' | sed -e "s/^\(## .*\)$/\1\n${esc}$red$user${esc}$nc ($domain)/g" >> $tmpfile
                        [[ ! -z $(sed -n '$p' $tmpfile) ]] && echo "" >> $tmpfile
                        fi
                done <"$subsfile"
@@ -118,6 +132,7 @@ function timeline() {
        wordcount="$(wc -c $tmpfile | awk '{print $1}')"
        if [[ "$wordcount" > 100 ]]; then
        cp $tmpfile $config_place/microblogs.gmi 
+       cp $tmpfile /mnt/geminiserver/gemini/lace.gmi
        else
                
 sed -i '1i Laced could not connect to the Internet showing previous download' $config_place/microblogs.gmi
@@ -125,7 +140,7 @@ sed -i '1i Laced could not connect to the Internet showing previous download' $c
        fi
 
 
-       rm -f $tmpfile $tmpfile2
+       rm -f $tmpfile $tmpfile2 $tmpfile3
        }
 
        if [[ "$1" == "help" ]] || [[ "$1" == "--help" ]] || [[ "$1" == "-help" ]] || [[ "$1" == "-h" ]];then