summary refs log tree commit diff
path: root/www/git.causal.agency
diff options
context:
space:
mode:
Diffstat (limited to 'www/git.causal.agency')
-rw-r--r--www/git.causal.agency/.gitignore12
-rw-r--r--www/git.causal.agency/Makefile61
-rw-r--r--www/git.causal.agency/about-filter.sh10
-rw-r--r--www/git.causal.agency/cgitrc13
-rw-r--r--www/git.causal.agency/custom.css36
-rw-r--r--www/git.causal.agency/filter.c158
-rw-r--r--www/git.causal.agency/index.781
-rw-r--r--www/git.causal.agency/source-filter.sh3
8 files changed, 324 insertions, 50 deletions
diff --git a/www/git.causal.agency/.gitignore b/www/git.causal.agency/.gitignore
index 8d20f25d..eaed8039 100644
--- a/www/git.causal.agency/.gitignore
+++ b/www/git.causal.agency/.gitignore
@@ -1,3 +1,13 @@
+*.html
 about-filter
-hi
+compress
+ctags
+email-filter
+filter
+gzip
+hilex
+htagml
+mandoc
+mtags
+owner-filter
 source-filter
diff --git a/www/git.causal.agency/Makefile b/www/git.causal.agency/Makefile
index 28e08ba5..86b9f3eb 100644
--- a/www/git.causal.agency/Makefile
+++ b/www/git.causal.agency/Makefile
@@ -1,18 +1,53 @@
-ETC = /usr/local/etc
-WWW = /usr/local/www/cgit
-LIBEXEC = /usr/local/libexec
+PREFIX = /var/www
+CONFDIR = ${PREFIX}/conf
+DATADIR = ${PREFIX}/cgit
+BINDIR = ${PREFIX}/bin
+WEBROOT = ${PREIFX}/git.causal.agency
 
-BIN = ../../bin
-BINS = about-filter source-filter hi
+CFLAGS += -Wall -Wextra
+LDFLAGS = -static -pie
 
-install: cgitrc custom.css ${BINS}
-	install -m 644 cgitrc ${ETC}
-	install -m 644 custom.css ${WWW}
-	install ${BINS} ${LIBEXEC}
+BINS += about-filter
+BINS += ctags
+BINS += email-filter
+BINS += gzip
+BINS += hilex
+BINS += htagml
+BINS += mandoc
+BINS += mtags
+BINS += owner-filter
+BINS += source-filter
+
+HTMLS = index.html
+
+all: ${BINS} ${HTMLS}
+
+compress ctags mandoc:
+	${MAKE} -C /usr/src/usr.bin/$@ LDFLAGS='${LDFLAGS}'
+	mv /usr/src/usr.bin/$@/$@ $@
+	${MAKE} -C /usr/src/usr.bin/$@ clean
+
+gzip: compress
+	ln -f compress $@
 
-hi: ${BIN}/hi.c
-	${MAKE} -C ${BIN} $@
-	cp ${BIN}/$@ $@
+hilex htagml mtags:
+	rm -f ../../bin/$@
+	${MAKE} -C ../../bin $@ LDFLAGS='${LDFLAGS}'
+	mv ../../bin/$@ $@
+
+about-filter email-filter owner-filter source-filter: filter
+	ln -f filter $@
+
+index.html: index.7
+	mandoc -Thtml -Ostyle=https://causal.agency/style.css index.7 >index.html
+
+install: cgitrc custom.css ${BINS}
+	install -m 644 cgitrc ${CONFDIR}
+	install -m 644 custom.css ${DATADIR}
+	install -d -o www -g daemon ${PREFIX}/cache/cgit
+	install -d -m 1700 -o www -g daemon ${PREFIX}/tmp
+	install -s ${BINS} ${BINDIR}
+	install -m 644 ${HTMLS} ${WEBROOT}
 
 clean:
-	rm -f ${BINS}
+	rm -f compress filter ${BINS} ${HTMLS}
diff --git a/www/git.causal.agency/about-filter.sh b/www/git.causal.agency/about-filter.sh
deleted file mode 100644
index ea68fe05..00000000
--- a/www/git.causal.agency/about-filter.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh
-
-case "$1" in
-	(*.[1-9])
-		exec /usr/bin/mandoc -T html -O fragment,man=%N.%S,includes=../tree/%I
-		;;
-	(*)
-		exec /usr/local/libexec/hi -l text -f html
-		;;
-esac
diff --git a/www/git.causal.agency/cgitrc b/www/git.causal.agency/cgitrc
index c187e1ee..0666fd28 100644
--- a/www/git.causal.agency/cgitrc
+++ b/www/git.causal.agency/cgitrc
@@ -1,5 +1,6 @@
 root-title=causal agency
