ctucx.git: stagit

ctucx' stagit fork

commit 0fcec908dcb79e7e28656923e42e479b0682ed13
parent 664a66173c9fcc3d62417f512eed3a9be2a582a2
Author: Leah (ctucx) <git@ctu.cx>
Date: Mon, 15 May 2023 12:45:24 +0200

stagit, stagit-index: responsiveness fix for tables
3 files changed, 12 insertions(+), 8 deletions(-)
M
stagit-index.c
|
4
++--
M
stagit.c
|
12
++++++------
M
style.css
|
4
++++
diff --git a/stagit-index.c b/stagit-index.c
@@ -111,7 +111,7 @@ writeheader(FILE *fp)
 	xmlencode(fp, pagename, strlen(pagename));
 
 	fputs("</h1></header>\n<main>"
-		"<table class=\"repositories\"><thead><tr>"
+		"<div class=\"table-container\"><table class=\"repositories\"><thead><tr>"
 		"<td>Name</td>"
 		"<td>Description</td>"
 		"<td>Last commit</td>"

@@ -121,7 +121,7 @@ writeheader(FILE *fp)
 void
 writefooter(FILE *fp)
 {
-	fputs("</tbody></table>\n", fp);
+	fputs("</tbody></table></div>\n", fp);
 
 	if (email[0]) fprintf(fp, "<h2 id=\"contribute\">Contribute</h2>"
 		"<p>The best way to contribute to my repositories is through e-mail, check out <a href=\"https://git-send-email.io\">git-send-email.io</a> if you don’t know how to do that. Send your patches to <a href=\"mailto:%s\">%s</a> and change the subject prefix to specify the repository you are sending the patch for. You can do that running the following command from the git repository:</p>"
diff --git a/stagit.c b/stagit.c
@@ -869,8 +869,6 @@ err:
 
 	relpath = "";
 
-	fputs("</div>", fp);
-
 	return 0;
 }
 

@@ -1062,7 +1060,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
 		fputs("</div>", fp);
 	}
 
-	fputs("<table class=\"files\"><thead><tr>"
+	fputs("<div class=\"table-container\"><table class=\"files\"><thead><tr>"
 			"<td>Mode</td>"
 			"<td>Name</td>"
 			"<td>Size</td>"

@@ -1171,7 +1169,7 @@ writefilestree(FILE *fp, git_tree *tree, const char *path)
 		}
 	}
 
-	fputs("</tbody></table>", fp);
+	fputs("</tbody></table></div>", fp);
 	return 0;
 }
 

@@ -1208,7 +1206,7 @@ writerefs(FILE *fp)
 	for (i = 0, j = 0, count = 0; i < refcount; i++) {
 		if (j == 0 && git_reference_is_tag(ris[i].ref)) {
 			if (count)
-				fputs("</tbody></table><br>", fp);
+				fputs("</tbody></table></div><br>", fp);
 			count = 0;
 			j = 1;
 		}

@@ -1216,6 +1214,7 @@ writerefs(FILE *fp)
 		/* print header if it has an entry (first). */
 		if (++count == 1) {
 			fprintf(fp, "<h2>%s</h2>"
+						"<div class=\"table-container\">"
 						"<table class=\"%s\"><thead><tr>"
 						"<td>Name</td>"
 						"<td>Last commit date</td>"

@@ -1239,7 +1238,7 @@ writerefs(FILE *fp)
 	}
 	/* table footer */
 	if (count)
-		fputs("</tbody></table><br>", fp);
+		fputs("</tbody></table></div><br>", fp);
 
 	for (i = 0; i < refcount; i++) {
 		commitinfo_free(ris[i].ci);

@@ -1508,6 +1507,7 @@ main(int argc, char *argv[])
 			writelog(fp, head);
 	}
 
+	fputs("</div>", fp);
 	writefooter(fp);
 	checkfileerror(fp, "log.html", 'w');
 	fclose(fp);
diff --git a/style.css b/style.css
@@ -127,6 +127,10 @@ dl {
  *
  ***/
 
+.table-container {
+	overflow-x: auto;
+}
+
 table {
 	width: 100%;
 }