|
diff --git a/ui-tree.c b/ui-tree.c index c22e30b..c138877 100644 --- a/ ui-tree.c+++ b/ ui-tree.c |
|
@@ -8,45 +8,45 @@ |
8 | |
8 | |
9 | #include "cgit.h" |
9 | #include "cgit.h" |
10 | |
10 | |
11 | char *curr_rev; |
11 | char *curr_rev; |
12 | char *match_path; |
12 | char *match_path; |
13 | int header = 0; |
13 | int header = 0; |
14 | |
14 | |
15 | static void print_object(const unsigned char *sha1, char *path) |
15 | static void print_object(const unsigned char *sha1, char *path) |
16 | { |
16 | { |
17 | enum object_type type; |
17 | enum object_type type; |
18 | char *buf; |
18 | char *buf; |
19 | unsigned long size, lineno, start, idx; |
19 | unsigned long size, lineno, start, idx; |
20 | const char *linefmt = "<tr><td class='no'><a name='%1$d'>%1$d</a></td><td class='txt'>"; |
20 | const char *linefmt = "<tr><td class='no'><a id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a></td><td class='txt'>"; |
21 | |
21 | |
22 | type = sha1_object_info(sha1, &size); |
22 | type = sha1_object_info(sha1, &size); |
23 | if (type == OBJ_BAD) { |
23 | if (type == OBJ_BAD) { |
24 | cgit_print_error(fmt("Bad object name: %s", |
24 | cgit_print_error(fmt("Bad object name: %s", |
25 | sha1_to_hex(sha1))); |
25 | sha1_to_hex(sha1))); |
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", |
31 | cgit_print_error(fmt("Error reading object %s", |
32 | sha1_to_hex(sha1))); |
32 | sha1_to_hex(sha1))); |
33 | return; |
33 | return; |
34 | } |
34 | } |
35 | |
35 | |
36 | html(" blob: <a href='"); |
36 | html(" blob: <a href='"); |
37 | html_attr(cgit_pageurl(cgit_query_repo, "blob", fmt("id=%s", sha1_to_hex(sha1)))); |
37 | html_attr(cgit_pageurl(cgit_query_repo, "blob", fmt("id=%s", sha1_to_hex(sha1)))); |
38 | htmlf("'>%s</a>",sha1_to_hex(sha1)); |
38 | htmlf("'>%s</a>",sha1_to_hex(sha1)); |
39 | |
39 | |
40 | html("<table class='blob'>\n"); |
40 | html("<table summary='blob content' class='blob'>\n"); |
41 | idx = 0; |
41 | idx = 0; |
42 | start = 0; |
42 | start = 0; |
43 | lineno = 0; |
43 | lineno = 0; |
44 | while(idx < size) { |
44 | while(idx < size) { |
45 | if (buf[idx] == '\n') { |
45 | if (buf[idx] == '\n') { |
46 | buf[idx] = '\0'; |
46 | buf[idx] = '\0'; |
47 | htmlf(linefmt, ++lineno); |
47 | htmlf(linefmt, ++lineno); |
48 | html_txt(buf + start); |
48 | html_txt(buf + start); |
49 | html("</td></tr>\n"); |
49 | html("</td></tr>\n"); |
50 | start = idx + 1; |
50 | start = idx + 1; |
51 | } |
51 | } |
52 | idx++; |
52 | idx++; |
@@ -99,25 +99,25 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, |
99 | htmlf("</td><td class='ls-size'>%li</td>", size); |
99 | htmlf("</td><td class='ls-size'>%li</td>", size); |
100 | |
100 | |
101 | html("<td>"); |
101 | html("<td>"); |
102 | cgit_log_link("log", NULL, "button", cgit_query_head, curr_rev, |
102 | cgit_log_link("log", NULL, "button", cgit_query_head, curr_rev, |
103 | fullpath, 0, NULL, NULL); |
103 | fullpath, 0, NULL, NULL); |
104 | html("</td></tr>\n"); |
104 | html("</td></tr>\n"); |
105 | free(name); |
105 | free(name); |
106 | return 0; |
106 | return 0; |
107 | } |
107 | } |
108 | |
108 | |
109 | static void ls_head() |
109 | static void ls_head() |
110 | { |
110 | { |
111 | html("<table class='list'>\n"); |
111 | html("<table summary='tree listing' class='list'>\n"); |
112 | html("<tr class='nohover'>"); |
112 | html("<tr class='nohover'>"); |
113 | html("<th class='left'>Mode</th>"); |
113 | html("<th class='left'>Mode</th>"); |
114 | html("<th class='left'>Name</th>"); |
114 | html("<th class='left'>Name</th>"); |
115 | html("<th class='right'>Size</th>"); |
115 | html("<th class='right'>Size</th>"); |
116 | html("<th/>"); |
116 | html("<th/>"); |
117 | html("</tr>\n"); |
117 | html("</tr>\n"); |
118 | header = 1; |
118 | header = 1; |
119 | } |
119 | } |
120 | |
120 | |
121 | static void ls_tail() |
121 | static void ls_tail() |
122 | { |
122 | { |
123 | if (!header) |
123 | if (!header) |
|