-root-desc=“then I'm sorry, no offence, but you write toy programs.”
+root-desc=“I think some people from the Gentoo project are behind this.”
+logo=
 
 clone-url=https://$HTTP_HOST/$CGIT_REPO_URL
 snapshots=tar.gz zip
@@ -13,15 +14,17 @@ repository-sort=age
 branch-sort=age
 
 css=/custom.css
-email-filter=/usr/local/libexec/cgit-email
-about-filter=/usr/local/libexec/about-filter
-source-filter=/usr/local/libexec/source-filter
+about-filter=/bin/about-filter
+source-filter=/bin/source-filter
+#owner-filter=/bin/owner-filter
+email-filter=/bin/email-filter
 
 readme=:README.7
 readme=:README
 
 remove-suffix=1
 enable-git-config=1
-scan-path=/home/june/pub
+scan-path=/git.causal.agency
 
+cache-root=/cache/cgit
 cache-size=1024
diff --git a/www/git.causal.agency/custom.css b/www/git.causal.agency/custom.css
index 80892b36..b3f4f425 100644
--- a/www/git.causal.agency/custom.css
+++ b/www/git.causal.agency/custom.css
@@ -14,12 +14,12 @@ div#cgit {
 	tab-size: 4;
 }
 
-div#cgit table#header td.logo {
-	display: none;
-}
 div#cgit table#header td.sub {
 	border-top: none;
 }
+div#cgit table#header td.sub.right {
+	padding-right: 1em;
+}
 div#cgit table.tabs {
 	border-bottom: none;
 }
@@ -49,20 +49,19 @@ div#cgit div#summary {
 	max-width: 80ch;
 }
 
-/* from hi(1) */
-div#cgit .hi.Keyword { color: dimgray; }
-div#cgit .hi.Macro { color: green; }
-div#cgit .hi.Tag { color: inherit; text-decoration: underline; }
-div#cgit .hi.String { color: teal; }
-div#cgit .hi.Format { color: teal; font-weight: bold; }
-div#cgit .hi.Interp { color: olive; }
-div#cgit .hi.Comment { color: navy; }
-div#cgit .hi.Todo { color: navy; font-weight: bold; }
-div#cgit .hi.DiffOld { color: red; }
-div#cgit .hi.DiffNew { color: green; }
-div#cgit .hi.Tag:target { color: goldenrod; outline: none; }
+/* for hilex(1) */
+div#cgit pre .Ke { color: dimgray; }
+div#cgit pre .Ma { color: green; }
+div#cgit pre .Co { color: navy; }
+div#cgit pre .St { color: teal; }
+div#cgit pre .Fo { color: teal; font-weight: bold; }
+div#cgit pre .Su { color: olive; }
+
+/* for htagml(1) */
+div#cgit pre a.tag { color: inherit; text-decoration: underline; }
+div#cgit pre a.tag:target { color: goldenrod; outline: none; }
 
-/* from mandoc(1) */
+/* for mandoc(1) */
 table.head, table.foot { width: 100%; }
 td.head-rtitle, td.foot-os { text-align: right; }
 td.head-vol { text-align: center; }
@@ -74,11 +73,12 @@ dl.Bl-diag > dt { font-weight: bold; }
 code.Nm, code.Fl, code.Cm, code.Ic, code.In, code.Fd, code.Fn,
 code.Cd { font-weight: bold; font-family: inherit; }
 
+h1.Sh { font-size: 1.5em; }
 table.Nm td:first-child { padding-right: 1ch; }
 code.Fl { white-space: nowrap; }
 span.RsT { font-style: italic; }
-dl.Bl-tag:not(.Bl-compact) dt { margin-top: 1em; }
-ul.Bl-bullet:not(.Bl-compact) li { margin-top: 1em; }
+dl.Bl-tag:not(.Bl-compact) > dt { margin-top: 1em; }
+ul.Bl-bullet:not(.Bl-compact) > li { margin-top: 1em; }
 div.Bd-indent { margin-left: 4ch; }
 table.Bl-column { width: 100%; }
 table.foot { margin-top: 1em; }
