commit 1becf8119516c60c4f6a2dd73133889d5b54e87f
parent b09e5c6200cf3ef21b002b24215737b5ecce9d81
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 23 May 2022 22:54:40 +0200
parent b09e5c6200cf3ef21b002b24215737b5ecce9d81
Author: Leah (ctucx) <leah@ctu.cx>
Date: Mon, 23 May 2022 22:54:40 +0200
writeheader: implement mode argument
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/stagit.c b/stagit.c @@ -541,7 +541,7 @@ static const char } void -writeheader(FILE *fp, const char *title) +writeheader(FILE *fp, const char *title, const char *mode) { fputs("<!DOCTYPE html>\n" "<html>\n<head>\n" @@ -862,8 +862,8 @@ writelog(FILE *fp, const git_oid *oid) if (r) { relpath = "../"; fpfile = efopen(path, "w"); - writeheader(fpfile, ci->summary); fputs("<pre>", fpfile); + writeheader(fpfile, ci->summary, "log"); printshowfile(fpfile, ci); fputs("</pre>\n", fpfile); writefooter(fpfile); @@ -931,8 +931,8 @@ writeblob(git_object *obj, const char *fpath, const char *rpath, const char *fil relpath = tmp; fp = efopen(fpath, "w"); - writeheader(fp, filename); fputs("<p> ", fp); + writeheader(fp, filename, "tree"); xmlencode(fp, filename, strlen(filename)); fprintf(fp, " (%zuB)", filesize); fprintf(fp, " - <a href=\"%s%s\">raw</a></p><hr/>", relpath, rpath); @@ -1073,7 +1073,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path) strlcpy(tmp2, "tree - ", sizeof(tmp2)); if (strlcat(tmp2, entrypath, sizeof(tmp2)) >= sizeof(tmp2)) errx(1, "path truncated: '%s'", tmp2); - writeheader(fp_subtree, tmp2); + writeheader(fp_subtree, tmp2, "tree"); /* NOTE: recurses */ ret = writefilestree(fp_subtree, (git_tree *)obj, entrypath); @@ -1353,7 +1353,7 @@ main(int argc, char *argv[]) /* about page */ if (readme) { fp = efopen("about.html", "w"); - writeheader(fp, "About"); + writeheader(fp, "about", "about"); git_revparse_single(&obj, repo, readmefiles[r]); const char *s = git_blob_rawcontent((git_blob *)obj); if (r == 1 | r == 2) { @@ -1377,12 +1377,12 @@ main(int argc, char *argv[]) fp = efopen("log.html", "w"); relpath = ""; mkdir("commit", S_IRWXU | S_IRWXG | S_IRWXO); - writeheader(fp, "Log"); 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>" "<td class=\"num\" align=\"right\"><b>+</b></td>" "<td class=\"num\" align=\"right\"><b>-</b></td></tr>\n</thead><tbody>\n", fp); + writeheader(fp, "log", "log"); if (cachefile && head) { /* read from cache file (does not need to exist) */ @@ -1431,7 +1431,7 @@ main(int argc, char *argv[]) /* files for HEAD */ fp = efopen("tree.html", "w"); - writeheader(fp, "tree"); + writeheader(fp, "tree", "tree"); if (head) writefiles(fp, head); writefooter(fp); @@ -1440,7 +1440,7 @@ main(int argc, char *argv[]) /* summary page with branches and tags */ fp = efopen("refs.html", "w"); - writeheader(fp, "Refs"); + writeheader(fp, "refs", "refs"); writerefs(fp); writefooter(fp); checkfileerror(fp, "refs.html", 'w');