diff options
Diffstat (limited to 'ui-tree.c')
| -rw-r--r-- | ui-tree.c | 25 |
1 files changed, 21 insertions, 4 deletions
@@ -23,6 +23,11 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) unsigned long lineno, idx; const char *numberfmt = "<a id='n%1$d' href='#n%1$d'>%1$d</a>\n"; + bool is_markdown = (strncmp(".md", &name[strlen(name)-3], 3) == 0); + if (is_markdown) { + html("<div class=\"tab-folder\"><div id=\"code\" class=\"tab-content\">"); + } + html("<table summary='blob content' class='blob'>\n"); if (ctx.cfg.enable_tree_linenumbers) { @@ -58,6 +63,16 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) html("<td class='lines'><pre><code>"); html_txt(buf); html("</code></pre></td></tr></table>\n"); + + if (is_markdown) { + html("</div><div id=\"preview\" class=\"tab-content\">"); + + cgit_open_filter(ctx.repo->about_filter, name); + html_raw(buf, size); + cgit_close_filter(ctx.repo->about_filter); + + html("</div></div>"); + } } #define ROWLEN 32 @@ -109,6 +124,8 @@ static void print_object(const struct object_id *oid, const char *path, const ch cgit_print_layout_start(); htmlf("blob: %s (", oid_to_hex(oid)); + html("<a href=\"#preview\">preview</a>) ("); + html("<a href=\"#code\">code</a>) ("); cgit_plain_link("plain", NULL, NULL, ctx.qry.head, rev, path); if (ctx.repo->enable_blame) { @@ -274,11 +291,11 @@ static void ls_head(void) html("</tr>\n"); } -static void ls_tail(const struct tree *tree) +static void ls_tail(const struct tree *tree, struct pathspec *paths) { html("</table>\n"); if (tree) - cgit_print_repo_readme_no_layout(tree); + cgit_print_repo_readme_no_layout(tree, paths); cgit_print_layout_end(); } @@ -299,7 +316,7 @@ static void ls_tree(const struct object_id *oid, const char *path, struct walk_t ls_head(); read_tree_recursive(the_repository, tree, "", 0, 1, &paths, ls_item, walk_tree_ctx); - ls_tail(tree); + ls_tail(tree, &paths); } @@ -383,7 +400,7 @@ void cgit_print_tree(const char *rev, char *path) "", 0, 0, &paths, walk_tree, &walk_tree_ctx); if (walk_tree_ctx.state == 1) { - ls_tail(tree); + ls_tail(tree, &paths); } else if (walk_tree_ctx.state == 2) { cgit_print_layout_end(); |
