about summary refs log tree commit diff stats
path: root/cacophony.sh
diff options
context:
space:
mode:
Diffstat (limited to 'cacophony.sh')
-rwxr-xr-xcacophony.sh14
1 files changed, 9 insertions, 5 deletions
diff --git a/cacophony.sh b/cacophony.sh index 92a5d4b..d6e2bf0 100755 --- a/cacophony.sh +++ b/cacophony.sh
@@ -1,7 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2# cacophony by C. Duckworth --- hereby released to the public domain 2# cacophony by C. Duckworth --- hereby released to the public domain
3 3
4SCRIPTDIR=source 4SCRIPTDIR=/home/acdw/www
5 5
6crlf() { # crlf < INPUT 6crlf() { # crlf < INPUT
7 ## Convert LF to CRLF 7 ## Convert LF to CRLF
@@ -22,7 +22,7 @@ HEADER
22 22
23html_footer() { # html_footer 23html_footer() { # html_footer
24 cat <<FOOTER 24 cat <<FOOTER
25<footer>this page is a <a href="$SCRIPTDIR/${1##*/}">program</a> 25<footer>this page is a <a href="/src/${1##*/}">program</a>
26served by <a href="https://git.acdw.net/cacophony">cacophony</a>. 26served by <a href="https://git.acdw.net/cacophony">cacophony</a>.
27</footer></body></html> 27</footer></body></html>
28FOOTER 28FOOTER
@@ -41,12 +41,12 @@ hexec() { # hexec PROGRAM [http_header args]
41 shift 41 shift
42 http_header "$@" 42 http_header "$@"
43 "$prog" 43 "$prog"
44 html_footer 44 html_footer "$prog"
45} 45}
46 46
47run() { # run 47run() { # run
48 pag="$PWD$PATH_INFO" 48 pag="$PWD$PATH_INFO"
49 src="$PWD/$SCRIPTDIR$PATH_INFO" 49 src="$SCRIPTDIR$PATH_INFO"
50 50
51 if test / = "$PATH_INFO" 51 if test / = "$PATH_INFO"
52 then PATH_INFO=/index run 52 then PATH_INFO=/index run
@@ -60,7 +60,11 @@ run() { # run
60 elif test -d "$pag" && test -r "$pag/index.html" 60 elif test -d "$pag" && test -r "$pag/index.html"
61 then hcat 200 < "$pag/index.html" 61 then hcat 200 < "$pag/index.html"
62 62
63 else http_header 404 63 else
64 case "$PATH_INFO" in
65 /src/*) hcat 200 < "$SCRIPTDIR/${PATH_INFO#/src/}" ;;
66 *) http_header 404 ;;
67 esac
64 fi 68 fi
65} 69}
66 70