diff --git a/cgit.mk b/cgit.mk
index f66c985..551f0b8 100644
--- a/cgit.mk
+++ b/cgit.mk
@@ -99,6 +99,7 @@ CGIT_OBJ_NAMES += themed/themed.o
CGIT_OBJ_NAMES += themed/mincrypt_sha256.o
CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/base.html
+CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/tree_common.html
CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/index.html
CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/commit.html
CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/diff.html
diff --git a/themed/summary.html b/themed/summary.html
index c22248e..bcf855c 100644
--- a/themed/summary.html
+++ b/themed/summary.html
@@ -1,32 +1,8 @@
{! #include "../ui-blob.h" !}
-{% block ls_item_impl(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, void *cbdata) %}
- {!
- unsigned long size = 0;
- if (!S_ISGITLINK(mode)) {
- oid_object_info(the_repository, oid, &size);
- }
- !}
-
- {% if S_ISDIR(mode) %}
- {# Heroicons solid folder #}
-
- {% else %}
- {# Heroicons outline document #}
-
- {% endif %}
-
-
- {! cgit_print_filemode(mode); !}
- {% if !S_ISDIR(mode) %}{{ size|%ld }}{% endif %}
-{% endblock %}
{!
int ls_item(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, void *cbdata) {
- ls_item_impl(oid, base, pathname, mode, cbdata);
+ tree_listing_item(oid, base, pathname, mode, true); /* from tree_common.html */
return 0;
}
!}
diff --git a/themed/tree.html b/themed/tree.html
index 2bf7378..bfd3709 100644
--- a/themed/tree.html
+++ b/themed/tree.html
@@ -17,35 +17,6 @@
{% endblock %}
-{% block tree_content_directory_item(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, int child_idx) %}
- {# Directory listing entry #}
- {!
- unsigned long size = 0;
- if (!S_ISGITLINK(mode)) {
- oid_object_info(the_repository, oid, &size);
- }
-
- struct strbuf fullpath = STRBUF_INIT;
- strbuf_addf(&fullpath, "%s%s", base->buf, pathname);
- !}
-
- {% if S_ISDIR(mode) %}
- {# Heroicons solid folder #}
-
- {% else %}
- {# Heroicons outline document #}
-
- {% endif %}
-
-
-
{! cgit_print_filemode(mode); !}
-
{% if !S_ISDIR(mode) %}{{ size|%ld }}{% endif %}
- {! strbuf_release(&fullpath); !}
-{% endblock %}
{% block tree_content_directory_footer %}
{# Footer for directory listing #}
@@ -112,7 +83,13 @@
if (strcmp(walk_tree_ctx->match_path, buffer.buf)) {
// Not the target path, so continue to walk the tree
strbuf_release(&buffer);
- return READ_TREE_RECURSIVE;
+
+ if (S_ISGITLINK(mode)) {
+ // Never recurse into submodules
+ return 0;
+ } else {
+ return READ_TREE_RECURSIVE;
+ }
}
// This is the target path
@@ -140,7 +117,7 @@
strbuf_addstr(&buffer, "/");
if (!strcmp(buffer.buf, base->buf)) {
- tree_content_directory_item(oid, base, pathname, mode, walk_tree_ctx->directory_child_idx);
+ tree_listing_item(oid, base, pathname, mode, walk_tree_ctx->directory_child_idx > 0);
walk_tree_ctx->directory_child_idx++;
}
strbuf_release(&buffer);
diff --git a/themed/tree_common.html b/themed/tree_common.html
new file mode 100644
index 0000000..dda53eb
--- /dev/null
+++ b/themed/tree_common.html
@@ -0,0 +1,46 @@
+{% block tree_listing_item(const struct object_id *oid, struct strbuf *base, const char *pathname, unsigned mode, bool border_above) %}
+ {# Directory listing entry #}
+ {!
+ unsigned long size = 0;
+ if (!S_ISGITLINK(mode)) {
+ oid_object_info(the_repository, oid, &size);
+ }
+
+ struct strbuf fullpath = STRBUF_INIT;
+ strbuf_addf(&fullpath, "%s%s", base->buf, pathname);
+ !}
+
+ {# File icon #}
+ {% if S_ISGITLINK(mode) %}
+ {# Heroicons solid folder #}
+
+ {% elif S_ISDIR(mode) %}
+ {# Heroicons solid folder #}
+
+ {% else %}
+ {# Heroicons outline document #}
+
+ {% endif %}
+
+
+ {# File name and link #}
+ {% if S_ISGITLINK(mode) %}
+ {! cgit_submodule_link("ls-mod", fullpath.buf, pathname, oid_to_hex(oid)); !}
+ {% else %}
+
+ {{ pathname }}
+
+ {% endif %}
+
+
+ {# Mode #}
+ {! cgit_print_filemode(mode); !}
+
+
+ {# File size #}
+ {% if !S_ISGITLINK(mode) && !S_ISDIR(mode) %}
+ {{ size|%ld }}
+ {% endif %}
+
+ {! strbuf_release(&fullpath); !}
+{% endblock %}
diff --git a/ui-plain.c b/ui-plain.c
index 4d69607..d087a63 100644
--- a/ui-plain.c
+++ b/ui-plain.c
@@ -118,7 +118,7 @@ static void print_dir_entry(const struct object_id *oid, const char *base,
fullpath[strlen(fullpath) - 1] = 0;
html(" ");
if (S_ISGITLINK(mode)) {
- cgit_submodule_link(NULL, fullpath, oid_to_hex(oid));
+ cgit_submodule_link(NULL, fullpath, NULL, oid_to_hex(oid));
} else
cgit_plain_link(path, NULL, NULL, ctx.qry.head, ctx.qry.oid,
fullpath);
diff --git a/ui-shared.c b/ui-shared.c
index 9c846b6..92d399f 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -675,7 +675,7 @@ static struct string_list_item *lookup_path(struct string_list *list,
return NULL;
}
-void cgit_submodule_link(const char *class, char *path, const char *rev)
+void cgit_submodule_link(const char *class, char *path, const char *display_name, const char *rev)
{
struct string_list *list;
struct string_list_item *item;
@@ -710,14 +710,14 @@ void cgit_submodule_link(const char *class, char *path, const char *rev)
html_attrf(ctx.repo->module_link, dir, rev);
}
html("'>");
- html_txt(path);
+ html_txt(display_name ? display_name : path);
html("");
} else {
html("");
- html_txt(path);
+ html_txt(display_name ? display_name : path);
html("");
}
html_txtf(" @ %.7s", rev);
diff --git a/ui-shared.h b/ui-shared.h
index 62db46a..5152030 100644
--- a/ui-shared.h
+++ b/ui-shared.h
@@ -62,7 +62,7 @@ extern void cgit_stats_link(const char *name, const char *title,
extern void cgit_object_link(struct object *obj);
extern void cgit_submodule_link(const char *class, char *path,
- const char *rev);
+ const char *display_name, const char *rev);
extern void cgit_print_layout_start(void);
extern void cgit_print_layout_end(void);
diff --git a/ui-tree.c b/ui-tree.c
index dbce43e..0dff599 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -240,7 +240,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,
cgit_print_filemode(mode);
html("");
if (S_ISGITLINK(mode)) {
- cgit_submodule_link("ls-mod", fullpath.buf, oid_to_hex(oid));
+ cgit_submodule_link("ls-mod", fullpath.buf, NULL, oid_to_hex(oid));
} else if (S_ISDIR(mode)) {
write_tree_link(oid, name, walk_tree_ctx->curr_rev,
&fullpath);
|