aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cgit.c6
-rw-r--r--cgit.h2
-rw-r--r--cgitrc.5.txt9
-rw-r--r--shared.c1
-rw-r--r--ui-summary.c44
5 files changed, 46 insertions, 16 deletions
diff --git a/cgit.c b/cgit.c
index ca318e8..8bda5c9 100644
--- a/cgit.c
+++ b/cgit.c
@@ -72,6 +72,8 @@ void cgit_repo_config(struct cgit_repo *repo, const char *name, const char *valu
repo->enable_log_filecount = atoi(value);
else if (!strcmp(name, "enable-log-linecount"))
repo->enable_log_linecount = atoi(value);
+ else if (!strcmp(name, "enable-summary-readme"))
+ repo->enable_summary_readme = atoi(value);
else if (!strcmp(name, "enable-remote-branches"))
repo->enable_remote_branches = atoi(value);
else if (!strcmp(name, "enable-subject-links"))
@@ -191,6 +193,8 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.enable_log_filecount = atoi(value);
else if (!strcmp(name, "enable-log-linecount"))
ctx.cfg.enable_log_linecount = atoi(value);
+ else if (!strcmp(name, "enable-summary-readme"))
+ ctx.cfg.enable_summary_readme = atoi(value);
else if (!strcmp(name, "enable-remote-branches"))
ctx.cfg.enable_remote_branches = atoi(value);
else if (!strcmp(name, "enable-subject-links"))
@@ -824,6 +828,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
repo->enable_log_filecount);
fprintf(f, "repo.enable-log-linecount=%d\n",
repo->enable_log_linecount);
+ fprintf(f, "repo.enable-summary-readme=%d\n",
+ repo->enable_summary_readme);
if (repo->about_filter && repo->about_filter != ctx.cfg.about_filter)
cgit_fprintf_filter(repo->about_filter, f, "repo.about-filter=");
if (repo->commit_filter && repo->commit_filter != ctx.cfg.commit_filter)
diff --git a/cgit.h b/cgit.h
index 7d7ece7..9b89c8f 100644
--- a/cgit.h
+++ b/cgit.h
@@ -107,6 +107,7 @@ struct cgit_repo {
int enable_remote_branches;
int enable_subject_links;
int enable_html_serving;
+ int enable_summary_readme;
int max_stats;
int branch_sort;
int commit_sort;
@@ -241,6 +242,7 @@ struct cgit_config {
int enable_remote_branches;
int enable_subject_links;
int enable_html_serving;
+ int enable_summary_readme;
int enable_tree_linenumbers;
int enable_git_config;
int local_time;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 7c39bf9..57839e4 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -197,6 +197,11 @@ enable-log-filecount::
modified files for each commit on the repository log page. Default
value: "0".
+enable-summary-readme::
+ Flag which, when set to "1", will make cgit render the repository's
+ readme (see 'readme') inline below the info on the repo summary page,
+ in addition to the standard "about" page. Default value: "0".
+
enable-log-linecount::
Flag which, when set to "1", will make cgit print the number of added
and removed lines for each commit on the repository log page. Default
@@ -519,6 +524,10 @@ repo.enable-log-linecount::
A flag which can be used to disable the global setting
`enable-log-linecount'. Default value: none.
+repo.enable-summary-readme::
+ A flag which can be used to override the global setting
+ `enable-summary-readme'. Default value: none.
+
repo.enable-remote-branches::
Flag which, when set to "1", will make cgit display remote branches
in the summary and refs views. Default value: <enable-remote-branches>.
diff --git a/shared.c b/shared.c
index a39394d..2c891be 100644
--- a/shared.c
+++ b/shared.c
@@ -68,6 +68,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->enable_log_linecount = ctx.cfg.enable_log_linecount;
ret->enable_remote_branches = ctx.cfg.enable_remote_branches;
ret->enable_subject_links = ctx.cfg.enable_subject_links;
+ ret->enable_summary_readme = ctx.cfg.enable_summary_readme;
ret->enable_html_serving = ctx.cfg.enable_html_serving;
ret->max_stats = ctx.cfg.max_stats;
ret->branch_sort = ctx.cfg.branch_sort;
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();
}