[PATCH v4 08/16] config: add global inline-readme list

Andy Green andy at warmcat.com
Wed Jun 20 12:12:39 CEST 2018


Allows the user to specify a list of filenames that should be
rendered inline with tree view, if present in the directory.

Signed-off-by: Andy Green <andy at warmcat.com>
---
 cgit.c       |    5 ++++-
 cgit.h       |    1 +
 cgitrc.5.txt |   10 ++++++++++
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/cgit.c b/cgit.c
index e0e94d5..bf62199 100644
--- a/cgit.c
+++ b/cgit.c
@@ -1,6 +1,6 @@
 /* cgit.c: cgi for the git scm
  *
- * Copyright (C) 2006-2014 cgit Development Team <cgit at lists.zx2c4.com>
+ * Copyright (C) 2006-2018 cgit Development Team <cgit at lists.zx2c4.com>
  *
  * Licensed under GNU General Public License v2
  *   (see COPYING for full license text)
@@ -297,6 +297,8 @@ static void config_cb(const char *name, const char *value)
 		add_mimetype(name + 9, value);
 	else if (starts_with(name, "render."))
 		add_render_filter(name + 7, value);
+	else if (!strcmp(name, "inline-readme"))
+		string_list_insert(&ctx.cfg.inline_readme, value);
 	else if (!strcmp(name, "include"))
 		parse_configfile(expand_macros(value), config_cb);
 }
@@ -430,6 +432,7 @@ static void prepare_context(void)
 	ctx.page.etag = NULL;
 	string_list_init(&ctx.cfg.mimetypes, 1);
 	string_list_init(&ctx.cfg.render_filters, 1);
+	string_list_init(&ctx.cfg.inline_readme, 1);
 	if (ctx.env.script_name)
 		ctx.cfg.script_name = xstrdup(ctx.env.script_name);
 	if (ctx.env.query_string)
diff --git a/cgit.h b/cgit.h
index 3149946..79605e7 100644
--- a/cgit.h
+++ b/cgit.h
@@ -261,6 +261,7 @@ struct cgit_config {
 	int branch_sort;
 	int commit_sort;
 	struct string_list mimetypes;
+	struct string_list inline_readme;
 	struct string_list render_filters;
 	struct cgit_filter *about_filter;
 	struct cgit_filter *commit_filter;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 34b6186..7ca8de9 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -238,6 +238,16 @@ include::
 	Name of a configfile to include before the rest of the current config-
 	file is parsed. Default value: none. See also: "MACRO EXPANSION".
 
+inline-readme::
+	Append given filename to the list of filenames to be rendered after the
+	tree navigation in tree view, if present in the directory being viewed.  Eg,
+	'inline-readme=README.md'.  You may also want a corresponding render.
+	entry for the readme suffix, eg,
+	'render.md=/usr/libexec/cgit/filters/html-converters/md2html'.  Repos will
+	use the list defined with 'inline-readme' by default, however they can
+	individually also choose to ignore this global list, and create a
+	repo-specific list by using 'repo.inline-readme'.
+
 local-time::
 	Flag which, if set to "1", makes cgit print commit and tag times in the
 	servers timezone. Default value: "0".



More information about the CGit mailing list