diff options
| Commit | 63aa2ecd4e72800c11b08e4fb94234a117ece029 (patch) | |
|---|---|---|
| Author | 2026-09-27 22:04:58 +0300 | |
| Committer | 2026-09-27 22:17:41 +0300 | |
| Files | f399e7b86e2c450adc2a62b517af100db65c1b73 | |
| cgit-63aa2ecd4e72800c11b08e4fb94234a117ece029.tar cgit-63aa2ecd4e72800c11b08e4fb94234a117ece029.tar.gz cgit-63aa2ecd4e72800c11b08e4fb94234a117ece029.zip | ||
| Parent | 59125deae6522ca335a16c84a67e57e85edb88d6 (diff) | |
ui-summary: (THEME) Rework what is shown in summary page
Now clone and branches are shown next to commits and tags, branches only
show name and age, clone does not create links, and file listing
(alongside readme) is shown below
5 files changed, 103 insertions, 12 deletions
| -rw-r--r-- | ui-refs.c | 46 | ||||
| -rw-r--r-- | ui-refs.h | 1 | ||||
| -rw-r--r-- | ui-summary.c | 26 | ||||
| -rw-r--r-- | ui-tree.c | 41 | ||||
| -rw-r--r-- | ui-tree.h | 1 |
@@ -179,6 +179,52 @@ void cgit_print_branches(int maxcount) cgit_free_reflist_inner(&list); } +void cgit_print_branches_component(int maxcount) +{ + struct reflist list; + int i; + struct commitinfo *info; + char *name; + + html("<tr class='nohover'><th class='left'>Branch</th>" + "<th class='left'>Age</th></tr>\n"); + + list.refs = NULL; + list.alloc = list.count = 0; + refs_for_each_branch_ref(get_main_ref_store(the_repository), + cgit_refs_cb, &list); + if (ctx.repo->enable_remote_branches) + refs_for_each_remote_ref(get_main_ref_store(the_repository), + cgit_refs_cb, &list); + + if (maxcount == 0 || maxcount > list.count) + maxcount = list.count; + + qsort(list.refs, list.count, sizeof(*list.refs), cmp_branch_age); + if (ctx.repo->branch_sort == 0) + qsort(list.refs, maxcount, sizeof(*list.refs), cmp_ref_name); + + for (i = 0; i < maxcount; i++) { + info = list.refs[i]->commit; + name = (char *)list.refs[i]->refname; + + if (!info || list.refs[i]->object->type != OBJ_COMMIT) + continue; + + html("<tr><td>"); + cgit_log_link(name, NULL, NULL, name, NULL, NULL, 0, NULL, NULL, + ctx.qry.showmsg, 0); + html("</td><td>"); + cgit_print_age(info->committer_date, info->committer_tz, -1); + html("</td></tr>\n"); + } + + if (maxcount < list.count) + print_refs_link("heads"); + + cgit_free_reflist_inner(&list); +} + void cgit_print_tags(int maxcount) { struct reflist list; @@ -2,6 +2,7 @@ #define UI_REFS_H extern void cgit_print_branches(int maxcount); +extern void cgit_print_branches_component(int maxcount); extern void cgit_print_tags(int maxcount); extern void cgit_print_refs(void); diff --git a/ui-summary.c b/ui-summary.c index 77f4c48..199364d 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -14,12 +14,13 @@ #include "ui-plain.h" #include "ui-refs.h" #include "ui-shared.h" +#include "ui-tree.h" static int urls; static void print_url(const char *url) { - int columns = 3; + int columns = 2; if (ctx.repo->enable_log_filecount) columns++; @@ -27,17 +28,12 @@ static void print_url(const char *url) columns++; if (urls++ == 0) { - htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); htmlf("<tr class='nohover'><th class='left' colspan='%d'>Clone</th></tr>\n", columns); } - htmlf("<tr><td colspan='%d'><a rel='vcs-git' href='", columns); - html_url_path(url); - html("' title='"); - html_attr(ctx.repo->name); - html(" Git repository'>"); + htmlf("<tr><td colspan='%d' title='git clone %s'>", columns, url); html_txt(url); - html("</a></td></tr>\n"); + html("</td></tr>\n"); } void cgit_print_summary(void) @@ -50,18 +46,24 @@ void cgit_print_summary(void) columns++; cgit_print_layout_start(); + html("<table id='summary-info'><tr><td>"); html("<table summary='repository info' class='list nowrap'>"); - cgit_print_branches(ctx.cfg.summary_branches); - htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); - cgit_print_tags(ctx.cfg.summary_tags); if (ctx.cfg.summary_log > 0) { - htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); cgit_print_log(ctx.qry.head, 0, ctx.cfg.summary_log, NULL, NULL, NULL, 0, 0, 0); + htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); } + cgit_print_tags(ctx.cfg.summary_tags); urls = 0; + html("</table>"); + html("</td><td> </td><td>"); + html("<table class='list nowrap'>"); cgit_add_clone_urls(print_url); + htmlf("<tr class='nohover'><td colspan='%d'> </td></tr>", columns); + cgit_print_branches_component(ctx.cfg.summary_branches); html("</table>"); + html("</td></tr></table>"); + cgit_print_tree_component(ctx.qry.oid, ctx.qry.path); cgit_print_layout_end(); } @@ -431,3 +431,44 @@ void cgit_print_tree(const char *rev, char *path) cleanup: free(walk_tree_ctx.curr_rev); } + +void cgit_print_tree_component(const char *rev, char *path) +{ + struct object_id oid; + struct commit *commit; + struct walk_tree_context walk_tree_ctx = { + .match_path = path, + .state = 0 + }; + struct tree *tree; + struct pathspec paths = { + .nr = 0 + }; + + if (!rev) + rev = ctx.qry.head; + + if (path != NULL || repo_get_oid(the_repository, rev, &oid)) + return; + + commit = lookup_commit_reference(the_repository, &oid); + if (!commit || repo_parse_commit(the_repository, commit)) + return; + + walk_tree_ctx.curr_rev = xstrdup(rev); + + tree = parse_tree_indirect(get_commit_tree_oid(commit)); + if (tree) { + html("<table summary='tree listing' class='list'>\n"); + html("<tr class='nohover'>"); + html("<th class='left'>Name</th>"); + html("<th class='right'>Size</th>"); + html("<th/>"); + html("</tr>\n"); + read_tree(the_repository, tree, &paths, ls_item, &walk_tree_ctx); + html("</table>\n"); + cgit_print_repo_readme_component(ctx.qry.path); + } + + free(walk_tree_ctx.curr_rev); +} @@ -2,5 +2,6 @@ #define UI_TREE_H extern void cgit_print_tree(const char *rev, char *path); +extern void cgit_print_tree_component(const char *rev, char *path); #endif /* UI_TREE_H */ |
