site

My personal website.

Date: Mon, 12 Jul 2021 14:38:21 +0200

Make generate output geomyidae menus

Diffstat:

M generate                            |      17 ++++++++++-------

1 file changed, 10 insertions(+), 7 deletions(-)

@@ -52,21 +52,21 @@ while read -r file <&4; do
                 end=""
                 line="$(escape "$line" | cut -c 5- | tr -d '\n')"
                 [ $output = "html" ] && printf "<h3>%s</h3>\n" "$line"
-                [ $output = "gopher" ] && printf "i### %s\tfake\t(NULL)\t0\r\n" "$line"
+                [ $output = "gopher" ] && printf "t### %s\n" "$line"
                 ;;
             "## "*)
                 [ -n "$end" ] && echo "$end"
                 end=""
                 line="$(escape "$line" | cut -c 4- | tr -d '\n')"
                 [ $output = "html" ] && printf "<h2>%s</h2>\n" "$line"
-                [ $output = "gopher" ] && printf "i## %s\tfake\t(NULL)\t0\r\n" "$line"
+                [ $output = "gopher" ] && printf "t## %s\n" "$line"
                 ;;
             "# "*)
                 [ -n "$end" ] && echo "$end"
                 end=""
                 line="$(escape "$line" | cut -c 3- | tr -d '\n')"
                 [ $output = "html" ] && printf "<h1>%s</h1>\n" "$line"
-                [ $output = "gopher" ] && printf "i# %s\tfake\t(NULL)\t0\r\n" "$line"
+                [ $output = "gopher" ] && printf "t# %s\n" "$line"
                 ;;
             "=>"*)
                 [ -n "$end" ] && echo "$end"
@@ -88,10 +88,12 @@ while read -r file <&4; do
                             ;;
                         http://*)
                             itemtype="h"
+                            path="$(printf "URL:%s" "$url")"
                             port="80"
                             ;;
                         https://*)
                             itemtype="h"
+                            path="$(printf "URL:%s" "$url")"
                             port="443"
                             ;;
                         *.gmi)
@@ -113,7 +115,8 @@ while read -r file <&4; do
                             port="70"
                             ;;
                     esac
-                    printf "%s%s\t%s\t%s\t%d\r\n" "$itemtype" "$text" "$url" "$host" "$port"
+                    text="$(printf "%s" "$text" | sed 's/|/\\|/g;s/\[/\\\[/g;s/\]/\\\]/g')"
+                    printf "[%s|%s|%s|%s|%d]\n" "$itemtype" "$text" "$path" "$host" "$port"
                 fi
                 ;;
             "> "*)
@@ -121,7 +124,7 @@ while read -r file <&4; do
                 end=""
                 line="$(escape "$line" | cut -c 3- | tr -d '\n')"
                 [ $output = "html" ] && printf "<blockquote>%s</blockquote>\n" "$line"
-                [ $output = "gopher" ] && printf "i    %s\tfake\t(NULL)\t0\r\n" "$line"
+                [ $output = "gopher" ] && printf "t    %s\n" "$line"
                 ;;
             "* "*)
                 if [ -z "$end" -a $output = "html" ]; then
@@ -130,14 +133,14 @@ while read -r file <&4; do
                 fi
                 line="$(escape "$line" | cut -c 3- | tr -d '\n')"
                 [ $output = "html" ] && printf "<li>%s</li>\n" "$line"
-                [ $output = "gopher" ] && printf "i* %s\tfake\t(NULL)\t0\r\n" "$line"
+                [ $output = "gopher" ] && printf "t* %s\n" "$line"
                 ;;
             *)
                 [ -n "$end" ] && echo "$end"
                 end=""
                 line="$(escape "$line")"
                 [ $output = "html" ] && printf "<p>%s</p>\n" "$line"
-                [ $output = "gopher" ] && printf "i%s\tfake\t(NULL)\t0\r\n" "$line"
+                [ $output = "gopher" ] && printf "t%s\n" "$line"
                 ;;
         esac
     done 3< "$file"