ctucx.git: stagit

ctucx' stagit fork

commit e6c4833f313ceb3f286af5d343703afceebc6549
parent a9157374e77dc9abf01ebf6eeef29e88d590c616
Author: Leah (ctucx) <leah@ctu.cx>
Date: Tue, 24 May 2022 13:00:49 +0200

log: refactor html output
1 file changed, 16 insertions(+), 25 deletions(-)
M
stagit.c
|
41
++++++++++++++++-------------------------
diff --git a/stagit.c b/stagit.c
@@ -816,25 +816,22 @@ printshowfile(FILE *fp, struct commitinfo *ci)
 void
 writelogline(FILE *fp, struct commitinfo *ci)
 {
-	fputs("<tr><td>", fp);
-	if (ci->author)
-		printtimeshort(fp, &(ci->author->when));
-	fputs("</td><td>", fp);
-	if (ci->summary) {
+	fputs("<div class=\"event\">", fp);
+
+	if (ci->author) {
 		fprintf(fp, "<a href=\"%scommit/%s.html\">", relpath, ci->oid);
-		xmlencode(fp, ci->summary, strlen(ci->summary));
-		fputs("</a>", fp);
-	}
-	fputs("</td><td>", fp);
-	if (ci->author)
+		fwrite(ci->short_oid.ptr, sizeof(char), ci->short_oid.size, fp);
+		fputs("</a> - ", fp);
 		xmlencode(fp, ci->author->name, strlen(ci->author->name));
-	fputs("</td><td class=\"num\" align=\"right\">", fp);
-	fprintf(fp, "%zu", ci->filecount);
-	fputs("</td><td class=\"num\" align=\"right\">", fp);
-	fprintf(fp, "+%zu", ci->addcount);
-	fputs("</td><td class=\"num\" align=\"right\">", fp);
-	fprintf(fp, "-%zu", ci->delcount);
-	fputs("</td></tr>\n", fp);
+
+		fputs("<small class=\"right\">", fp);
+		printtimeshort(fp, &(ci->author->when));
+		fputs("</small>", fp);
+	}
+
+	if (ci->summary) fprintf(fp, "<pre>%s</pre>", ci->summary);
+
+	fputs("</div>", fp);
 }
 
 int

@@ -904,9 +901,9 @@ err:
 	git_revwalk_free(w);
 
 	if (nlogcommits == 0 && remcommits != 0) {
-		fprintf(fp, "<tr><td></td><td colspan=\"5\">"
+		fprintf(fp, "<div class=\"event\"><p>"
 		        "%zu more commits remaining, fetch the repository"
-		        "</td></tr>\n", remcommits);
+		        "</p></div>", remcommits);
 	}
 
 	relpath = "";

@@ -1417,11 +1414,6 @@ main(int argc, char *argv[])
 	fp = efopen("log.html", "w");
 	relpath = "";
 	mkdir("commit", S_IRWXU | S_IRWXG | S_IRWXO);
-	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) {

@@ -1464,7 +1456,6 @@ main(int argc, char *argv[])
 			writelog(fp, head);
 	}
 
-	fputs("</tbody></table>", fp);
 	writefooter(fp);
 	checkfileerror(fp, "log.html", 'w');
 	fclose(fp);