From 093ac9697068833a15cae2dbbd5ffbc0203741c0 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Tue, 3 Jul 2018 11:33:59 +0800 Subject: css: change to be a list Without changing the default behaviour of including /cgit.css if nothing declared, allow the "css" config to be given multiple times listing one or more alternative URL paths to be included in the document head area. Signed-off-by: Andy Green Signed-off-by: Christian Hesse --- cgit.c | 3 +-- cgit.h | 2 +- cgitrc.5.txt | 3 ++- ui-shared.c | 21 ++++++++++++++++++--- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/cgit.c b/cgit.c index 133f454..75d9926 100644 --- a/cgit.c +++ b/cgit.c @@ -142,7 +142,7 @@ static void config_cb(const char *name, const char *value) else if (!strcmp(name, "root-readme")) ctx.cfg.root_readme = xstrdup(value); else if (!strcmp(name, "css")) - ctx.cfg.css = xstrdup(value); + string_list_append(&ctx.cfg.css, xstrdup(value)); else if (!strcmp(name, "favicon")) ctx.cfg.favicon = xstrdup(value); else if (!strcmp(name, "footer")) @@ -378,7 +378,6 @@ static void prepare_context(void) ctx.cfg.case_sensitive_sort = 1; ctx.cfg.branch_sort = 0; ctx.cfg.commit_sort = 0; - ctx.cfg.css = "/cgit.css"; ctx.cfg.logo = "/cgit.png"; ctx.cfg.favicon = "/favicon.ico"; ctx.cfg.local_time = 0; diff --git a/cgit.h b/cgit.h index 69b5c13..1d88396 100644 --- a/cgit.h +++ b/cgit.h @@ -195,7 +195,6 @@ struct cgit_config { char *cache_root; char *clone_prefix; char *clone_url; - char *css; char *favicon; char *footer; char *head_include; @@ -206,6 +205,7 @@ struct cgit_config { char *module_link; char *project_list; struct string_list readme; + struct string_list css; char *robots; char *root_title; char *root_desc; diff --git a/cgitrc.5.txt b/cgitrc.5.txt index 463d90c..45288bc 100644 --- a/cgitrc.5.txt +++ b/cgitrc.5.txt @@ -126,7 +126,8 @@ commit-sort:: css:: Url which specifies the css document to include in all cgit pages. - Default value: "/cgit.css". + Default value: "/cgit.css". May be given multiple times, each + css URL path is added in the head section of the document in turn. email-filter:: Specifies a command which will be invoked to format names and email diff --git a/ui-shared.c b/ui-shared.c index fbf5a2d..7c7a537 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -768,6 +768,18 @@ static void print_rel_vcs_link(const char *url) html(" Git repository'/>\n"); } +static int emit_css_link(struct string_list_item *s, void *arg) +{ + html("\n"); + + return 0; +} + void cgit_print_docstart(void) { char *host = cgit_hosturl(); @@ -787,9 +799,12 @@ void cgit_print_docstart(void) htmlf("\n", cgit_version); if (ctx.cfg.robots && *ctx.cfg.robots) htmlf("\n", ctx.cfg.robots); - html("\n"); + + if (ctx.cfg.css.items) + for_each_string_list(&ctx.cfg.css, emit_css_link, NULL); + else + emit_css_link(NULL, "/cgit.css"); + if (ctx.cfg.favicon) { html("