add namespaces to stagit-index output
authorGeorgios Atheridis <georgios@atheridis.org>
Tue, 27 Dec 2022 10:32:52 +0000 (10:32 +0000)
committerGeorgios Atheridis <georgios@atheridis.org>
Tue, 27 Dec 2022 10:32:52 +0000 (10:32 +0000)
stagit-index.c
style.css

index 223756c4f9a911efb73eb49266096ac24384b32d..a5eddc4d46783cd1951b70924d1cd1271d4c9fdc 100644 (file)
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <time.h>
 #include <unistd.h>
+#include <ctype.h>
 
 #include <git2.h>
 
@@ -119,6 +120,20 @@ writeheader(FILE *fp)
                "</thead><tbody>\n", fp);
 }
 
+void
+writenamespace(FILE *fp)
+{
+        fputs("<tr><td class=\"namespace\">", fp);
+        namespace[0] = toupper(namespace[0]);
+        xmlencode(fp, namespace, strlen(description));
+        namespace[0] = tolower(namespace[0]);
+        fputs("</td><td>", fp);
+        fputs("</td><td>", fp);
+        fputs("</td><td>", fp);
+        fputs("</td></tr>", fp);
+}
+
+
 void
 writefooter(FILE *fp)
 {
@@ -204,6 +219,7 @@ main(int argc, char *argv[])
 
        writeheader(stdout);
 
+    char *old_namespace = "";
        for (i = 1; i < argc; i++) {
                repodir = argv[i];
                if (!realpath(repodir, repodirabs))
@@ -219,6 +235,12 @@ main(int argc, char *argv[])
                /* use directory name as name and namespace*/
         name = basename(repodirabs);
         namespace = basename(dirname(repodirabs));
+        if (strcmp(old_namespace, namespace) != 0) {
+            writenamespace(stdout);
+            old_namespace = malloc( sizeof *namespace );
+            memcpy(old_namespace, namespace, strlen(namespace));
+        }
+
 
                /* read description or .git/description */
                joinpath(path, sizeof(path), repodir, "description");
index 043ffcd56185fd1ce3fc193f7f80aabb422e8619..04b8093724ba60cedebe9471a7a9ef11f789419a 100644 (file)
--- a/style.css
+++ b/style.css
@@ -89,6 +89,10 @@ td.num {
        text-align: right;
 }
 
+td.namespace {
+    font-style: italic;
+}
+
 .desc {
        color: #555;
 }