stagit

static page generator for git
git clone https://github.com/michaelneuper/stagit.git
README | Files | Log | Refs | LICENSE

commit 85b5a3745aaa121f48d4234e4a54ed0a6af007ea
parent 71ebfbce02f07b026a00d3ab8f6620b359ab5abc
Author: Michael Neuper <michael@michaelneuper.com>
Date:   Sun, 25 Oct 2026 22:19:27 +0200

stagit-index: add -s for a subtitle under the title

build.sh uses it to say the site is a read-only mirror of my public
repositories on GitHub, linking to the account being mirrored.

Diffstat:
Mbuild.sh | 4+++-
Mstagit-index.1 | 8++++++++
Mstagit-index.c | 19+++++++++++++------
Mstyle.css | 4++++
4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/build.sh b/build.sh @@ -99,4 +99,6 @@ set -- while read -r _ repo; do set -- "$@" "$repo" done < "$work/index.lst" -"$root/stagit-index" "$@" > "$out/index.html" +"$root/stagit-index" \ + -s "Read-only mirror of my public repositories on <a href=\"https://github.com/$user\">GitHub</a>." \ + "$@" > "$out/index.html" diff --git a/stagit-index.1 b/stagit-index.1 @@ -6,6 +6,7 @@ .Nd static git index page generator .Sh SYNOPSIS .Nm +.Op Fl s Ar subtitle .Op Ar repodir... .Sh DESCRIPTION .Nm @@ -15,6 +16,13 @@ The repos in the index are in the same order as the arguments .Ar repodir specified. .Pp +The options are as follows: +.Bl -tag -width Ds +.It Fl s Ar subtitle +HTML shown under the title of the page. +It is written as is, not escaped. +.El +.Pp The basename of the directory is used as the repository name. The suffix ".git" is removed from the basename, this suffix is commonly used for "bare" repos. diff --git a/stagit-index.c b/stagit-index.c @@ -16,6 +16,7 @@ static char description[255] = "Repositories"; static char *name = ""; static char owner[255]; static char language[255]; +static const char *subtitle = ""; /* HTML shown under the title, -s */ /* Handle read or write errors for a FILE * stream */ void @@ -108,8 +109,10 @@ writeheader(FILE *fp) fprintf(fp, "<table>\n<tr><td><img src=\"%slogo.png\" alt=\"\" width=\"32\" height=\"32\" /></td>\n" "<td><span class=\"desc\">", relpath); xmlencode(fp, description, strlen(description)); - fputs("</span></td></tr><tr><td></td><td>\n" - "</td></tr>\n</table>\n<hr/>\n<div id=\"content\">\n" + fputs("</span></td></tr><tr><td></td><td>\n", fp); + if (subtitle[0]) + fprintf(fp, "<span class=\"subtitle\">%s</span>\n", subtitle); + fputs("</td></tr>\n</table>\n<hr/>\n<div id=\"content\">\n" "<table id=\"index\"><thead>\n" "<tr><td><b>Name</b></td><td><b>Description</b></td><td><b>Language</b></td><td><b>Owner</b></td>" "<td><b>Last commit</b></td></tr>" @@ -179,10 +182,14 @@ main(int argc, char *argv[]) FILE *fp; char path[PATH_MAX], repodirabs[PATH_MAX + 1]; const char *repodir; - int i, ret = 0; + int i, first = 1, ret = 0; - if (argc < 2) { - fprintf(stderr, "usage: %s [repodir...]\n", argv[0]); + if (argc > 2 && !strcmp(argv[1], "-s")) { + subtitle = argv[2]; + first = 3; + } + if (argc <= first || argv[first][0] == '-') { + fprintf(stderr, "usage: %s [-s subtitle] [repodir...]\n", argv[0]); return 1; } @@ -201,7 +208,7 @@ main(int argc, char *argv[]) writeheader(stdout); - for (i = 1; i < argc; i++) { + for (i = first; i < argc; i++) { repodir = argv[i]; if (!realpath(repodir, repodirabs)) err(1, "realpath"); diff --git a/style.css b/style.css @@ -79,6 +79,10 @@ h1 { color: var(--fg); } +.subtitle { + color: var(--muted); +} + tr.url td { color: var(--muted); overflow-wrap: anywhere;