diff options
Diffstat (limited to '')
-rw-r--r-- | www/git.causal.agency/.gitignore | 13 | ||||
-rw-r--r-- | www/git.causal.agency/Makefile | 53 | ||||
-rw-r--r-- | www/git.causal.agency/cgitrc | 30 | ||||
-rw-r--r-- | www/git.causal.agency/custom.css | 86 | ||||
-rw-r--r-- | www/git.causal.agency/filter.c | 158 | ||||
-rw-r--r-- | www/git.causal.agency/index.7 | 81 |
6 files changed, 421 insertions, 0 deletions
diff --git a/www/git.causal.agency/.gitignore b/www/git.causal.agency/.gitignore new file mode 100644 index 00000000..eaed8039 --- /dev/null +++ b/www/git.causal.agency/.gitignore @@ -0,0 +1,13 @@ +*.html +about-filter +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 new file mode 100644 index 00000000..86b9f3eb --- /dev/null +++ b/www/git.causal.agency/Makefile @@ -0,0 +1,53 @@ +PREFIX = /var/www +CONFDIR = ${PREFIX}/conf +DATADIR = ${PREFIX}/cgit +BINDIR = ${PREFIX}/bin +WEBROOT = ${PREIFX}/git.causal.agency + +CFLAGS += -Wall -Wextra +LDFLAGS = -static -pie + +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 $@ + +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 compress filter ${BINS} ${HTMLS} diff --git a/www/git.causal.agency/cgitrc b/www/git.causal.agency/cgitrc new file mode 100644 index 00000000..0666fd28 --- /dev/null +++ b/www/git.causal.agency/cgitrc @@ -0,0 +1,30 @@ +root-title=causal agency +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 + +enable-blame=1 +enable-commit-graph=1 +enable-subject-links=1 +enable-follow-links=1 +enable-index-owner=0 +repository-sort=age +branch-sort=age + +css=/custom.css +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=/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 new file mode 100644 index 00000000..b3f4f425 --- /dev/null +++ b/www/git.causal.agency/custom.css @@ -0,0 +1,86 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +@import url("cgit.css"); + +* { line-height: 1.25em; } + +div#cgit { + max-width: 117ch; + margin: auto; + font-family: monospace; + -moz-tab-size: 4; + tab-size: 4; +} + +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; +} +div#cgit div.content { + border-bottom: none; +} +div#cgit table.list th a { + color: inherit; +} +div#cgit table.list tr:nth-child(even) { + background: inherit; +} +div#cgit table.list tr:hover { + background: inherit; +} +div#cgit table.list tr.nohover-highlight:hover:nth-child(even) { + background: inherit; +} + +div#cgit table.blob td.linenumbers a:target { + color: goldenrod; + text-decoration: underline; + outline: none; +} + +div#cgit div#summary { + max-width: 80ch; +} + +/* 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; } + +/* for mandoc(1) */ +table.head, table.foot { width: 100%; } +td.head-rtitle, td.foot-os { text-align: right; } +td.head-vol { text-align: center; } +div.Pp { margin: 1ex 0ex; } +div.Nd, div.Bf, div.Op { display: inline; } +span.Pa, span.Ad { font-style: italic; } +span.Ms { font-weight: bold; } +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; } +div.Bd-indent { margin-left: 4ch; } +table.Bl-column { width: 100%; } +table.foot { margin-top: 1em; } + +div#cgit a.permalink { color: inherit; } 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 |