From 7dfc2b975fd4a735073536914f5a49b8d80a1104 Mon Sep 17 00:00:00 2001 From: Patrick Date: Tue, 23 Dec 2025 23:35:13 +0100 Subject: buncha features --- ui-tree.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'ui-tree.c') diff --git a/ui-tree.c b/ui-tree.c index 5e78f64..61049e7 100644 --- a/ui-tree.c +++ b/ui-tree.c @@ -23,6 +23,11 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size) unsigned long lineno, idx; const char *numberfmt = "%1$d\n"; + bool is_markdown = (strncmp(".md", &name[strlen(name)-3], 3) == 0); + if (is_markdown) { + html("
"); + } + html("\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("
");
 	html_txt(buf);
 	html("
\n"); + + if (is_markdown) { + html("
"); + + cgit_open_filter(ctx.repo->about_filter, name); + html_raw(buf, size); + cgit_close_filter(ctx.repo->about_filter); + + html("
"); + } } #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("preview) ("); + html("code) ("); 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("\n"); } -static void ls_tail(const struct tree *tree) +static void ls_tail(const struct tree *tree, struct pathspec *paths) { html("\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(); -- cgit v1.2.3