diff options
author | Case Duckworth | 2023-06-02 14:15:42 -0500 |
---|---|---|
committer | Case Duckworth | 2023-06-02 14:15:42 -0500 |
commit | b426388561fd1d0379674abb55f6024e26dd20b7 (patch) | |
tree | a6156d5ae5b3daf54abc52e77089aaa4a10f04e2 | |
parent | Update readme (diff) | |
download | cacophony-b426388561fd1d0379674abb55f6024e26dd20b7.tar.gz cacophony-b426388561fd1d0379674abb55f6024e26dd20b7.zip |
Change function names; update README and MAKEFILE
-rwxr-xr-x | cacophony.sh | 23 | ||||
-rw-r--r-- | makefile | 1 | ||||
-rw-r--r-- | readme | 23 | ||||
-rwxr-xr-x | 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 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # cacophony by C. Duckworth --- public domain | ||
2 | 3 | ||
3 | SCRIPTDIR=source | 4 | SCRIPTDIR=source |
4 | 5 | ||
@@ -7,7 +8,7 @@ crlf() { # crlf < INPUT | |||
7 | sed 's/$/ /g' | 8 | sed 's/$/ /g' |
8 | } | 9 | } |
9 | 10 | ||
10 | header() { # header [STATUS] | 11 | http_header() { # header [STATUS] |
11 | cat <<HEADER | crlf | 12 | cat <<HEADER | crlf |
12 | HTTP/1.1 ${1:-200} | 13 | HTTP/1.1 ${1:-200} |
13 | Content-Type: text/html;charset=utf-8 | 14 | Content-Type: text/html;charset=utf-8 |
@@ -15,20 +16,32 @@ Content-Type: text/html;charset=utf-8 | |||
15 | HEADER | 16 | HEADER |
16 | } | 17 | } |
17 | 18 | ||
19 | html_footer() { # footer PROGRAM | ||
20 | cat <<EOF | ||
21 | <footer> | ||
22 | copyright (C) $(stat -c %y "$1" | cut -d- -f1) Case Duckworth. | ||
23 | this page is a <a href="$SCRIPTDIR/${1##*/}">program</a> | ||
24 | served by <a href="https://git.acdw.net/cacophony">cacophony</a>. | ||
25 | </footer> | ||
26 | </body></html> | ||
27 | EOF | ||
28 | } | ||
29 | |||
18 | hexec() { # hexec PROGRAM [header args] | 30 | hexec() { # hexec PROGRAM [header args] |
19 | prog="$1"; shift | 31 | prog="$1"; shift |
20 | header "$@" | 32 | http_header "$@" |
21 | exec "$prog" | 33 | "$prog" |
34 | html_footer "$prog" | ||
22 | } | 35 | } |
23 | 36 | ||
24 | run() { | 37 | run() { # run |
25 | if test / = "$PATH_INFO" | 38 | if test / = "$PATH_INFO" |
26 | then PATH_INFO=/index run | 39 | then PATH_INFO=/index run |
27 | else | 40 | else |
28 | path="$PWD/$SCRIPTDIR$PATH_INFO" | 41 | path="$PWD/$SCRIPTDIR$PATH_INFO" |
29 | if ! test -d "$path" && test -x "$path" | 42 | if ! test -d "$path" && test -x "$path" |
30 | then hexec "$path" 200 | 43 | then hexec "$path" 200 |
31 | else header 404 | 44 | else http_header 404 |
32 | fi | 45 | fi |
33 | fi | 46 | fi |
34 | } | 47 | } |
diff --git a/makefile b/makefile index b783d07..8bee547 100644 --- a/makefile +++ b/makefile | |||
@@ -1,2 +1,3 @@ | |||
1 | serve: cacophony.sh lighttpd.conf | 1 | serve: cacophony.sh lighttpd.conf |
2 | @grep server.port lighttpd.conf | ||
2 | lighttpd -D -f lighttpd.conf | 3 | lighttpd -D -f lighttpd.conf |
diff --git a/readme b/readme index 0a7764e..0a37b0a 100644 --- a/readme +++ b/readme | |||
@@ -1,15 +1,22 @@ | |||
1 | CACOPHONY | 1 | CACOPHONY |
2 | "Every page a program" | 2 | "Every page a program" |
3 | 3 | ||
4 | This repo contains *cacophony.sh*, a CGI script that will run every script in | 4 | This repo contains *cacophony.sh*, a CGI script that will run every |
5 | the source/ directory as a CGI script to display a page. | 5 | script in the source/ directory as a CGI script to display a page. |
6 | 6 | ||
7 | This is probably a bad idea. It originated mostly on tilde.town. | 7 | This is probably a bad idea. It originated mostly on tilde.town. |
8 | 8 | ||
9 | USAGE | 9 | = USAGE = |
10 | 10 | ||
11 | There's a lighttpd.conf in here for basic testing. Just run `make`. | 11 | There's a lighttpd.conf in here for basic testing. Just run `make`. |
12 | 12 | ||
13 | LICENSE | 13 | = CUSTOMIZATION = |
14 | |||
15 | Check `cacophony.sh` for variables and functions to play around | ||
16 | with. You'll probably want to play with `$SCRIPTDIR` and | ||
17 | `html_footer`, but you could change `http_header` too (or of course | ||
18 | whatever you like). | ||
19 | |||
20 | = LICENSE = | ||
14 | 21 | ||
15 | Public domain \ No newline at end of file | 22 | 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 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # -*- markdown -*- | 2 | # -*- markdown -*- |
3 | echo "<!DOCTYPE html>";pandoc <<EOF;echo "</body></html>" | 3 | echo "<!DOCTYPE html>";pandoc <<EOF |
4 | 4 | ||
5 | # Every page a program | 5 | # Every page a program |
6 | ## an exciting new experiment in web development | 6 | ## an exciting new experiment in web development |
7 | 7 | ||
8 | Er, not really, lol. This is a plain CGI script with shit tacked on. Anyway ... | 8 | Er, not really, lol. This is a plain CGI script with shit tacked on. Anyway ... |
9 | |||
10 | See [the source][]! | ||
11 | |||
12 | [the source]: /source/index | ||