diff options
authorAndy Green <andy@warmcat.com>2018-06-18 14:24:36 +0800
committerAndy Green <andy@warmcat.com>2018-06-29 07:53:21 +0800
commitc51a6414559ff8e6fca77cb8ffc5dc73f2bc0460 (patch)
parentui-tree: ls_tail: add walk table param (diff)
config: add global inline-readme list
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@warmcat.com>
3 files changed, 15 insertions, 1 deletions
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@lists.zx2c4.com>
+ * Copyright (C) 2006-2018 cgit Development Team <cgit@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 5dc77db..981524a 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".
+ 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'.
Flag which, if set to "1", makes cgit print commit and tag times in the
servers timezone. Default value: "0".