From: Andy Green Date: Sun, 24 Jun 2018 00:13:05 +0000 (+0800) Subject: desc: add root-desc-html and repo.desc-html X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5eec453d44d48dc5f78a0aa98ac1a543ed185811;p=cgit desc: add root-desc-html and repo.desc-html These are optional, default-empty raw html strings that are emitted after the corresponding text-only versions root-desc and repo.desc when they are used in the header area. This provides a flexible way to place buttons or links in the header region for both the repo index page and for repos individually. The existing root-desc and repo.desc keep their original meaning as a shortish text-only repo description. The reason for that is the description is also used in places like the repo list, where any decoration is not wanted. Where root-desc and repo.desc are used in the header region, also emit their html counterparts afterwards if they are defined. Where root-desc are repo.desc are used outside the header, eg in the repo list, leave it as it is without adding any related html. It's possible to not define the text repo.desc and just define the repo.desc-html counterpart; only the html part is shown then. But results in the repo list page will then vary according to what's in the html (text size, pictures etc). Signed-off-by: Andy Green --- diff --git a/cgit.c b/cgit.c index 8b23c8f..2ae8895 100644 --- a/cgit.c +++ b/cgit.c @@ -52,6 +52,8 @@ static void repo_config(struct cgit_repo *repo, const char *name, const char *va repo->clone_url = xstrdup(value); else if (!strcmp(name, "desc")) repo->desc = xstrdup(value); + else if (!strcmp(name, "desc-html")) + repo->desc_html = xstrdup(value); else if (!strcmp(name, "owner")) repo->owner = xstrdup(value); else if (!strcmp(name, "homepage")) @@ -142,6 +144,8 @@ static void config_cb(const char *name, const char *value) ctx.cfg.root_title = xstrdup(value); else if (!strcmp(name, "root-desc")) ctx.cfg.root_desc = xstrdup(value); + else if (!strcmp(name, "root-desc-html")) + ctx.cfg.root_desc_html = xstrdup(value); else if (!strcmp(name, "root-readme")) ctx.cfg.root_readme = xstrdup(value); else if (!strcmp(name, "css")) diff --git a/cgit.h b/cgit.h index 582416e..cf91a96 100644 --- a/cgit.h +++ b/cgit.h @@ -81,6 +81,7 @@ struct cgit_repo { char *name; char *path; char *desc; + char *desc_html; char *owner; char *homepage; char *defbranch; @@ -208,6 +209,7 @@ struct cgit_config { char *robots; char *root_title; char *root_desc; + char *root_desc_html; char *root_readme; char *script_name; char *section; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 2737008..39f50c7 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -383,6 +383,10 @@ root-desc:: Text printed below the heading on the repository index page. Default value: "a fast webinterface for the git dscm". +root-desc-html:: + Optional additional raw html to show in the header after root-desc. + Default value: none. + root-readme:: The content of the file specified with this option will be included verbatim below the "about" link on the repository index page. Default @@ -508,6 +512,14 @@ repo.defbranch:: repo.desc:: The value to show as repository description. Default value: none. +repo.desc-html:: + Optional additional raw html to show in the header after repo.desc. + Default value: none. It's possible to leave repo.desc undefined, + and just define repo.desc-html. But it would mean the repo name + in the cgit repo list page will show the html parts. Depending on + the html, it may be preferable to define repo.desc so the repo list + can just use that and leave out the html. + repo.email-filter:: Override the default email-filter. Default value: none. See also: "enable-filter-overrides". See also: "FILTER API". diff --git a/ui-shared.c b/ui-shared.c index e1ff349..f519860 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -1028,12 +1028,19 @@ static void print_header(void) html(""); if (ctx.repo) { - html_txt(ctx.repo->desc); + if (ctx.repo->desc && + (ctx.repo->desc != cgit_default_repo_desc || + !ctx.repo->desc_html)) + html_txt(ctx.repo->desc); + if (ctx.repo->desc_html) + html(ctx.repo->desc_html); html(""); html_txt(ctx.repo->owner); } else { if (ctx.cfg.root_desc) html_txt(ctx.cfg.root_desc); + if (ctx.cfg.root_desc_html) + html(ctx.cfg.root_desc_html); } html("\n"); }