abouttreesummaryrefslogcommitdiff
path: root/ui-tree.c
diff options
context:
space:
mode:
authorPatrick2025-12-23 23:35:13 +0100
committerPatrick2025-12-23 23:35:13 +0100
commit7dfc2b975fd4a735073536914f5a49b8d80a1104 (patch)
tree69ec9e78cd5ad255ae17435f962952a1e4ebdc2c /ui-tree.c
parent13ff15345e1fe7ecc72967e1e0d9a473428f241f (diff)
downloadps-cgit-7dfc2b975fd4a735073536914f5a49b8d80a1104.tar.gz
ps-cgit-7dfc2b975fd4a735073536914f5a49b8d80a1104.zip
buncha features
Diffstat (limited to 'ui-tree.c')
-rw-r--r--ui-tree.c25
1 files changed, 21 insertions, 4 deletions
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 = "<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();