-- Leo's gemini proxy
-- Connecting to git.thebackupbox.net:1965...
-- Connected
-- Sending request
-- Meta line: 20 text/gemini
repo: www_git action: commit revision: path_from: revision_from: d99c370fa869abf919dbdbde8c015dff12ed28a5: path_to: revision_to:
commit d99c370fa869abf919dbdbde8c015dff12ed28a5 Author: epoch <epoch@hack.thebackupbox.net> Date: Sat May 8 06:10:37 2021 +0000 at least it isn't github diff --git a/index.cgi b/index.cgi new file mode 100755 index 0000000000000000000000000000000000000000..cd77d2c42975eb75be44478a91647d6f23aaa83c --- /dev/null +++ b/index.cgi @@ -0,0 +1,66 @@ +#!/bin/bash +export PI_1="$(printf "%s\n" "$PATH_INFO" | cut -d/ -f2 | tr -cd 'a-zA-Z0-9_-')" ### REPO +export PI_2="$(printf "%s\n" "$PATH_INFO" | cut -d/ -f3 | tr -cd 'a-zA-Z0-9_-')" ### branch +export PI_3="$(printf "%s\n" "$PATH_INFO" | cut -d/ -f4- | tr -cd 'a-zA-Z0-9_/.-')" ### path in git repo of.. file or dir I guess +if [ "$PI_3" ];then + trailing_slash="$(printf "%s\n" "${PI_3}" | rev | cut -b1 | grep /)" + export PI_3="$(normalpath "/$PI_3" | cut -b2-)${trailing_slash}" +fi +if [ "${PI_1}" ];then + if printf "%s\n" "$PATH_INFO" | grep -v '^/'"${PI_1}"'/' 2>&1 >/dev/null;then + printf "Status: 301\r\n" + printf "Location: /%s/\r\n" "${PI_1}" + printf "Content-Type: text/plain\r\n\r\n" + printf "redirect to: /%s/" "${PI_1}" + exit 0 + fi +fi +if [ "${PI_2}" ];then + if printf "%s\n" "$PATH_INFO" | grep -v '^/'"${PI_1}"'/'"${PI_2}"'/' 2>&1 >/dev/null;then + printf "Status: 301\r\n" + printf "Location: /%s/%s/\r\n" "${PI_1}" "${PI_2}" + printf "Content-Type: text/plain\r\n\r\n" + printf "redirect to: /%s/%s/" "${PI_1}" "${PI_2}" + exit 0 + fi +fi +printf "Content-Type: text/html\r\n\r\n" +printf "<html><head><title>%s</title></head><body>\n" "git shit" +if [ ! "${PI_1}" ];then + printf "<h2>repositories</h2>" + ls /var/git \ + | sed 's|^\(.*\)$|<a href="/\1/">/\1/</a><br/>|g' +else + gitroot="$(normalpath /var/git/${PI_1})" + if printf "%s\n" "$gitroot" | grep -v '^/var/git/' 2>&1 >/dev/null;then + printf "derp." + else ## we are in a valid git repo + printf '<h1><a href="/">git.thebackupbox.net</a> / <a href="/%s/">%s</a>' "$PI_1" "$PI_1" + if [ "$PI_2" ];then + printf ' / <a href="/%s/%s/">%s</a>' "$PI_1" "$PI_2" "$PI_2" + fi + if [ "$PI_3" ];then + printf ' / <a href="/%s/%s/%s">%s</a>' "$PI_1" "$PI_2" "$PI_3" "$PI_3" + fi + printf '</h1>' + cd /"$gitroot" + if [ ! "${PI_2}" ];then ## we have not be provided a branch name yet... + printf "<h2>branches</h2>" + git show-branch \ + | sed 's|^\[\(.*\)\] \(.*\)$|[<a href="\1/">\1/</a>] \2<br/>|g' + else + if [ ! "${PI_3}" -o "$(printf "%s\n" "$PI_3" | rev | cut -b1)" = "/" ];then + printf "<h2>file list</h2>" + git show -- "${PI_2}:${PI_3}" | tail -n+3 \ + | sed 's|^\(.*\)$|<a href="\1">\1</a><br/>|g' + else + printf "<h2>file contents %s</h2>" "$PI_3" + echo "<pre>" + git show -- "${PI_2}":"${PI_3}" | html_entities_encode + echo "</pre>" + fi + fi + fi +fi + +printf "</body></html>\n" diff --git a/robots.txt b/robots.txt new file mode 100644 index 0000000000000000000000000000000000000000..1f53798bb4fe33c86020be7f10c44f29486fd190 --- /dev/null +++ b/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: /
-----END OF PAGE-----
-- Response ended
-- Page fetched on Sun Jun 2 18:16:30 2024