|
diff --git a/ui-view.c b/ui-view.c index 9d23c45..7d022fd 100644 --- a/ ui-view.c+++ b/ ui-view.c |
|
@@ -1,43 +1,48 @@ |
1 | /* ui-view.c: functions to output _any_ object, given it's sha1 |
1 | /* ui-view.c: functions to output _any_ object, given it's sha1 |
2 | * |
2 | * |
3 | * Copyright (C) 2006 Lars Hjemli |
3 | * Copyright (C) 2006 Lars Hjemli |
4 | * |
4 | * |
5 | * Licensed under GNU General Public License v2 |
5 | * Licensed under GNU General Public License v2 |
6 | * (see COPYING for full license text) |
6 | * (see COPYING for full license text) |
7 | */ |
7 | */ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | |
10 | |
11 | void cgit_print_view(const char *hex) |
11 | void cgit_print_view(const char *hex, char *path) |
12 | { |
12 | { |
13 | unsigned char sha1[20]; |
13 | unsigned char sha1[20]; |
14 | enum object_type type; |
14 | enum object_type type; |
15 | unsigned char *buf; |
15 | unsigned char *buf; |
16 | unsigned long size; |
16 | unsigned long size; |
17 | |
17 | |
18 | if (get_sha1_hex(hex, sha1)){ |
18 | if (get_sha1_hex(hex, sha1)){ |
19 | cgit_print_error(fmt("Bad hex value: %s", hex)); |
19 | cgit_print_error(fmt("Bad hex value: %s", hex)); |
20 | return; |
20 | return; |
21 | } |
21 | } |
22 | |
22 | |
23 | type = sha1_object_info(sha1, &size); |
23 | type = sha1_object_info(sha1, &size); |
24 | if (type == OBJ_BAD) { |
24 | if (type == OBJ_BAD) { |
25 | cgit_print_error(fmt("Bad object name: %s", hex)); |
25 | cgit_print_error(fmt("Bad object name: %s", hex)); |
26 | return; |
26 | return; |
27 | } |
27 | } |
28 | |
28 | |
29 | buf = read_sha1_file(sha1, &type, &size); |
29 | buf = read_sha1_file(sha1, &type, &size); |
30 | if (!buf) { |
30 | if (!buf) { |
31 | cgit_print_error(fmt("Error reading object %s", hex)); |
31 | cgit_print_error(fmt("Error reading object %s", hex)); |
32 | return; |
32 | return; |
33 | } |
33 | } |
34 | |
34 | |
35 | buf[size] = '\0'; |
35 | buf[size] = '\0'; |
36 | html("<table class='list'>\n"); |
36 | html("<table class='list'>\n"); |
37 | htmlf("<tr class='nohover'><th class='left'>%s %s, %li bytes</th></tr>\n", |
37 | html("<tr class='nohover'><th class='left'>"); |
38 | typename(type), hex, size); |
38 | if (path) |
| |
39 | htmlf("%s (", path); |
| |
40 | htmlf("%s %s, %li bytes", typename(type), hex, size); |
| |
41 | if (path) |
| |
42 | html(")"); |
| |
43 | html("</th></tr>\n"); |
39 | html("<tr><td class='blob'>\n"); |
44 | html("<tr><td class='blob'>\n"); |
40 | html_txt(buf); |
45 | html_txt(buf); |
41 | html("\n</td></tr>\n"); |
46 | html("\n</td></tr>\n"); |
42 | html("</table>\n"); |
47 | html("</table>\n"); |
43 | } |
48 | } |
|