aboutsummaryrefslogtreecommitdiffstats
path: root/ui-summary.c
diff options
context:
space:
mode:
Diffstat (limited to 'ui-summary.c')
-rw-r--r--ui-summary.c44
1 files changed, 28 insertions, 16 deletions
diff --git a/ui-summary.c b/ui-summary.c
index 947812a..be3c3d9 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -17,6 +17,8 @@
static int urls;
+static void print_readme(const char *path);
+
static void print_url(const char *url)
{
int columns = 3;
@@ -62,6 +64,8 @@ void cgit_print_summary(void)
urls = 0;
cgit_add_clone_urls(print_url);
html("</table>");
+ if (ctx.repo->enable_summary_readme)
+ print_readme(NULL);
cgit_print_layout_end();
}
@@ -99,24 +103,16 @@ static char* append_readme_path(const char *filename, const char *ref, const cha
return full_path;
}
-void cgit_print_repo_readme(const char *path)
+/* Render the configured readme (filtered through the about-filter). The caller
+ * is responsible for opening/closing the page layout, so this can be reused by
+ * both the about page and the repo summary page. */
+static void print_readme(const char *path)
{
- char *filename, *ref, *mimetype;
+ char *filename, *ref;
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();
- free(mimetype);
- return;
- }
- free(mimetype);
-
- cgit_print_layout_start();
if (ctx.repo->readme.nr == 0)
- goto done;
+ return;
filename = ctx.repo->readme.items[0].string;
ref = ctx.repo->readme.items[0].util;
@@ -125,7 +121,7 @@ void cgit_print_repo_readme(const char *path)
free_filename = 1;
filename = append_readme_path(filename, ref, path);
if (!filename)
- goto done;
+ return;
}
/* Print the calculated readme, either from the git repo or from the
@@ -142,7 +138,23 @@ void cgit_print_repo_readme(const char *path)
html("</div>");
if (free_filename)
free(filename);
+}
-done:
+void cgit_print_repo_readme(const char *path)
+{
+ char *mimetype;
+
+ 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();
+ free(mimetype);
+ return;
+ }
+ free(mimetype);
+
+ cgit_print_layout_start();
+ print_readme(path);
cgit_print_layout_end();
}