stagit

static git page - forked from https://git.codemadness.org/stagit
git clone git://src.gearsix.net/stagitstagit.zip
Log | Files | Refs | Atom | README | LICENSE

commit fcd56021e524747af0db27cb565d7be2c541a661
parent c9917b1e795773bf9c90ccce48d510fd0d307a5f
Author: gearsix <gearsix@tuta.io>
Date:   Wed, 19 Feb 2025 22:36:17 +0000

added a system zip command & link to the zipped file

It requires 'ZIP' to be defined in the build flags.

style-gearsix: insert/delete in diffs are *readable*

Diffstat:
Mstagit.c | 35++++++++++++++++++++++++++++-------
Mstyle-gearsix.css | 12++++++++++++
2 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/stagit.c b/stagit.c @@ -74,6 +74,7 @@ static char *license; static char *readmefiles[] = { "HEAD:README", "HEAD:README.md" }; static char *readme; static long long nlogcommits = -1; /* -1 indicates not used */ +static int zipped = 0; /* cache */ static git_oid lastoid; @@ -521,23 +522,32 @@ writeheader(FILE *fp, const char *title) xmlencode(fp, name, strlen(name)); fprintf(fp, " Atom Feed (tags)\" href=\"%stags.xml\" />\n", relpath); fprintf(fp, "<link rel=\"stylesheet\" type=\"text/css\" href=\"%sstyle.css\" />\n", rootpath); - fputs("</head>\n<body>\n<table><tr><td id=\"logo\" rowspan=3>", fp); + fputs("</head>\n<body>\n<table><tr><td id=\"logo\" rowspan=\"3\">", fp); fprintf(fp, "<a href=\"../%s\"><img src=\"%slogo.png\" alt=\"\" width=\"75px\" height=\"75px\" /></a>", relpath, rootpath); - fputs("</td><td><h1>", fp); + fputs("</td><td colspan=\"2\"><h1>", fp); xmlencode(fp, strippedname, strlen(strippedname)); fputs("</h1><span class=\"desc\">", fp); xmlencode(fp, description, strlen(description)); fputs(forked, fp); fputs("</span></td></tr>", fp); + fputs("<tr class=\"url\">", fp); if (cloneurl[0]) { - fputs("<tr class=\"url\"><td>git clone <a href=\"", fp); + fputs("<td>git clone <a href=\"", fp); xmlencode(fp, cloneurl, strlen(cloneurl)); /* not percent-encoded */ fputs("\">", fp); xmlencode(fp, cloneurl, strlen(cloneurl)); - fputs("</a></td></tr>", fp); + fputs("</a></td>", fp); } - fputs("<tr><td>\n", fp); + if (zipped) { + fputs("<td><a href=\"", fp); + xmlencode(fp, strippedname, strlen(strippedname)); + fputs(".zip\">", fp); + xmlencode(fp, strippedname, strlen(strippedname)); + fputs(".zip</a></td>", fp); + } + fputs("</td></tr>", fp); + fputs("<tr><td colspan=\"2\">\n", fp); fprintf(fp, "<a href=\"%slog.html\">Log</a> | ", relpath); fprintf(fp, "<a href=\"%sfiles.html\">Files</a> | ", relpath); fprintf(fp, "<a href=\"%srefs.html\">Refs</a> | ", relpath); @@ -1306,6 +1316,18 @@ main(int argc, char *argv[]) if (!strcmp(p, ".git")) *p = '\0'; +#ifdef ZIP + snprintf(path, sizeof(path), "zip -q -r %s.zip %s", name, repodir); + system(path); + snprintf(path, sizeof(path), "%s.zip", name); + if (!(fpread = efopen(path, "r"))) { + checkfileerror(fpread, path, 'r'); + fclose(fpread); + } else { + zipped = 1; + } +#endif + /* read description or .git/description */ joinpath(path, sizeof(path), repodir, "description"); if (!(fpread = fopen(path, "r"))) { @@ -1428,8 +1450,7 @@ main(int argc, char *argv[]) /* files for HEAD */ fp = efopen("files.html", "w"); writeheader(fp, "Files"); - if (head) - writefiles(fp, head); + if (head) writefiles(fp, head); writefooter(fp); checkfileerror(fp, "files.html", 'w'); fclose(fp); diff --git a/style-gearsix.css b/style-gearsix.css @@ -9,6 +9,18 @@ body { a { color: #8dc; } +a.h { + color: #fff; +} +a.i { + color: #8d8; +} +a.d { + color: #d88; +} +a.h, a.i, a.d { + text-decoration: none; +} a:hover { text-shadow: 1px 1px 5px #8dc; }