X-Git-Url: https://gitweb.ps.run/ps-cgit/blobdiff_plain/df63119302910587e280d91dce67f6537a671f74..47a81c77fdd017227632c4df9a0b7b135b8a738d:/ui-view.c diff --git a/ui-view.c b/ui-view.c index 193c685..dbe4b29 100644 --- a/ui-view.c +++ b/ui-view.c @@ -8,10 +8,10 @@ #include "cgit.h" -void cgit_print_view(char *hex) +void cgit_print_view(const char *hex, char *path) { unsigned char sha1[20]; - char type[20]; + enum object_type type; unsigned char *buf; unsigned long size; @@ -20,21 +20,36 @@ void cgit_print_view(char *hex) return; } - if (sha1_object_info(sha1, type, NULL)){ - cgit_print_error("Bad object name"); + type = sha1_object_info(sha1, &size); + if (type == OBJ_BAD) { + cgit_print_error(fmt("Bad object name: %s", hex)); return; } - buf = read_sha1_file(sha1, type, &size); + buf = read_sha1_file(sha1, &type, &size); if (!buf) { - cgit_print_error("Error reading object"); + cgit_print_error(fmt("Error reading object %s", hex)); return; } buf[size] = '\0'; - html("
");
+ html("| "); + if (path) + htmlf("%s (", path); + htmlf("%s %s, %li bytes", typename(type), hex, size); + if (path) + html(")"); + + html(" download"); + html(" |
|---|
| \n"); html_txt(buf); - html(""); + html("\n |