diff --git a/cgit.mk b/cgit.mk index 9c37954..e0e29a4 100644 --- a/cgit.mk +++ b/cgit.mk @@ -98,6 +98,13 @@ CGIT_OBJ_NAMES += ui-tree.o 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/index.html +CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/commit.html +CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/log.html +CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/refs.html +CGIT_THEMED_INPUTS += $(CGIT_PREFIX)themed/summary.html + CGIT_OBJS := $(addprefix $(CGIT_PREFIX),$(CGIT_OBJ_NAMES)) # Only cgit.c reference CGIT_VERSION so we only rebuild its objects when the @@ -129,11 +136,11 @@ $(CGIT_PREFIX).depend: $(CGIT_PREFIX)themed/.depend: @mkdir -p $@ -$(CGIT_PREFIX)themed/themed.c: $(CGIT_PREFIX)themed/base.html $(CGIT_PREFIX)themed/index.html $(CGIT_PREFIX)themed/commit.html $(CGIT_PREFIX)themed/log.html $(CGIT_PREFIX)themed/refs.html +$(CGIT_PREFIX)themed/themed.c: $(CGIT_THEMED_INPUTS) cd $(CGIT_PREFIX)themed; python -m htmlcc $^ > $@ -$(CGIT_PREFIX)themed/themed.css: $(CGIT_PREFIX)themed/themed.in.css - cd $(CGIT_PREFIX)themed; tailwindcss -i $^ -o $@ +$(CGIT_PREFIX)themed/themed.css: $(CGIT_PREFIX)themed/themed.in.css $(CGIT_THEMED_INPUTS) + cd $(CGIT_PREFIX)themed; tailwindcss -i $< -o $@ $(CGIT_PREFIX)CGIT-CFLAGS: FORCE @FLAGS='$(subst ','\'',$(CGIT_CFLAGS))'; \ diff --git a/themed/summary.html b/themed/summary.html new file mode 100644 index 0000000..9bd3004 --- /dev/null +++ b/themed/summary.html @@ -0,0 +1,98 @@ +{! #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 %} +
+
{{ pathname }}
+
{! 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); + return 0; + } +!} + +{% page cgit_print_summary %} +{! page_start(); !} +{! repo_header(); !} +
{# Main content #} +{! repo_description_panel(); !} +{! repo_summary_bar(); !} +
+ {# Latest commit panel (specify rounded-t-md so background does not cover border) #} + {! + // Get latest commit + struct object_id oid; + if (repo_get_oid(the_repository, ctx.qry.head, &oid)) { + die("Bad object id"); + } + struct commit *commit = lookup_commit_reference(the_repository, &oid); + if (!commit) { + die("Bad commit reference"); + } + struct commitinfo *info = cgit_parse_commit(commit); + !} +
+ + {{ info->author }} + object.oid) }}" class="ml-2 text-gray-500 hover:text-blue-600 hover:underline">{{ info->subject }} +
+ {! char short_commit_id[8]; !} + {! memcpy(short_commit_id, oid_to_hex(&commit->object.oid), 7); !} + {! short_commit_id[7] = '\0'; !} + object.oid) }}" class="font-mono hover:text-blue-600 hover:underline">{{ short_commit_id }} · {! cgit_print_age(info->committer_date, info->committer_tz, TM_WEEK * 2); !} ago +
+ {# Files #} + {! + const struct object_id *tree_oid = get_commit_tree_oid(commit); + struct tree *tree = parse_tree_indirect(tree_oid); + struct pathspec paths = { + .nr = 0 + }; + read_tree(the_repository, tree, &paths, ls_item, NULL); + !} +
+ {% if ctx.repo->readme.nr > 0 %} + {! + char *filename = ctx.repo->readme.items[0].string; + char *ref = ctx.repo->readme.items[0].util; + !} +
+ {# Readme panel #} +
+ {# Heroicons micro book-open #} + + {{ filename }} +
+ {# Readme content #} +
+ {! + cgit_open_filter(ctx.repo->about_filter, filename); + if (ref) { + cgit_print_file(filename, ref, 1); + } else { + html_include(filename); + } + cgit_close_filter(ctx.repo->about_filter); + !} +
+
+ {% endif %} +
+{! page_end(); !} +{% endpage %} diff --git a/themed/themed.in.css b/themed/themed.in.css index 9ab4c72..336859d 100644 --- a/themed/themed.in.css +++ b/themed/themed.in.css @@ -8,6 +8,18 @@ font-size: 11pt; } +.rendered-file { + a { + @apply hover:underline; + } + :not(h1, h2, h3, h4, h5, h6) > a { + @apply text-blue-500 hover:text-blue-600; + } + ul { + @apply list-disc; + } +} + .diff-panel { a { @apply text-blue-500 hover:text-blue-600 hover:underline; diff --git a/ui-summary.c b/ui-summary.c index b855267..1752e20 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -40,7 +40,7 @@ static void print_url(const char *url) html("\n"); } -void cgit_print_summary(void) +void _orig_cgit_print_summary(void) { int columns = 3;