summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-08-24 03:58:15 +0000
committerFreya Murphy <freya@freyacat.org>2025-08-24 03:58:15 +0000
commitd20f16f384ab10353a21d5776d47a81dda188b85 (patch)
tree567e263643a1638f5b7e031d21930b8a6b0b8d9f
parentgit: update to v2.46.0 (diff)
downloadcgit-d20f16f384ab10353a21d5776d47a81dda188b85.tar.gz
cgit-d20f16f384ab10353a21d5776d47a81dda188b85.tar.bz2
cgit-d20f16f384ab10353a21d5776d47a81dda188b85.zip
print repo readme with summary
-rw-r--r--cmd.c2
-rw-r--r--ui-summary.c21
-rw-r--r--ui-summary.h2
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("</table>");
+ 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("</div>");
+ html("<div class=\"content\">");
+ }
html("<div id='summary'>");
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 */