]> granicus.if.org Git - cgit/commitdiff
config: add repo inline-readme list
authorAndy Green <andy@warmcat.com>
Mon, 18 Jun 2018 06:24:57 +0000 (14:24 +0800)
committerAndy Green <andy@warmcat.com>
Thu, 28 Jun 2018 23:53:21 +0000 (07:53 +0800)
This allows the user to choose to override any global
inline-readme list for a specific repo, using the
same kind of semantics as the other repo overrides.

Signed-off-by: Andy Green <andy@warmcat.com>
Reviewed-by: John Keeping <john@keeping.me.uk>
cgit.c
cgit.h
cgitrc.5.txt
shared.c

diff --git a/cgit.c b/cgit.c
index bf621998a8707cb5d9443e8a72dc0e9c0b95da86..bdb2fadee562f337dcfb565c17b742ada08cda1a 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -105,7 +105,12 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
                repo->hide = atoi(value);
        else if (!strcmp(name, "ignore"))
                repo->ignore = atoi(value);
-       else if (ctx.cfg.enable_filter_overrides) {
+       else if (!strcmp(name, "inline-readme")) {
+               if (repo->inline_readme.items == ctx.cfg.inline_readme.items)
+                       string_list_init(&repo->inline_readme, 1);
+
+               string_list_append(&repo->inline_readme, value);
+       } else if (ctx.cfg.enable_filter_overrides) {
                if (!strcmp(name, "about-filter"))
                        repo->about_filter = cgit_new_filter(value, ABOUT);
                else if (!strcmp(name, "commit-filter"))
diff --git a/cgit.h b/cgit.h
index 981524a982e98516902d210f2393479757d6bfd0..999db9e386db59b944065ce0feb5539e3948a551 100644 (file)
--- a/cgit.h
+++ b/cgit.h
@@ -86,6 +86,7 @@ struct cgit_repo {
        char *defbranch;
        char *module_link;
        struct string_list readme;
+       struct string_list inline_readme;
        char *section;
        char *clone_url;
        char *logo;
index 7ca8de99665c707b4cca3b8f721598def2d65def..62d7c2adb8f20bb261b44a770e937436a9f4e22f 100644 (file)
@@ -544,6 +544,16 @@ repo.ignore::
        is not shown in the index and cannot be accessed by providing a direct
        path. Default value: "0". See also: "repo.hide".
 
+repo.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,
+       'repo.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'.
+       If not given, the repo will use any global 'inline-readme=' configuration;
+       if any 'repo.inline-readme' are given only they are used for that repo,
+       and the global 'inline-readme=' list is ignored for that repo.
+
 repo.logo::
        Url which specifies the source of an image which will be used as a logo
        on this repo's pages. Default value: global logo.
index aad0024c81b29fe2ba5bd7a35d19151527e3bf89..3d7296d4245f7015e22ab40311231d66ded47092 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -77,6 +77,8 @@ struct cgit_repo *cgit_add_repo(const char *url)
        ret->clone_url = ctx.cfg.clone_url;
        ret->submodules.strdup_strings = 1;
        ret->hide = ret->ignore = 0;
+       ret->inline_readme = ctx.cfg.inline_readme;
+
        return ret;
 }