From d20f16f384ab10353a21d5776d47a81dda188b85 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sun, 24 Aug 2025 03:58:15 +0000 Subject: print repo readme with summary --- cmd.c | 2 +- ui-summary.c | 21 +++++++++++++++------ ui-summary.h | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cmd.c b/cmd.c index 0eb75b1..3342843 100644 --- a/cmd.c +++ b/cmd.c @@ -50,7 +50,7 @@ static void about_fn(void) free(currenturl); free(redirect); } else if (ctx.repo->readme.nr) - cgit_print_repo_readme(ctx.qry.path); + cgit_print_repo_readme(ctx.qry.path, true); else if (ctx.repo->homepage) cgit_redirect(ctx.repo->homepage, false); else { diff --git a/ui-summary.c b/ui-summary.c index 947812a..6e04c55 100644 --- a/ui-summary.c +++ b/ui-summary.c @@ -62,6 +62,7 @@ void cgit_print_summary(void) urls = 0; cgit_add_clone_urls(print_url); html(""); + cgit_print_repo_readme(ctx.qry.path, false); cgit_print_layout_end(); } @@ -99,22 +100,25 @@ static char* append_readme_path(const char *filename, const char *ref, const cha return full_path; } -void cgit_print_repo_readme(const char *path) +void cgit_print_repo_readme(const char *path, bool page) { char *filename, *ref, *mimetype; int free_filename = 0; mimetype = get_mimetype_for_filename(path); if (mimetype && (!strncmp(mimetype, "image/", 6) || !strncmp(mimetype, "video/", 6))) { - ctx.page.mimetype = mimetype; - ctx.page.charset = NULL; - cgit_print_plain(); + if (page) { + ctx.page.mimetype = mimetype; + ctx.page.charset = NULL; + cgit_print_plain(); + } free(mimetype); return; } free(mimetype); - cgit_print_layout_start(); + if (page) + cgit_print_layout_start(); if (ctx.repo->readme.nr == 0) goto done; @@ -131,6 +135,10 @@ void cgit_print_repo_readme(const char *path) /* Print the calculated readme, either from the git repo or from the * filesystem, while applying the about-filter. */ + if (!page) { + html(""); + html("
"); + } html("
"); cgit_open_filter(ctx.repo->about_filter, filename); if (ref) @@ -144,5 +152,6 @@ void cgit_print_repo_readme(const char *path) free(filename); done: - cgit_print_layout_end(); + if (page) + cgit_print_layout_end(); } diff --git a/ui-summary.h b/ui-summary.h index cba696a..5e7cf2d 100644 --- a/ui-summary.h +++ b/ui-summary.h @@ -2,6 +2,6 @@ #define UI_SUMMARY_H extern void cgit_print_summary(void); -extern void cgit_print_repo_readme(const char *path); +extern void cgit_print_repo_readme(const char *path, bool page); #endif /* UI_SUMMARY_H */ -- cgit v1.2.3-freya