abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorPatrick2025-12-23 23:56:13 +0100
committerPatrick2025-12-23 23:56:13 +0100
commit99bb0dbc9c058d3737054e11e417b8715874c75c (patch)
tree27149179d9589fac4950ea4cffbf7f86dc6fd498
parent1f820ce8f0c8ce6df5bdc072775ea631ca403960 (diff)
downloadps-cgit-99bb0dbc9c058d3737054e11e417b8715874c75c.tar.gz
ps-cgit-99bb0dbc9c058d3737054e11e417b8715874c75c.zip
only show preview/code links on markdown blobs
-rw-r--r--ui-tree.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/ui-tree.c b/ui-tree.c
index 61049e7..897a92d 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -18,12 +18,11 @@ struct walk_tree_context {
int state;
};
-static void print_text_buffer(const char *name, char *buf, unsigned long size)
+static void print_text_buffer(const char *name, char *buf, unsigned long size, bool is_markdown)
{
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\">");
}
@@ -122,10 +121,14 @@ static void print_object(const struct object_id *oid, const char *path, const ch
cgit_set_title_from_path(path);
+ bool is_markdown = (strncmp(".md", &basename[strlen(basename)-3], 3) == 0);
+
cgit_print_layout_start();
htmlf("blob: %s (", oid_to_hex(oid));
- html("<a href=\"#preview\">preview</a>) (");
- html("<a href=\"#code\">code</a>) (");
+ if (is_markdown) {
+ 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) {
@@ -144,7 +147,7 @@ static void print_object(const struct object_id *oid, const char *path, const ch
if (buffer_is_binary(buf, size))
print_binary_buffer(buf, size);
else
- print_text_buffer(basename, buf, size);
+ print_text_buffer(basename, buf, size, is_markdown);
free(buf);
}