From mboxrd@z Thu Jan 1 00:00:00 1970 From: andy at warmcat.com (Andy Green) Date: Mon, 18 Jun 2018 10:58:05 +0800 Subject: [PATCH v2 10/15] config: add global inline-readme list In-Reply-To: <152928998685.10419.7869045561776063625.stgit@mail.warmcat.com> References: <152928998685.10419.7869045561776063625.stgit@mail.warmcat.com> Message-ID: <152929068560.10419.9276417651833254121.stgit@mail.warmcat.com> 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 --- cgit.c | 5 ++++- cgit.h | 1 + cgitrc.5.txt | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/cgit.c b/cgit.c index 975e573..4ffd61f 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 + * Copyright (C) 2006-2018 cgit Development Team * * Licensed under GNU General Public License v2 * (see COPYING for full license text) @@ -301,6 +301,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); } @@ -435,6 +437,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 a19742f..664f003 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 a1560eb..37858af 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -250,6 +250,13 @@ index-info:: is deprecated, and will not be supported by cgit-1.0 (use root-desc instead). Default value: none. +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' + local-time:: Flag which, if set to "1", makes cgit print commit and tag times in the servers timezone. Default value: "0".