- html("class='ls-blob'>");
- cgit_tree_link(name, NULL, NULL, cgit_query_head,
- curr_rev, fullpath);
- }
- htmlf("</td><td class='filesize'>%li</td>", size);
-
- html("<td class='links'><a href='");
- qry = fmt("h=%s&path=%s%s%s", curr_rev,
- cgit_query_path ? cgit_query_path : "",
- cgit_query_path ? "/" : "", pathname);
- url = cgit_pageurl(cgit_query_repo, "log", qry);
- html_attr(url);
- html("' class='button'>H</a></td>");
- html("</tr>\n");
+ char *ext = strrchr(name, '.');
+ strbuf_addstr(&class, "ls-blob");
+ if (ext)
+ strbuf_addf(&class, " %s", ext + 1);
+ cgit_tree_link(name, NULL, class.buf, ctx.qry.head,
+ walk_tree_ctx->curr_rev, fullpath.buf);
+ }
+ if (S_ISLNK(mode)) {
+ html(" -> ");
+ buf = read_object_file(oid, &type, &size);
+ if (!buf) {
+ htmlf("Error reading object: %s", oid_to_hex(oid));
+ goto cleanup;
+ }
+ strbuf_addbuf(&linkpath, &fullpath);
+ strbuf_addf(&linkpath, "/../%s", buf);
+ strbuf_normalize_path(&linkpath);
+ cgit_tree_link(buf, NULL, class.buf, ctx.qry.head,
+ walk_tree_ctx->curr_rev, linkpath.buf);
+ free(buf);
+ strbuf_release(&linkpath);
+ }
+ htmlf("</td><td class='ls-size'>%li</td>", size);
+
+ html("<td>");
+ cgit_log_link("log", NULL, "button", ctx.qry.head,
+ walk_tree_ctx->curr_rev, fullpath.buf, 0, NULL, NULL,
+ ctx.qry.showmsg, 0);
+ if (ctx.repo->max_stats)
+ cgit_stats_link("stats", NULL, "button", ctx.qry.head,
+ fullpath.buf);
+ if (!S_ISGITLINK(mode))
+ cgit_plain_link("plain", NULL, "button", ctx.qry.head,
+ walk_tree_ctx->curr_rev, fullpath.buf);
+ if (!S_ISDIR(mode) && ctx.repo->enable_blame)
+ cgit_blame_link("blame", NULL, "button", ctx.qry.head,
+ walk_tree_ctx->curr_rev, fullpath.buf);
+ html("</td></tr>\n");
+
+cleanup: