]> git.armaanb.net Git - stagit.git/commitdiff
print file as table, add link
authorHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 7 Dec 2015 15:40:45 +0000 (16:40 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Mon, 7 Dec 2015 15:40:45 +0000 (16:40 +0100)
urmoms.c

index 69f0d1fa3bfa3b25f538f51687b92d7464d26752..d7e70054bbd4025ef790143cbb88e080bc41e1c4 100644 (file)
--- a/urmoms.c
+++ b/urmoms.c
@@ -503,11 +503,21 @@ writefiles(FILE *fp)
        git_repository_index(&index, repo);
 
        count = git_index_entrycount(index);
+       fputs("<table><thead><tr><td>Mode</td><td>Name</td><td>Size</td></tr></thead><tbody>", fp);
+
        for (i = 0; i < count; i++) {
                entry = git_index_get_byindex(index, i);
-               fprintf(fp, "name: %s, size: %" PRIu64 ", mode: %u\n",
-                       entry->path, entry->file_size, entry->mode);
+               fputs("<tr><td>", fp);
+               fprintf(fp, "%u", entry->mode); /* TODO: fancy print, like: "-rw-r--r--" */
+               fprintf(fp, "</td><td><a href=\"%sfile/", relpath);
+               xmlencode(fp, entry->path, strlen(entry->path));
+               fputs("\">", fp);
+               xmlencode(fp, entry->path, strlen(entry->path));
+               fputs("</a></td><td align=\"right\">", fp);
+               fprintf(fp, "%" PRIu64, entry->file_size);
+               fputs("</td></tr>", fp);
        }
+       fputs("</tbody></table>", fp);
 
        return 0;
 }