]> git.cameronkatri.com Git - cgit.git/commitdiff
Expose file extension in tree lists as class to allow nicer tree styling
authorMartin Szulecki <opensuse@sukimashita.com>
Fri, 7 Aug 2009 12:06:02 +0000 (14:06 +0200)
committerMartin Szulecki <opensuse@sukimashita.com>
Sat, 8 Aug 2009 12:23:34 +0000 (14:23 +0200)
Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
ui-tree.c

index 553dbaa5a27e60ebad594d23cc842895bdf4beed..61fcf5a0776433a3a129a8fa805f7ab2ce11ff6f 100644 (file)
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -103,6 +103,7 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
 {
        char *name;
        char *fullpath;
+       char *class;
        enum object_type type;
        unsigned long size = 0;
 
@@ -135,7 +136,12 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
                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);