summaryrefslogtreecommitdiffabout
authorLars Hjemli <hjemli@gmail.com>2006-12-17 22:55:53 (UTC)
committer Lars Hjemli <hjemli@gmail.com>2006-12-17 22:55:53 (UTC)
commita53042865a4ac8b1fa1d6b37720787601e181495 (patch) (unidiff)
treea104baf6600ccf30977e81649e859d8035484f13
parentfb6e5869dcc81b775d5ac79dd3afac7220c366dd (diff)
downloadcgit-a53042865a4ac8b1fa1d6b37720787601e181495.zip
cgit-a53042865a4ac8b1fa1d6b37720787601e181495.tar.gz
cgit-a53042865a4ac8b1fa1d6b37720787601e181495.tar.bz2
Use html_filemode in ui-tree.c
No reason to show "100644" when we can show "-rw-r--r--" Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--cgit.css4
-rw-r--r--ui-tree.c11
2 files changed, 9 insertions, 6 deletions
diff --git a/cgit.css b/cgit.css
index ae304fa..5f01926 100644
--- a/cgit.css
+++ b/cgit.css
@@ -74,26 +74,26 @@ div#blob {
74 74
75div.error { 75div.error {
76 color: red; 76 color: red;
77 font-weight: bold; 77 font-weight: bold;
78 margin: 1em 2em; 78 margin: 1em 2em;
79} 79}
80div.ls-dir a { 80div.ls-dir a {
81 font-weight: bold; 81 font-weight: bold;
82} 82}
83th.filesize, td.filesize { 83th.filesize, td.filesize {
84 text-align: right; 84 text-align: right;
85} 85}
86th.filemode, td.filemode { 86td.filemode {
87 text-align: center; 87 font-family: monospace;
88} 88}
89 89
90td.blob { 90td.blob {
91 white-space: pre; 91 white-space: pre;
92 font-family: courier; 92 font-family: courier;
93 font-size: 100%; 93 font-size: 100%;
94 background-color: white; 94 background-color: white;
95} 95}
96 96
97table.log td { 97table.log td {
98 white-space: nowrap; 98 white-space: nowrap;
99} 99}
diff --git a/ui-tree.c b/ui-tree.c
index c4d75ab..54dcdbe 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -14,57 +14,60 @@ static int print_entry(const unsigned char *sha1, const char *base,
14 int stage) 14 int stage)
15{ 15{
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>"); 26 html("<tr><td class='filemode'>");
27 html_filemode(mode);
28 html("</td><td>");
27 if (S_ISDIR(mode)) { 29 if (S_ISDIR(mode)) {
28 html("<div class='ls-dir'><a href='"); 30 html("<div class='ls-dir'><a href='");
29 html_attr(cgit_pageurl(cgit_query_repo, "tree", 31 html_attr(cgit_pageurl(cgit_query_repo, "tree",
30 fmt("id=%s", sha1_to_hex(sha1)))); 32 fmt("id=%s", sha1_to_hex(sha1))));
31 } else { 33 } else {
32 html("<div class='ls-blob'><a href='"); 34 html("<div class='ls-blob'><a href='");
33 html_attr(cgit_pageurl(cgit_query_repo, "view", 35 html_attr(cgit_pageurl(cgit_query_repo, "view",
34 fmt("id=%s", sha1_to_hex(sha1)))); 36 fmt("id=%s", sha1_to_hex(sha1))));
35 } 37 }
36 html("'>"); 38 html("'>");
37 html_txt(name); 39 html_txt(name);
38 if (S_ISDIR(mode)) 40 if (S_ISDIR(mode))
39 html("/"); 41 html("/");
40 html("</a></div></td>"); 42 html("</a></div></td>");
41 htmlf("<td class='filesize'>%li</td>", size); 43 htmlf("<td class='filesize'>%li</td>", size);
42 htmlf("<td class='filemode'>%06o</td>", mode);
43 html("</tr>\n"); 44 html("</tr>\n");
44 free(name); 45 free(name);
45 return 0; 46 return 0;
46} 47}
47 48
48void cgit_print_tree(const char *hex) 49void cgit_print_tree(const char *hex)
49{ 50{
50 struct tree *tree; 51 struct tree *tree;
51 unsigned char sha1[20]; 52 unsigned char sha1[20];
52 53
53 if (get_sha1_hex(hex, sha1)) { 54 if (get_sha1_hex(hex, sha1)) {
54 cgit_print_error(fmt("Invalid object id: %s", hex)); 55 cgit_print_error(fmt("Invalid object id: %s", hex));
55 return; 56 return;
56 } 57 }
57 tree = parse_tree_indirect(sha1); 58 tree = parse_tree_indirect(sha1);
58 if (!tree) { 59 if (!tree) {
59 cgit_print_error(fmt("Not a tree object: %s", hex)); 60 cgit_print_error(fmt("Not a tree object: %s", hex));
60 return; 61 return;
61 } 62 }
62 63
63 html("<h2>Tree content</h2>\n"); 64 html("<h2>Tree content</h2>\n");
64 html("<table class='list'>\n"); 65 html("<table class='list'>\n");
65 html("<tr><th class='left'>Name</th>"); 66 html("<tr>");
67 html("<th class='left'>Mode</th>");
68 html("<th class='left'>Name</th>");
66 html("<th class='right'>Size</th>"); 69 html("<th class='right'>Size</th>");
67 html("<th class='right'>Mode</th></tr>\n"); 70 html("</tr>\n");
68 read_tree_recursive(tree, "", 0, 1, NULL, print_entry); 71 read_tree_recursive(tree, "", 0, 1, NULL, print_entry);
69 html("</table>\n"); 72 html("</table>\n");
70} 73}