author | Martin Szulecki <opensuse@sukimashita.com> | 2009-08-07 12:06:02 (UTC) |
---|---|---|
committer | Martin Szulecki <opensuse@sukimashita.com> | 2009-08-08 12:23:34 (UTC) |
commit | b4c3562f57c924866314d0f80f46dddecd4ce61a (patch) (side-by-side diff) | |
tree | a720b48fa2f32458b6d1a80808f329cc90e233fe | |
parent | 2f56e390f04fe6975b75e512c1436ef173e4aafe (diff) | |
download | cgit-b4c3562f57c924866314d0f80f46dddecd4ce61a.zip cgit-b4c3562f57c924866314d0f80f46dddecd4ce61a.tar.gz cgit-b4c3562f57c924866314d0f80f46dddecd4ce61a.tar.bz2 |
Expose file extension in tree lists as class to allow nicer tree styling
Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
-rw-r--r-- | ui-tree.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -98,16 +98,17 @@ static void print_object(const unsigned char *sha1, char *path) static int ls_item(const unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned int mode, int stage, void *cbdata) { char *name; char *fullpath; + char *class; enum object_type type; unsigned long size = 0; name = xstrdup(pathname); fullpath = fmt("%s%s%s", ctx.qry.path ? ctx.qry.path : "", ctx.qry.path ? "/" : "", name); if (!S_ISGITLINK(mode)) { @@ -130,17 +131,22 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen, sha1_to_hex(sha1))); html("'>"); html_txt(name); html("</a>"); } else if (S_ISDIR(mode)) { cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, curr_rev, fullpath); } else { - cgit_tree_link(name, NULL, "ls-blob", ctx.qry.head, + class = strrchr(name, '.'); + if (class != NULL) { + class = fmt("ls-blob %s", class + 1); + } else + class = "ls-blob"; + cgit_tree_link(name, NULL, class, ctx.qry.head, curr_rev, fullpath); } htmlf("</td><td class='ls-size'>%li</td>", size); html("<td>"); cgit_log_link("log", NULL, "button", ctx.qry.head, curr_rev, fullpath, 0, NULL, NULL, ctx.qry.showmsg); if (ctx.repo->max_stats) |