summaryrefslogtreecommitdiffabout
path: root/ui-tree.c
Unidiff
Diffstat (limited to 'ui-tree.c') (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 caf6a9e..c608754 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -92,81 +92,87 @@ static void print_object(const unsigned char *sha1, char *path, const char *base
92 if (!buf) { 92 if (!buf) {
93 cgit_print_error(fmt("Error reading object %s", 93 cgit_print_error(fmt("Error reading object %s",
94 sha1_to_hex(sha1))); 94 sha1_to_hex(sha1)));
95 return; 95 return;
96 } 96 }
97 97
98 html(" ("); 98 html(" (");
99 cgit_plain_link("plain", NULL, NULL, ctx.qry.head, 99 cgit_plain_link("plain", NULL, NULL, ctx.qry.head,
100 curr_rev, path); 100 curr_rev, path);
101 htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1)); 101 htmlf(")<br/>blob: %s\n", sha1_to_hex(sha1));
102 102
103 if (buffer_is_binary(buf, size)) 103 if (buffer_is_binary(buf, size))
104 print_binary_buffer(buf, size); 104 print_binary_buffer(buf, size);
105 else 105 else
106 print_text_buffer(basename, buf, size); 106 print_text_buffer(basename, buf, size);
107} 107}
108 108
109 109
110static int ls_item(const unsigned char *sha1, const char *base, int baselen, 110static int ls_item(const unsigned char *sha1, const char *base, int baselen,
111 const char *pathname, unsigned int mode, int stage, 111 const char *pathname, unsigned int mode, int stage,
112 void *cbdata) 112 void *cbdata)
113{ 113{
114 char *name; 114 char *name;
115 char *fullpath; 115 char *fullpath;
116 char *class;
116 enum object_type type; 117 enum object_type type;
117 unsigned long size = 0; 118 unsigned long size = 0;
118 119
119 name = xstrdup(pathname); 120 name = xstrdup(pathname);
120 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", 121 fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "",
121 ctx.qry.path ? "/" : "", name); 122 ctx.qry.path ? "/" : "", name);
122 123
123 if (!S_ISGITLINK(mode)) { 124 if (!S_ISGITLINK(mode)) {
124 type = sha1_object_info(sha1, &size); 125 type = sha1_object_info(sha1, &size);
125 if (type == OBJ_BAD) { 126 if (type == OBJ_BAD) {
126 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>", 127 htmlf("<tr><td colspan='3'>Bad object: %s %s</td></tr>",
127 name, 128 name,
128 sha1_to_hex(sha1)); 129 sha1_to_hex(sha1));
129 return 0; 130 return 0;
130 } 131 }
131 } 132 }
132 133
133 html("<tr><td class='ls-mode'>"); 134 html("<tr><td class='ls-mode'>");
134 cgit_print_filemode(mode); 135 cgit_print_filemode(mode);
135 html("</td><td>"); 136 html("</td><td>");
136 if (S_ISGITLINK(mode)) { 137 if (S_ISGITLINK(mode)) {
137 htmlf("<a class='ls-mod' href='"); 138 htmlf("<a class='ls-mod' href='");
138 html_attr(fmt(ctx.repo->module_link, 139 html_attr(fmt(ctx.repo->module_link,
139 name, 140 name,
140 sha1_to_hex(sha1))); 141 sha1_to_hex(sha1)));
141 html("'>"); 142 html("'>");
142 html_txt(name); 143 html_txt(name);
143 html("</a>"); 144 html("</a>");
144 } else if (S_ISDIR(mode)) { 145 } else if (S_ISDIR(mode)) {
145 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, 146 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head,
146 curr_rev, fullpath); 147 curr_rev, fullpath);
147 } else { 148 } else {
148 cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, 149 class = strrchr(name, '.');
150 if (class != NULL) {
151 class = fmt("ls-blob %s", class + 1);
152 } else
153 class = "ls-blob";
154 cgit_tree_link(name, NULL, class, ctx.qry.head,
149 curr_rev, fullpath); 155 curr_rev, fullpath);
150 } 156 }
151 htmlf("</td><td class='ls-size'>%li</td>", size); 157 htmlf("</td><td class='ls-size'>%li</td>", size);
152 158
153 html("<td>"); 159 html("<td>");
154 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, 160 cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev,
155 fullpath, 0, NULL, NULL, ctx.qry.showmsg); 161 fullpath, 0, NULL, NULL, ctx.qry.showmsg);
156 if (ctx.repo->max_stats) 162 if (ctx.repo->max_stats)
157 cgit_stats_link("stats", NULL, "button", ctx.qry.head, 163 cgit_stats_link("stats", NULL, "button", ctx.qry.head,
158 fullpath); 164 fullpath);
159 html("</td></tr>\n"); 165 html("</td></tr>\n");
160 free(name); 166 free(name);
161 return 0; 167 return 0;
162} 168}
163 169
164static void ls_head() 170static void ls_head()
165{ 171{
166 html("<table summary='tree listing' class='list'>\n"); 172 html("<table summary='tree listing' class='list'>\n");
167 html("<tr class='nohover'>"); 173 html("<tr class='nohover'>");
168 html("<th class='left'>Mode</th>"); 174 html("<th class='left'>Mode</th>");
169 html("<th class='left'>Name</th>"); 175 html("<th class='left'>Name</th>");
170 html("<th class='right'>Size</th>"); 176 html("<th class='right'>Size</th>");
171 html("<th/>"); 177 html("<th/>");
172 html("</tr>\n"); 178 html("</tr>\n");