-- Leo's gemini proxy

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

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

repo: blog
action: blob
revision:
path_from: index.cgi
revision_from: refs/heads/master:
path_to:
revision_to:

git.thebackupbox.net

blog

git://git.thebackupbox.net/blog

blob of:

blog

/ index.cgi

refs/heads/master:/index.cgi
 #!/usr/bin/env bash
 cd blog 2>&1 >/dev/null 2>&1

 if [ "${PATH_INFO}" ];then
   case "$SERVER_PROTOCOL" in
 HTTP*)
   printf "Status: 404 Not Found\r\n"
   printf "Content-Type: text/plain\r\n\r\n"
   printf "Dunno what you're talking about.\n"
   exit 0
   ;;
 gemini*)
   printf "51 Not Found\r\n"
   ;;
 *)
   printf "wtf? gopher?"
   ;;
 esac
 fi

 title='🛸 epoch'\''s "blog"'

 case "$SERVER_PROTOCOL" in

 HTTP*)
 	printf "Content-Type: text/html; charset=UTF-8\r\n\r\n"
 	printf '<html>\n'
 	printf '  <head>\n'
 	printf '    <title>%s</title>\n' "${title}"
 	printf '    <link rel="stylesheet" type="text/css" href="/minimal.css" />\n'
         printf '  </head>\n'
         printf '  <body>\n'
 	printf '  <h1>%s</h1>\n' "${title}"
 	printf "<ul>\n"
 	find . -maxdepth 1 -type f \
 		| grep -v '^\./\.' \
 		| grep -v '\.cgi$' \
 		| sed 's|^./||g' \
 		| while read -r line;do
 			stat "$line" -c '<li><a href="%n"> %w - %n -- ' \
 				| cut '-d ' -f1-3,6- \
 				| sed 's|/blog/./|/blog/|g' \
 				| tr -d '\n'
 			grep -m1 '^#' "$line" \
 				| sed 's/^#* *//' \
 				| sed 's|$|</a></li>|g'
 		done \
 		| sort -rk 3
 	printf "</ul>\n"
         printf '  </body>\n'
         printf '</html>\n'
 ;;
 gemini*)
 	printf "20 text/gemini\r\n"
 	printf '# %s\n' "${title}"
 	find . -maxdepth 1 -type f \
 		| grep -v '^\./\.' \
 		| grep -v '\.cgi$' \
 		| sed 's|^./||g' \
 		| while read -r line;do
 			stat "$line" -c '=> %n %w - %n -- ' \
 				| cut '-d ' -f1-3,6- \
 				| sed 's|/blog/./|/blog/|g' \
 				| tr -d '\n'
 			grep -m1 '^#' "$line" \
 				| sed 's/^#* *//'
 		done \
 		| sort -rk 3
 ;;
 esac

-- Response ended

-- Page fetched on Sun Jun 2 15:19:23 2024