author | Lars Hjemli <hjemli@gmail.com> | 2007-01-11 23:46:17 (UTC) |
---|---|---|
committer | Lars Hjemli <hjemli@gmail.com> | 2007-01-11 23:46:17 (UTC) |
commit | 5cd2bf7e7f3f3daf6107cd3a269bad78e342de70 (patch) (unidiff) | |
tree | 7ce9368e94b39114e772c279f741bd8106f611d2 /ui-tree.c | |
parent | 2c2047ff67a1e0053f95776e5079e432f69cea54 (diff) | |
download | cgit-5cd2bf7e7f3f3daf6107cd3a269bad78e342de70.zip cgit-5cd2bf7e7f3f3daf6107cd3a269bad78e342de70.tar.gz cgit-5cd2bf7e7f3f3daf6107cd3a269bad78e342de70.tar.bz2 |
WIP: add paths/backlinks to tree/blobview
-rw-r--r-- | ui-tree.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -16,58 +16,64 @@ static int print_entry(const unsigned char *sha1, const char *base, | |||
16 | char *name; | 16 | char *name; |
17 | char type[20]; | 17 | char type[20]; |
18 | unsigned long size; | 18 | unsigned long size; |
19 | 19 | ||
20 | if (sha1_object_info(sha1, type, &size)) { | 20 | if (sha1_object_info(sha1, type, &size)) { |
21 | cgit_print_error(fmt("Bad object name: %s", | 21 | cgit_print_error(fmt("Bad object name: %s", |
22 | sha1_to_hex(sha1))); | 22 | sha1_to_hex(sha1))); |
23 | return 0; | 23 | return 0; |
24 | } | 24 | } |
25 | name = xstrdup(pathname); | 25 | name = xstrdup(pathname); |
26 | html("<tr><td class='filemode'>"); | 26 | html("<tr><td class='filemode'>"); |
27 | html_filemode(mode); | 27 | html_filemode(mode); |
28 | html("</td><td>"); | 28 | html("</td><td>"); |
29 | if (S_ISDIR(mode)) { | 29 | if (S_ISDIR(mode)) { |
30 | html("<div class='ls-dir'><a href='"); | 30 | html("<div class='ls-dir'><a href='"); |
31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", | 31 | html_attr(cgit_pageurl(cgit_query_repo, "tree", |
32 | fmt("id=%s", sha1_to_hex(sha1)))); | 32 | fmt("id=%s&path=%s%s/", |
33 | sha1_to_hex(sha1), | ||
34 | cgit_query_path ? cgit_query_path : "", | ||
35 | pathname))); | ||
33 | } else { | 36 | } else { |
34 | html("<div class='ls-blob'><a href='"); | 37 | html("<div class='ls-blob'><a href='"); |
35 | html_attr(cgit_pageurl(cgit_query_repo, "view", | 38 | html_attr(cgit_pageurl(cgit_query_repo, "view", |
36 | fmt("id=%s", sha1_to_hex(sha1)))); | 39 | fmt("id=%s&path=%s%s", sha1_to_hex(sha1), |
40 | cgit_query_path ? cgit_query_path : "", | ||
41 | pathname))); | ||
37 | } | 42 | } |
38 | html("'>"); | 43 | html("'>"); |
39 | html_txt(name); | 44 | html_txt(name); |
40 | if (S_ISDIR(mode)) | 45 | if (S_ISDIR(mode)) |
41 | html("/"); | 46 | html("/"); |
42 | html("</a></div></td>"); | 47 | html("</a></div></td>"); |
43 | htmlf("<td class='filesize'>%li</td>", size); | 48 | htmlf("<td class='filesize'>%li</td>", size); |
44 | html("</tr>\n"); | 49 | html("</tr>\n"); |
45 | free(name); | 50 | free(name); |
46 | return 0; | 51 | return 0; |
47 | } | 52 | } |
48 | 53 | ||
49 | void cgit_print_tree(const char *hex) | 54 | void cgit_print_tree(const char *hex, char *path) |
50 | { | 55 | { |
51 | struct tree *tree; | 56 | struct tree *tree; |
52 | unsigned char sha1[20]; | 57 | unsigned char sha1[20]; |
53 | 58 | ||
54 | if (get_sha1_hex(hex, sha1)) { | 59 | if (get_sha1_hex(hex, sha1)) { |
55 | cgit_print_error(fmt("Invalid object id: %s", hex)); | 60 | cgit_print_error(fmt("Invalid object id: %s", hex)); |
56 | return; | 61 | return; |
57 | } | 62 | } |
58 | tree = parse_tree_indirect(sha1); | 63 | tree = parse_tree_indirect(sha1); |
59 | if (!tree) { | 64 | if (!tree) { |
60 | cgit_print_error(fmt("Not a tree object: %s", hex)); | 65 | cgit_print_error(fmt("Not a tree object: %s", hex)); |
61 | return; | 66 | return; |
62 | } | 67 | } |
63 | 68 | ||
64 | html("<h2>Tree content</h2>\n"); | 69 | html("<h2>Tree content</h2>\n"); |
70 | html_txt(path); | ||
65 | html("<table class='list'>\n"); | 71 | html("<table class='list'>\n"); |
66 | html("<tr>"); | 72 | html("<tr>"); |
67 | html("<th class='left'>Mode</th>"); | 73 | html("<th class='left'>Mode</th>"); |
68 | html("<th class='left'>Name</th>"); | 74 | html("<th class='left'>Name</th>"); |
69 | html("<th class='right'>Size</th>"); | 75 | html("<th class='right'>Size</th>"); |
70 | html("</tr>\n"); | 76 | html("</tr>\n"); |
71 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); | 77 | read_tree_recursive(tree, "", 0, 1, NULL, print_entry); |
72 | html("</table>\n"); | 78 | html("</table>\n"); |
73 | } | 79 | } |