]> granicus.if.org Git - cgit/commitdiff
config: add global inline-readme list
authorAndy Green <andy@warmcat.com>
Mon, 18 Jun 2018 06:24:36 +0000 (14:24 +0800)
committerAndy Green <andy@warmcat.com>
Thu, 28 Jun 2018 23:53:21 +0000 (07:53 +0800)
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>
cgit.c
cgit.h
cgitrc.5.txt

diff --git a/cgit.c b/cgit.c
index e0e94d56b1f8e232899bde6a55d5fb077a1f7633..bf621998a8707cb5d9443e8a72dc0e9c0b95da86 100644 (file)
--- 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 5dc77dbaf7c51405805ee637716d079d1dcf8c39..981524a982e98516902d210f2393479757d6bfd0 100644 (file)
--- 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;
index 34b618680b88c7ff81748f53fce906c033725570..7ca8de99665c707b4cca3b8f721598def2d65def 100644 (file)
@@ -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".