From b426388561fd1d0379674abb55f6024e26dd20b7 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Fri, 2 Jun 2023 14:15:42 -0500 Subject: Change function names; update README and MAKEFILE --- cacophony.sh | 23 ++++++++++++++++++----- makefile | 1 + readme | 23 +++++++++++++++-------- source/index | 6 +++++- 4 files changed, 39 insertions(+), 14 deletions(-) diff --git a/cacophony.sh b/cacophony.sh index 7cf4dc3..f893a60 100755 --- a/cacophony.sh +++ b/cacophony.sh @@ -1,4 +1,5 @@ #!/bin/sh +# cacophony by C. Duckworth --- public domain SCRIPTDIR=source @@ -7,7 +8,7 @@ crlf() { # crlf < INPUT sed 's/$/ /g' } -header() { # header [STATUS] +http_header() { # header [STATUS] cat <
+copyright (C) $(stat -c %y "$1" | cut -d- -f1) Case Duckworth. +this page is a program +served by cacophony. + + +EOF +} + hexec() { # hexec PROGRAM [header args] prog="$1"; shift - header "$@" - exec "$prog" + http_header "$@" + "$prog" + html_footer "$prog" } -run() { +run() { # run if test / = "$PATH_INFO" then PATH_INFO=/index run else path="$PWD/$SCRIPTDIR$PATH_INFO" if ! test -d "$path" && test -x "$path" then hexec "$path" 200 - else header 404 + else http_header 404 fi fi } diff --git a/makefile b/makefile index b783d07..8bee547 100644 --- a/makefile +++ b/makefile @@ -1,2 +1,3 @@ serve: cacophony.sh lighttpd.conf + @grep server.port lighttpd.conf lighttpd -D -f lighttpd.conf diff --git a/readme b/readme index 0a7764e..0a37b0a 100644 --- a/readme +++ b/readme @@ -1,15 +1,22 @@ -CACOPHONY -"Every page a program" + CACOPHONY + "Every page a program" -This repo contains *cacophony.sh*, a CGI script that will run every script in -the source/ directory as a CGI script to display a page. +This repo contains *cacophony.sh*, a CGI script that will run every +script in the source/ directory as a CGI script to display a page. -This is probably a bad idea. It originated mostly on tilde.town. +This is probably a bad idea. It originated mostly on tilde.town. -USAGE += USAGE = -There's a lighttpd.conf in here for basic testing. Just run `make`. +There's a lighttpd.conf in here for basic testing. Just run `make`. -LICENSE += CUSTOMIZATION = + +Check `cacophony.sh` for variables and functions to play around +with. You'll probably want to play with `$SCRIPTDIR` and +`html_footer`, but you could change `http_header` too (or of course +whatever you like). + += LICENSE = Public domain \ No newline at end of file diff --git a/source/index b/source/index index 1b870b4..e4e48a4 100755 --- a/source/index +++ b/source/index @@ -1,8 +1,12 @@ #!/bin/sh # -*- markdown -*- -echo "";pandoc <" +echo "";pandoc <