summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--ui-tree.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui-tree.c b/ui-tree.c
index 553dbaa..61fcf5a 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -90,65 +90,71 @@ static void print_object(const unsigned char *sha1, char *path)
90 curr_rev, path); 90 curr_rev, path);
91 htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); 91 htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1));
92 92
93 if (buffer_is_binary(buf, size)) 93 if (buffer_is_binary(buf, size))
94 print_binary_buffer(buf, size); 94 print_binary_buffer(buf, size);
95 else 95 else
96 print_text_buffer(buf, size); 96 print_text_buffer(buf, size);
97} 97}
98 98
99 99
100static int ls_item(const unsigned char *sha1, const char *base, int baselen, 100static int ls_item(const unsigned char *sha1, const char *base, int baselen,
101 const char *pathname, unsigned int mode, int stage, 101 const char *pathname, unsigned int mode, int stage,
102 void *cbdata) 102 void *cbdata)
103{ 103{
104 char *name; 104 char *name;
105 char *fullpath; 105 char *fullpath;
106 char *class;
106 enum object_type type; 107 enum object_type type;
107 unsigned long size = 0; 108 unsigned long size = 0;
108 109
109 name = xstrdup(pathname); 110 name = xstrdup(pathname);
110 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", 111 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "",
111 ctx.qry.path ? "/" : "", name); 112 ctx.qry.path ? "/" : "", name);
112 113
113 if (!S_ISGITLINK(mode)) { 114 if (!S_ISGITLINK(mode)) {
114 type = sha1_object_info(sha1, &size); 115 type = sha1_object_info(sha1, &size);
115 if (type == OBJ_BAD) { 116 if (type == OBJ_BAD) {
116 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", 117 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
117 name, 118 name,
118 sha1_to_hex(sha1)); 119 sha1_to_hex(sha1));
119 return 0; 120 return 0;
120 } 121 }
121 } 122 }
122 123
123 html("<tr><td class='ls-mode'>"); 124 html("<tr><td class='ls-mode'>");
124 cgit_print_filemode(mode); 125 cgit_print_filemode(mode);
125 html("</td><td>"); 126 html("</td><td>");
126 if (S_ISGITLINK(mode)) { 127 if (S_ISGITLINK(mode)) {
127 htmlf("<a class='ls-mod' href='"); 128 htmlf("<a class='ls-mod' href='");
128 html_attr(fmt(ctx.repo->module_link, 129 html_attr(fmt(ctx.repo->module_link,
129 name, 130 name,
130 sha1_to_hex(sha1))); 131 sha1_to_hex(sha1)));
131 html("'>"); 132 html("'>");
132 html_txt(name); 133 html_txt(name);
133 html("</a>"); 134 html("</a>");
134 } else if (S_ISDIR(mode)) { 135 } else if (S_ISDIR(mode)) {
135 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, 136 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head,
136 curr_rev, fullpath); 137 curr_rev, fullpath);
137 } else { 138 } else {
138 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, 139 class = strrchr(name, '.');
140 if (class != NULL) {
141 class = fmt("ls-blob %s", class + 1);
142 } else
143 class = "ls-blob";
144 cgit_tree_link(name, NULL, class, ctx.qry.head,
139 curr_rev, fullpath); 145 curr_rev, fullpath);
140 } 146 }
141 htmlf("</td><td class='ls-size'>%li</td>", size); 147 htmlf("</td><td class='ls-size'>%li</td>", size);
142 148
143 html("<td>"); 149 html("<td>");
144 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, 150 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev,
145 fullpath, 0, NULL, NULL, ctx.qry.showmsg); 151 fullpath, 0, NULL, NULL, ctx.qry.showmsg);
146 if (ctx.repo->max_stats) 152 if (ctx.repo->max_stats)
147 cgit_stats_link("stats", NULL, "button", ctx.qry.head, 153 cgit_stats_link("stats", NULL, "button", ctx.qry.head,
148 fullpath); 154 fullpath);
149 html("</td></tr>\n"); 155 html("</td></tr>\n");
150 free(name); 156 free(name);
151 return 0; 157 return 0;
152} 158}
153 159
154static void ls_head() 160static void ls_head()