]> git.cameronkatri.com Git - cgit.git/commitdiff
extra-head-content: introduce another option for meta tags
authorJason A. Donenfeld <Jason@zx2c4.com>
Mon, 12 Feb 2018 22:10:06 +0000 (23:10 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 3 Jul 2018 18:37:00 +0000 (20:37 +0200)
This is to support things like go-import meta tags, which are on a
per-repo basis.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
cgit.c
cgit.h
cgitrc.5.txt
shared.c
ui-shared.c

diff --git a/cgit.c b/cgit.c
index 0c9f3e9a1b3cf854e39f8cffc432201cdd1be183..e2d789101f302a6ad4b580146e1615968a7a91e9 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -46,6 +46,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
                repo->homepage = xstrdup(value);
        else if (!strcmp(name, "defbranch"))
                repo->defbranch = xstrdup(value);
+       else if (!strcmp(name, "extra-head-content"))
+               repo->extra_head_content = xstrdup(value);
        else if (!strcmp(name, "snapshots"))
                repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
        else if (!strcmp(name, "enable-commit-graph"))
@@ -797,6 +799,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
        }
        if (repo->defbranch)
                fprintf(f, "repo.defbranch=%s\n", repo->defbranch);
+       if (repo->extra_head_content)
+               fprintf(f, "repo.extra-head-content=%s\n", repo->extra_head_content);
        if (repo->module_link)
                fprintf(f, "repo.module-link=%s\n", repo->module_link);
        if (repo->section)
diff --git a/cgit.h b/cgit.h
index 6feca688d91c3b09121bd4776720471bffbba76b..32dfd7a6b741db6d1b87aa9807bf8a69e5b3f70b 100644 (file)
--- a/cgit.h
+++ b/cgit.h
@@ -81,6 +81,7 @@ struct cgit_repo {
        char *name;
        char *path;
        char *desc;
+       char *extra_head_content;
        char *owner;
        char *homepage;
        char *defbranch;
index f6f6502fa2df7d754c8b698d9f54c67dc460a3cd..6f008ccb88f750d3fc274b3f3c9ce7b088f21ec1 100644 (file)
@@ -509,6 +509,10 @@ repo.enable-subject-links::
        A flag which can be used to override the global setting
        `enable-subject-links'. Default value: none.
 
+repo.extra-head-content::
+       This value will be added verbatim to the head section of each page
+       displayed for this repo. Default value: none.
+
 repo.hide::
        Flag which, when set to "1", hides the repository from the repository
        index. The repository can still be accessed by providing a direct path.
index d7c7636913a063cfc45eadab85f282a2bf5b6cc3..f7b64cf317ced6a7dd5ce33fce48e74c149c0e5f 100644 (file)
--- a/shared.c
+++ b/shared.c
@@ -53,6 +53,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
        ret->name = ret->url;
        ret->path = NULL;
        ret->desc = cgit_default_repo_desc;
+       ret->extra_head_content = NULL;
        ret->owner = NULL;
        ret->homepage = NULL;
        ret->section = ctx.cfg.section;
index a63dcb041d99cdf65d101bd98bcc19059e329d94..9a2e382b62abfe6241123711a88223da8cfb59ab 100644 (file)
@@ -775,6 +775,8 @@ void cgit_print_docstart(void)
                cgit_add_clone_urls(print_rel_vcs_link);
        if (ctx.cfg.head_include)
                html_include(ctx.cfg.head_include);
+       if (ctx.repo && ctx.repo->extra_head_content)
+               html(ctx.repo->extra_head_content);
        html("</head>\n");
        html("<body>\n");
        if (ctx.cfg.header)