aboutsummaryrefslogtreecommitdiffstats
path: root/ui-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-tree.c')
-rw-r--r--ui-tree.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/ui-tree.c b/ui-tree.c
index dee8309..db63e13 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -8,9 +8,10 @@
8 8
9#include "cgit.h" 9#include "cgit.h"
10 10
11char *curr_rev;
11 12
12static int print_entry(const unsigned char *sha1, const char *base, 13static int print_entry(const unsigned char *sha1, const char *base,
13 int baselen, const char *pathname, unsigned int mode, 14 int baselen, const char *pathname, unsigned int mode,
14 int stage) 15 int stage)
15{ 16{
16 char *name; 17 char *name;
@@ -35,30 +36,41 @@ static int print_entry(const unsigned char *sha1, const char *base,
35 sha1_to_hex(sha1))); 36 sha1_to_hex(sha1)));
36 } else if (S_ISDIR(mode)) { 37 } else if (S_ISDIR(mode)) {
37 html("class='ls-dir'><a href='"); 38 html("class='ls-dir'><a href='");
38 html_attr(cgit_pageurl(cgit_query_repo, "tree", 39 html_attr(cgit_pageurl(cgit_query_repo, "tree",
39 fmt("id=%s&path=%s%s/", 40 fmt("h=%s&id=%s&path=%s%s/",
41 curr_rev,
40 sha1_to_hex(sha1), 42 sha1_to_hex(sha1),
41 cgit_query_path ? cgit_query_path : "", 43 cgit_query_path ? cgit_query_path : "",
42 pathname))); 44 pathname)));
43 } else { 45 } else {
44 html("class='ls-blob'><a href='"); 46 html("class='ls-blob'><a href='");
45 html_attr(cgit_pageurl(cgit_query_repo, "view", 47 html_attr(cgit_pageurl(cgit_query_repo, "view",
46 fmt("id=%s&path=%s%s", sha1_to_hex(sha1), 48 fmt("h=%s&id=%s&path=%s%s", curr_rev,
49 sha1_to_hex(sha1),
47 cgit_query_path ? cgit_query_path : "", 50 cgit_query_path ? cgit_query_path : "",
48 pathname))); 51 pathname)));
49 } 52 }
50 htmlf("'>%s</a></div></td>", name); 53 htmlf("'>%s</a></div></td>", name);
51 htmlf("<td class='filesize'>%li</td>", size); 54 htmlf("<td class='filesize'>%li</td>", size);
55
56 html("<td class='links'><a href='");
57 html_attr(cgit_pageurl(cgit_query_repo, "log",
58 fmt("h=%s&path=%s%s",
59 curr_rev,
60 cgit_query_path ? cgit_query_path : "",
61 pathname)));
62 html("'>history</a></td>");
52 html("</tr>\n"); 63 html("</tr>\n");
53 free(name); 64 free(name);
54 return 0; 65 return 0;
55} 66}
56 67
57void cgit_print_tree(const char *hex, char *path) 68void cgit_print_tree(const char *rev, const char *hex, char *path)
58{ 69{
59 struct tree *tree; 70 struct tree *tree;
60 unsigned char sha1[20]; 71 unsigned char sha1[20];
61 72
73 curr_rev = xstrdup(rev);
62 if (get_sha1_hex(hex, sha1)) { 74 if (get_sha1_hex(hex, sha1)) {
63 cgit_print_error(fmt("Invalid object id: %s", hex)); 75 cgit_print_error(fmt("Invalid object id: %s", hex));
64 return; 76 return;
@@ -75,6 +87,7 @@ void cgit_print_tree(const char *hex, char *path)
75 html("<th class='left'>Mode</th>"); 87 html("<th class='left'>Mode</th>");
76 html("<th class='left'>Name</th>"); 88 html("<th class='left'>Name</th>");
77 html("<th class='right'>Size</th>"); 89 html("<th class='right'>Size</th>");
90 html("<th/>");
78 html("</tr>\n"); 91 html("</tr>\n");
79 read_tree_recursive(tree, "", 0, 1, NULL, print_entry); 92 read_tree_recursive(tree, "", 0, 1, NULL, print_entry);
80 html("</table>\n"); 93 html("</table>\n");