extra-head-content: introduce another option for meta tags

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>
Цей коміт міститься в:
Jason A. Donenfeld
2018-02-12 23:10:06 +01:00
джерело c4fbb99cee
коміт b522a302c9
5 змінених файлів з 12 додано та 0 видалено

4
cgit.c
Переглянути файл

@@ -46,6 +46,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va
repo->homepage = xstrdup(value); repo->homepage = xstrdup(value);
else if (!strcmp(name, "defbranch")) else if (!strcmp(name, "defbranch"))
repo->defbranch = xstrdup(value); repo->defbranch = xstrdup(value);
else if (!strcmp(name, "extra-head-content"))
repo->extra_head_content = xstrdup(value);
else if (!strcmp(name, "snapshots")) else if (!strcmp(name, "snapshots"))
repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value); repo->snapshots = ctx.cfg.snapshots & cgit_parse_snapshots_mask(value);
else if (!strcmp(name, "enable-commit-graph")) else if (!strcmp(name, "enable-commit-graph"))
@@ -797,6 +799,8 @@ static void print_repo(FILE *f, struct cgit_repo *repo)
} }
if (repo->defbranch) if (repo->defbranch)
fprintf(f, "repo.defbranch=%s\n", 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) if (repo->module_link)
fprintf(f, "repo.module-link=%s\n", repo->module_link); fprintf(f, "repo.module-link=%s\n", repo->module_link);
if (repo->section) if (repo->section)

1
cgit.h
Переглянути файл

@@ -81,6 +81,7 @@ struct cgit_repo {
char *name; char *name;
char *path; char *path;
char *desc; char *desc;
char *extra_head_content;
char *owner; char *owner;
char *homepage; char *homepage;
char *defbranch; char *defbranch;

Переглянути файл

@@ -509,6 +509,10 @@ repo.enable-subject-links::
A flag which can be used to override the global setting A flag which can be used to override the global setting
`enable-subject-links'. Default value: none. `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:: repo.hide::
Flag which, when set to "1", hides the repository from the repository 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. The repository can still be accessed by providing a direct path.

Переглянути файл

@@ -53,6 +53,7 @@ struct cgit_repo *cgit_add_repo(const char *url)
ret->name = ret->url; ret->name = ret->url;
ret->path = NULL; ret->path = NULL;
ret->desc = cgit_default_repo_desc; ret->desc = cgit_default_repo_desc;
ret->extra_head_content = NULL;
ret->owner = NULL; ret->owner = NULL;
ret->homepage = NULL; ret->homepage = NULL;
ret->section = ctx.cfg.section; ret->section = ctx.cfg.section;

Переглянути файл

@@ -775,6 +775,8 @@ void cgit_print_docstart(void)
cgit_add_clone_urls(print_rel_vcs_link); cgit_add_clone_urls(print_rel_vcs_link);
if (ctx.cfg.head_include) if (ctx.cfg.head_include)
html_include(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("</head>\n");
html("<body>\n"); html("<body>\n");
if (ctx.cfg.header) if (ctx.cfg.header)