aboutsummaryrefslogtreecommitdiffstats
path: root/ui-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-tree.c')
-rw-r--r--ui-tree.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/ui-tree.c b/ui-tree.c
index 553dbaa..c608754 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -15,13 +15,23 @@ char *curr_rev;
15char *match_path; 15char *match_path;
16int header = 0; 16int header = 0;
17 17
18static void print_text_buffer(char *buf, unsigned long size) 18static void print_text_buffer(const char *name, char *buf, unsigned long size)
19{ 19{
20 unsigned long lineno, idx; 20 unsigned long lineno, idx;
21 const char *numberfmt = 21 const char *numberfmt =
22 "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n"; 22 "<a class='no' id='n%1$d' name='n%1$d' href='#n%1$d'>%1$d</a>\n";
23 23
24 html("<table summary='blob content' class='blob'>\n"); 24 html("<table summary='blob content' class='blob'>\n");
25 if (ctx.repo->source_filter) {
26 html("<tr><td class='lines'><pre><code>");
27 ctx.repo->source_filter->argv[1] = xstrdup(name);
28 cgit_open_filter(ctx.repo->source_filter);
29 write(STDOUT_FILENO, buf, size);
30 cgit_close_filter(ctx.repo->source_filter);
31 html("</code></pre></td></tr></table>\n");
32 return;
33 }
34
25 html("<tr><td class='linenumbers'><pre>"); 35 html("<tr><td class='linenumbers'><pre>");
26 idx = 0; 36 idx = 0;
27 lineno = 0; 37 lineno = 0;
@@ -65,7 +75,7 @@ static void print_binary_buffer(char *buf, unsigned long size)
65 html("</table>\n"); 75 html("</table>\n");
66} 76}
67 77
68static void print_object(const unsigned char *sha1, char *path) 78static void print_object(const unsigned char *sha1, char *path, const char *basename)
69{ 79{
70 enum object_type type; 80 enum object_type type;
71 char *buf; 81 char *buf;
@@ -93,7 +103,7 @@ static void print_object(const unsigned char *sha1, char *path)
93 if (buffer_is_binary(buf, size)) 103 if (buffer_is_binary(buf, size))
94 print_binary_buffer(buf, size); 104 print_binary_buffer(buf, size);
95 else 105 else
96 print_text_buffer(buf, size); 106 print_text_buffer(basename, buf, size);
97} 107}
98 108
99 109
@@ -103,6 +113,7 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
103{ 113{
104 char *name; 114 char *name;
105 char *fullpath; 115 char *fullpath;
116 char *class;
106 enum object_type type; 117 enum object_type type;
107 unsigned long size = 0; 118 unsigned long size = 0;
108 119
@@ -135,7 +146,12 @@ static int ls_item(const unsigned char *sha1, const char *base, int baselen,
135 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head, 146 cgit_tree_link(name, NULL, "ls-dir", ctx.qry.head,
136 curr_rev, fullpath); 147 curr_rev, fullpath);
137 } else { 148 } else {
138 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,
139 curr_rev, fullpath); 155 curr_rev, fullpath);
140 } 156 }
141 htmlf("</td><td class='ls-size'>%li</td>", size); 157 htmlf("</td><td class='ls-size'>%li</td>", size);
@@ -213,7 +229,7 @@ static int walk_tree(const unsigned char *sha1, const char *base, int baselen,
213 ls_head(); 229 ls_head();
214 return READ_TREE_RECURSIVE; 230 return READ_TREE_RECURSIVE;
215 } else { 231 } else {
216 print_object(sha1, buffer); 232 print_object(sha1, buffer, pathname);
217 return 0; 233 return 0;
218 } 234 }
219 } 235 }