[PATCH] extra-head-content: introduce another option for meta tags
John Keeping
john at keeping.me.uk
Sat Feb 17 15:00:31 CET 2018
On Mon, Feb 12, 2018 at 11:34:53PM +0100, Jason A. Donenfeld wrote:
> This is to support things like go-import meta tags, which are on a
> per-repo basis.
>
> Signed-off-by: Jason A. Donenfeld <Jason at zx2c4.com>
> ---
> This is kind of really ugly, and I'm not keen on its approach, but I
> thought I'd post it to get some feedback on the general "requirement".
> It turns out, the ugly Go ecosystem requires meta tags like these to
> function:
>
> <meta name="go-import" content="git.zx2c4.com/terrible-go-package git https://git.zx2c4.com/terrible-go-package" />
>
> The question is: is cgit a good place for doing this? Is this here,
> below, actually a good way of going about it, if so?
It looks like it's generally expected that imports can use the path to
the Git repo, so I think it is reasonable for CGit to add these tags.
However, I wonder if extra-head-content is too generic. Should we just
accept that "support meta go-import" is a feature and have a cgitrc
option for "go-import-url" a bit like the existing clone-url option?
> cgit.c | 4 ++++
> cgit.h | 1 +
> cgitrc.5.txt | 4 ++++
> shared.c | 1 +
> ui-shared.c | 2 ++
> 5 files changed, 12 insertions(+)
>
> diff --git a/cgit.c b/cgit.c
> index bd9cb3f..cf65bbd 100644
> --- 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"))
> @@ -802,6 +804,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 005ae63..edec271 100644
> --- a/cgit.h
> +++ b/cgit.h
> @@ -79,6 +79,7 @@ struct cgit_repo {
> char *name;
> char *path;
> char *desc;
> + char *extra_head_content;
> char *owner;
> char *homepage;
> char *defbranch;
> diff --git a/cgitrc.5.txt b/cgitrc.5.txt
> index 4da166c..fa2fbfc 100644
> --- a/cgitrc.5.txt
> +++ b/cgitrc.5.txt
> @@ -501,6 +501,10 @@ repo.defbranch::
> repo.desc::
> The value to show as repository description. 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.homepage::
> The value to show as repository homepage. Default value: none.
>
> diff --git a/shared.c b/shared.c
> index 21ac8f4..d0405cf 100644
> --- 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;
> diff --git a/ui-shared.c b/ui-shared.c
> index 9d8f66b..5197cd6 100644
> --- a/ui-shared.c
> +++ b/ui-shared.c
> @@ -766,6 +766,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)
> --
> 2.16.1
>
> _______________________________________________
> CGit mailing list
> CGit at lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/cgit
More information about the CGit
mailing list