stagit

static git page generator
git clone https://git.awy.one/stagit
Log | Files | Refs | README | LICENSE

commit 102253bdf0bd9573ed2489c6d9ae2a2202015af9
parent 3d5531f6c10ae36ca34a69f78a8974f3adfafcc3
Author: awy <awy@awy.one>
Date:   Fri, 10 Apr 2026 22:26:41 +0300

show readme preview on repo files view

Diffstat:
Mstagit.c | 26++++++++++++++++++++++++++
1 file changed, 26 insertions(+), 0 deletions(-)

diff --git a/stagit.c b/stagit.c @@ -562,6 +562,7 @@ writeheader(FILE *fp, const char *title) fprintf(fp, " | <a href=\"%sfile/%s.html\">LICENSE</a>", relpath, license); fputs("</td></tr></table>\n<hr/>\n<div id=\"content\">\n", fp); + fputs("</div>\n", fp); } void @@ -838,6 +839,7 @@ writelog(FILE *fp, const git_oid *oid) relpath = "../"; fpfile = efopen(path, "w"); writeheader(fpfile, ci->summary); + fputs("<hr/>\n<div id=\"content\">\n", fpfile); fputs("<pre>", fpfile); printshowfile(fpfile, ci); fputs("</pre>\n", fpfile); @@ -1014,6 +1016,7 @@ writeblob(git_object *obj, const char *fpath, const char *rpath, const char *fil xmlencode(fp, filename, strlen(filename)); fprintf(fp, " (%zuB)", filesize); fprintf(fp, " - <a href=\"%s%s\">raw</a></p><hr/>", relpath, rpath); + fputs("<div id=\"content\">\n", fp); if (git_blob_is_binary((git_blob *)obj)) { @@ -1163,6 +1166,9 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) if (strlcat(tmp2, entrypath, sizeof(tmp2)) >= sizeof(tmp2)) errx(1, "path truncated: '%s'", tmp2); writeheader(fp_subtree, tmp2); + /* fputs("<hr/>\n", fp_subtree); */ + fputs("<div id=\"content\">\n", fp_subtree); + /* NOTE: recurses */ ret = writefilestree(fp_subtree, (git_tree *)obj, entrypath); @@ -1518,6 +1524,7 @@ main(int argc, char *argv[]) relpath = ""; mkdir("commit", S_IRWXU | S_IRWXG | S_IRWXO); writeheader(fp, "Log"); + fputs("<hr/>\n<div id=\"content\">\n", fp); fputs("<table id=\"log\"><thead>\n<tr><td><b>Date</b></td>" "<td><b>Commit message</b></td>" "<td><b>Author</b></td><td class=\"num\" align=\"right\"><b>Files</b></td>" @@ -1574,6 +1581,24 @@ main(int argc, char *argv[]) writeheader(fp, "Files"); if (head) writefiles(fp, head); + if (readme) { + fputs("<hr>", fp); + git_revparse_single(&obj, repo, readmefiles[r]); + const char *s = git_blob_rawcontent((git_blob *)obj); + if (r == 1) { + git_off_t len = git_blob_rawsize((git_blob *)obj); + fputs("<div id=\"readme\">", fp); + if (md_html(s, len, process_output_md, fp, MD_FLAG_TABLES | MD_FLAG_TASKLISTS | + MD_FLAG_PERMISSIVEEMAILAUTOLINKS | MD_FLAG_PERMISSIVEURLAUTOLINKS, 0)) + err(1, "error parsing markdown"); + fputs("</div>\n", fp); + } else { + fputs("<pre id=\"readme\">", fp); + xmlencode(fp, s, strlen(s)); + fputs("</pre>\n", fp); + } + git_object_free(obj); + } writefooter(fp); checkfileerror(fp, "files.html", 'w'); fclose(fp); @@ -1581,6 +1606,7 @@ main(int argc, char *argv[]) /* summary page with branches and tags */ fp = efopen("refs.html", "w"); writeheader(fp, "Refs"); + fputs("<hr/>\n<div id=\"content\">\n", fp); writerefs(fp); writefooter(fp); checkfileerror(fp, "refs.html", 'w');