[PATCH 10/11] config: add tree-readme list

Andy Green andy at warmcat.com
Wed Jun 13 04:02:20 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       |   11 ++++++++++-
 cgit.h       |    1 +
 cgitrc.5.txt |    7 +++++++
 3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/cgit.c b/cgit.c
index 975e573..017ce78 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)
@@ -39,6 +39,12 @@ static void add_render_filter(const char *name, const char *cmd)
 	item->util = filter;
 }
 
+static void add_tree_readme(const char *name)
+{
+	string_list_insert(&ctx.cfg.tree_readme, name);
+}
+
+
 static void process_cached_repolist(const char *path);
 
 static void repo_config(struct cgit_repo *repo, const char *name, const char *value)
@@ -301,6 +307,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, "tree-readme"))
+		add_tree_readme(value);
 	else if (!strcmp(name, "include"))
 		parse_configfile(expand_macros(value), config_cb);
 }
@@ -435,6 +443,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.tree_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 a19742f..1076568 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 tree_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 793a0c1..5111197 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -469,6 +469,13 @@ strict-export::
 	repositories to match those exported by git-daemon. This option must
 	be defined prior to scan-path.
 
+tree-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,
+	'tree-readme=README.md'.  There must also be a corresponding render.
+	entry for the readme suffix, eg,
+	'render.md=/usr/libexec/cgit/filters/html-converters/md2html'
+
 virtual-root::
 	Url which, if specified, will be used as root for all cgit links. It
 	will also cause cgit to generate 'virtual urls', i.e. urls like



More information about the CGit mailing list