stagit

print file as table, add link

Hiltjo Posthuma contact@arjunchoudhary.com

commit: cc22f8d parent: a09d3fd
1 files changed, 12 insertions(+), 2 deletions(-)
Murmoms.c+12-2
M · urmoms.c +12, -2
 1@@ -503,11 +503,21 @@ writefiles(FILE *fp)
 2 	git_repository_index(&index, repo);
 3 
 4 	count = git_index_entrycount(index);
 5+	fputs("<table><thead><tr><td>Mode</td><td>Name</td><td>Size</td></tr></thead><tbody>", fp);
 6+
 7 	for (i = 0; i < count; i++) {
 8 		entry = git_index_get_byindex(index, i);
 9-		fprintf(fp, "name: %s, size: %" PRIu64 ", mode: %u\n",
10-			entry->path, entry->file_size, entry->mode);
11+		fputs("<tr><td>", fp);
12+		fprintf(fp, "%u", entry->mode); /* TODO: fancy print, like: "-rw-r--r--" */
13+		fprintf(fp, "</td><td><a href=\"%sfile/", relpath);
14+		xmlencode(fp, entry->path, strlen(entry->path));
15+		fputs("\">", fp);
16+		xmlencode(fp, entry->path, strlen(entry->path));
17+		fputs("</a></td><td align=\"right\">", fp);
18+		fprintf(fp, "%" PRIu64, entry->file_size);
19+		fputs("</td></tr>", fp);
20 	}
21+	fputs("</tbody></table>", fp);
22 
23 	return 0;
24 }