From ebead97801cef89b9f1118556185f0cd0cad128a Mon Sep 17 00:00:00 2001 From: RunasSudo Date: Fri, 16 May 2025 16:19:42 +1000 Subject: [PATCH] Allow customising path to themed.css --- cgit.c | 2 ++ cgit.h | 1 + themed/base.html | 6 +++++- ui-shared.c | 5 +++++ ui-shared.h | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cgit.c b/cgit.c index 65c38c0..f631f89 100644 --- a/cgit.c +++ b/cgit.c @@ -145,6 +145,8 @@ static void config_cb(const char *name, const char *value) ctx.cfg.root_readme = xstrdup(value); else if (!strcmp(name, "css")) string_list_append(&ctx.cfg.css, xstrdup(value)); + else if (!strcmp(name, "css-themed")) + string_list_append(&ctx.cfg.css_themed, xstrdup(value)); else if (!strcmp(name, "js")) string_list_append(&ctx.cfg.js, xstrdup(value)); else if (!strcmp(name, "favicon")) diff --git a/cgit.h b/cgit.h index 9146d9a..56d28c6 100644 --- a/cgit.h +++ b/cgit.h @@ -211,6 +211,7 @@ struct cgit_config { char *project_list; struct string_list readme; struct string_list css; + struct string_list css_themed; char *robots; char *root_title; char *root_desc; diff --git a/themed/base.html b/themed/base.html index 1f52b12..f7b9143 100644 --- a/themed/base.html +++ b/themed/base.html @@ -7,7 +7,11 @@ {{ ctx.page.title }}{# ctx.page.title is usually set by prepare_repo_cmd #} - + {% if ctx.cfg.css_themed.items %} + {! for_each_string_list(&ctx.cfg.css_themed, cgit_shared_emit_css_link, NULL); !} + {% else %} + {! cgit_shared_emit_css_link(NULL, "/themed.css"); !} + {% endif %} {% endblock %} diff --git a/ui-shared.c b/ui-shared.c index 5e4d83e..9c846b6 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -847,6 +847,11 @@ static int emit_css_link(struct string_list_item *s, void *arg) return 0; } +int cgit_shared_emit_css_link(struct string_list_item *s, void *arg) +{ + return emit_css_link(s, arg); +} + static int emit_js_link(struct string_list_item *s, void *arg) { /* Do not emit anything if js= is specified. */ diff --git a/ui-shared.h b/ui-shared.h index 47fcced..62db46a 100644 --- a/ui-shared.h +++ b/ui-shared.h @@ -1,6 +1,7 @@ #ifndef UI_SHARED_H #define UI_SHARED_H +extern int cgit_shared_emit_css_link(struct string_list_item *s, void *arg); extern const char *cgit_shared_repolink_url(const char *page, const char *head, const char *path); extern void cgit_shared_repolink_url_with_delimiter(const char *page, const char *head, const char *path); extern void cgit_shared_reporevlink_url(const char *page, const char *head, const char *rev, const char *path);