about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCase Duckworth2023-06-02 14:15:42 -0500
committerCase Duckworth2023-06-02 14:15:42 -0500
commitb426388561fd1d0379674abb55f6024e26dd20b7 (patch)
treea6156d5ae5b3daf54abc52e77089aaa4a10f04e2
parentUpdate readme (diff)
downloadcacophony-b426388561fd1d0379674abb55f6024e26dd20b7.tar.gz
cacophony-b426388561fd1d0379674abb55f6024e26dd20b7.zip
Change function names; update README and MAKEFILE
-rwxr-xr-xcacophony.sh23
-rw-r--r--makefile1
-rw-r--r--readme23
-rwxr-xr-xsource/index6
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
3SCRIPTDIR=source 4SCRIPTDIR=source
4 5
@@ -7,7 +8,7 @@ crlf() { # crlf < INPUT
7 sed 's/$/ /g' 8 sed 's/$/ /g'
8} 9}
9 10
10header() { # header [STATUS] 11http_header() { # header [STATUS]
11 cat <<HEADER | crlf 12 cat <<HEADER | crlf
12HTTP/1.1 ${1:-200} 13HTTP/1.1 ${1:-200}
13Content-Type: text/html;charset=utf-8 14Content-Type: text/html;charset=utf-8
@@ -15,20 +16,32 @@ Content-Type: text/html;charset=utf-8
15HEADER 16HEADER
16} 17}
17 18
19html_footer() { # footer PROGRAM
20 cat <<EOF
21<footer>
22copyright (C) $(stat -c %y "$1" | cut -d- -f1) Case Duckworth.
23this page is a <a href="$SCRIPTDIR/${1##*/}">program</a>
24served by <a href="https://git.acdw.net/cacophony">cacophony</a>.
25</footer>
26</body></html>
27EOF
28}
29
18hexec() { # hexec PROGRAM [header args] 30hexec() { # 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
24run() { 37run() { # 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 @@
1serve: cacophony.sh lighttpd.conf 1serve: 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 @@
1CACOPHONY 1 CACOPHONY
2"Every page a program" 2 "Every page a program"
3 3
4This repo contains *cacophony.sh*, a CGI script that will run every script in 4This repo contains *cacophony.sh*, a CGI script that will run every
5the source/ directory as a CGI script to display a page. 5script in the source/ directory as a CGI script to display a page.
6 6
7This is probably a bad idea. It originated mostly on tilde.town. 7This is probably a bad idea. It originated mostly on tilde.town.
8 8
9USAGE 9= USAGE =
10 10
11There's a lighttpd.conf in here for basic testing. Just run `make`. 11There's a lighttpd.conf in here for basic testing. Just run `make`.
12 12
13LICENSE 13= CUSTOMIZATION =
14
15Check `cacophony.sh` for variables and functions to play around
16with. You'll probably want to play with `$SCRIPTDIR` and
17`html_footer`, but you could change `http_header` too (or of course
18whatever you like).
19
20= LICENSE =
14 21
15Public domain \ No newline at end of file 22Public 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 -*-
3echo "<!DOCTYPE html>";pandoc <<EOF;echo "</body></html>" 3echo "<!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
8Er, not really, lol. This is a plain CGI script with shit tacked on. Anyway ... 8Er, not really, lol. This is a plain CGI script with shit tacked on. Anyway ...
9
10See [the source][]!
11
12[the source]: /source/index