diff --git a/www/git.causal.agency/filter.c b/www/git.causal.agency/filter.c
new file mode 100644
index 00000000..7c7e9320
--- /dev/null
+++ b/www/git.causal.agency/filter.c
@@ -0,0 +1,158 @@
+#include <err.h>
+#include <fcntl.h>
+#include <fnmatch.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#define Q(...) #__VA_ARGS__
+
+#define MANDOC_OPTIONS "fragment,man=%N.%S,includes=../tree/%I"
+
+static int about(int argc, char *argv[]) {
+	if (argc < 2) return 1;
+	if (!fnmatch("README.[1-9]", argv[1], 0)) {
+		execlp("mandoc", "mandoc", "-T", "html", "-O", MANDOC_OPTIONS, NULL);
+		err(127, "mandoc");
+	} else if (!fnmatch("*.[1-9]", argv[1], 0)) {
+		execlp(
+			"mandoc", "mandoc", "-T", "html", "-O", "toc," MANDOC_OPTIONS, NULL
+		);
+		err(127, "mandoc");
+	} else {
+		execlp("hilex", "hilex", "-l", "text", "-f", "html", "-o", "pre", NULL);
+		err(127, "hilex");
+	}
+}
+
+static int email(void) {
+	size_t cap = 0;
+	char *buf = NULL;
+	if (getline(&buf, &cap, stdin) < 0) err(1, "getline");
+	if (buf[0] == 'C' && !strncmp(&buf[strcspn(buf, " ")], " McEnroe", 8)) {
+		printf("June%s", &buf[strcspn(buf, " ")]);
+	} else {
+		printf("%s", buf);
+	}
+	return 0;
+}
+
+static int owner(void) {
+	printf(Q(<a href="https://liberapay.com/june/donate"><img alt="Donate using Liberapay" src="https://liberapay.com/assets/widgets/donate.svg"></a>));
+	return 0;
+}
+
+#define CTAGS_PATTERN "*.[chlmy]"
+#define TEMPLATE "/tmp/filter.XXXXXXXXXX"
+
+static char tmp[PATH_MAX];
+static char tags[] = TEMPLATE;
+static void cleanup(void) {
+	unlink(tmp);
+	unlink(tags);
+}
+
+static int source(int argc, char *argv[]) {
+	if (argc < 2) return 1;
+	if (
+		strcmp("Makefile", argv[1]) &&
+		strcmp(".profile", argv[1]) &&
+		strcmp(".shrc", argv[1]) &&
+		fnmatch(CTAGS_PATTERN, argv[1], 0) &&
+		fnmatch("*.mk", argv[1], 0) &&
+		fnmatch("*.[1-9]", argv[1], 0) &&
+		fnmatch("*.sh", argv[1], 0)
+	) {
+		execlp("hilex", "hilex", "-t", "-n", argv[1], "-f", "html", NULL);
+		err(127, "hilex");
+	}
+
+	const char *ext = strrchr(argv[1], '.');
+	if (!strcmp(argv[1], ".profile") || !strcmp(argv[1], ".shrc")) {
+		ext = ".sh";
+	} else if (!strcmp(argv[1], "Makefile")) {
+		ext = ".mk";
+	} else if (!ext) {
+		ext = "";
+	}
+
+	snprintf(tmp, sizeof(tmp), TEMPLATE "%s", ext);
+	int fd = mkstemps(tmp, strlen(ext));
+	if (fd < 0) err(1, "%s", tmp);
+	atexit(cleanup);
+
+	char buf[4096];
+	for (ssize_t len; 0 < (len = read(STDIN_FILENO, buf, sizeof(buf)));) {
+		if (write(fd, buf, len) < 0) err(1, "%s", tmp);
+	}
+	if (close(fd) < 0) err(1, "%s", tmp);
+
+	fd = mkstemp(tags);
+	if (fd < 0) err(1, "%s", tags);
+	close(fd);
+	pid_t pid = fork();
+	if (pid < 0) err(1, "fork");
+	if (!pid) {
+		if (!fnmatch(CTAGS_PATTERN, argv[1], 0)) {
+			execlp("ctags", "ctags", "-w", "-f", tags, tmp, NULL);
+			warn("ctags");
+		} else {
+			execlp("mtags", "mtags", "-f", tags, tmp, NULL);
+			warn("mtags");
+		}
+		_exit(127);
+	}
+	int status;
+	if (wait(&status) < 0) err(1, "wait");
+
+	int rw[2];
+	if (pipe(rw) < 0) err(1, "pipe");
+	pid = fork();
+	if (pid < 0) err(1, "fork");
+	if (!pid) {
+		dup2(rw[1], STDOUT_FILENO);
+		close(rw[0]);
+		close(rw[1]);
+		execlp("hilex", "hilex", "-f", "html", tmp, NULL);
+		warn("hilex");
+		_exit(127);
+	}
+	pid = fork();
+	if (pid < 0) err(1, "fork");
+	if (!pid) {
+		dup2(rw[0], STDIN_FILENO);
+		close(rw[0]);
+		close(rw[1]);
+		execlp("htagml", "htagml", "-im", "-f", tags, tmp, NULL);
+		warn("htagml");
+		_exit(127);
+	}
+	close(rw[0]);
+	close(rw[1]);
+
+	if (wait(&status) < 0) err(1, "wait");
+	if (wait(&status) < 0) err(1, "wait");
+	return status;
+}
+
+int main(int argc, char *argv[]) {
+#ifdef __OpenBSD__
+	int error;
+	switch (getprogname()[0]) {
+		break; case 'a': error = pledge("stdio exec", NULL);
+		break; case 's': error = pledge("stdio tmppath proc exec", NULL);
+		break; default:  error = pledge("stdio", NULL);
+	}
+	if (error) err(1, "pledge");
+#endif
+	switch (getprogname()[0]) {
+		case 'a': return about(argc, argv);
+		case 'e': return email();
+		case 'o': return owner();
+		case 's': return source(argc, argv);
+		default: return 1;
+	}
+}
diff --git a/www/git.causal.agency/index.7 b/www/git.causal.agency/index.7
new file mode 100644
index 00000000..58a40dfe
--- /dev/null
+++ b/www/git.causal.agency/index.7
@@ -0,0 +1,81 @@
+.Dd January 12, 2024
+.Dt GIT.CAUSAL.AGENCY 7
+.Os "Causal Agency"
+.
+.Sh NAME
+.Nm causal agency
+.Nd \(dqI think some people from the Gentoo project are behind this.\(dq
+.
+.Sh DESCRIPTION
+basically cgit (awful software)
+getting hammered by web crawlers
+keeps making my machine crash.
+this static page will be here
+until I can find a better solution.
+clone urls and tarball urls are still functional.
+.
+.Bl -tag
+.It src \(em dontfiles
+.Dl git clone https://git.causal.agency/src
+.It ascii.town
+.Bl -tag
+.It torus \(em collaborative ASCII art
+.Dl git clone https://git.causal.agency/torus
+.It play \(em some games for SSH
+.Dl git clone https://git.causal.agency/play
+.El
+.It email
+.Bl -tag
+.It imbox \(em IMAP to mbox
+.Dl git clone https://git.causal.agency/imbox
+.It bubger \(em IMAP archive generator
+.Dl git clone https://git.causal.agency/bubger
+.It notemap \(em notemap
+.Dl git clone https://git.causal.agency/notemap
+.El
+.It forks
+.Bl -tag
+.It shulker \(em Discord to vanilla Minecraft bridge
+.Dl git clone https://git.causal.agency/shulker
+.It cgit-pink \(em web frontend for git
+.Dl git clone https://git.causal.agency/cgit-pink
+.It dash \(em patched shell with cmake build
+.Dl git clone https://git.causal.agency/dash
+.El
+.It games
+.Bl -tag
+.It wep \(em Windows Entertainment Pack recreations
+.Dl git clone https://git.causal.agency/wep
+.It cards \(em CARDS.DLL loader for SDL
+.Dl git clone https://git.causal.agency/cards
+.El
+.It irc
+.Bl -tag
+.It scooper \(em web interface for litterbox
+.Dl git clone https://git.causal.agency/scooper
+.It litterbox \(em IRC logger
+.Dl git clone https://git.causal.agency/litterbox
+.It pounce \(em IRC bouncer
+.Dl git clone https://git.causal.agency/pounce
+.It catgirl \(em IRC client
+.Dl git clone https://git.causal.agency/catgirl
+.El
+.It ports
+.Bl -tag
+.It jorts \(em my own ports tree for macOS
+.Dl git clone https://git.causal.agency/jorts
+.It exman \(em manuals for other systems
+.Dl git clone https://git.causal.agency/exman
+.It libretls \(em libtls for OpenSSL
+.Dl git clone https://git.causal.agency/libretls
+.It ports \(em Fx and Ox ports for this software
+.Dl git clone https://git.causal.agency/ports
+.El
+.It system
+.Bl -tag
+.It kitd \(em process supervisor for OpenBSD
+.Dl git clone https://git.causal.agency/kitd
+.It catsit \(em (deprecated) process supervisor
+.Dl git clone https://git.causal.agency/catsit
+.El
+.El
diff --git a/www/git.causal.agency/source-filter.sh b/www/git.causal.agency/source-filter.sh
deleted file mode 100644
index 4febc2e0..00000000
--- a/www/git.causal.agency/source-filter.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-exec /usr/local/libexec/hi -t -n "$1" -f html -o anchor