Allow customising path to themed.css

This commit is contained in:
RunasSudo 2025-05-16 16:19:42 +10:00
parent 615420c062
commit ebead97801
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
5 changed files with 14 additions and 1 deletions

2
cgit.c
View File

@ -145,6 +145,8 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.root_readme = xstrdup(value); ctx.cfg.root_readme = xstrdup(value);
else if (!strcmp(name, "css")) else if (!strcmp(name, "css"))
string_list_append(&ctx.cfg.css, xstrdup(value)); 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")) else if (!strcmp(name, "js"))
string_list_append(&ctx.cfg.js, xstrdup(value)); string_list_append(&ctx.cfg.js, xstrdup(value));
else if (!strcmp(name, "favicon")) else if (!strcmp(name, "favicon"))

1
cgit.h
View File

@ -211,6 +211,7 @@ struct cgit_config {
char *project_list; char *project_list;
struct string_list readme; struct string_list readme;
struct string_list css; struct string_list css;
struct string_list css_themed;
char *robots; char *robots;
char *root_title; char *root_title;
char *root_desc; char *root_desc;

View File

@ -7,7 +7,11 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>{{ ctx.page.title }}</title>{# ctx.page.title is usually set by prepare_repo_cmd #} <title>{{ ctx.page.title }}</title>{# ctx.page.title is usually set by prepare_repo_cmd #}
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap"> <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Noto+Sans:ital,wght@0,100..900;1,100..900&display=swap">
<link rel="stylesheet" href="/themed.css"> {% 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 %}
</head> </head>
<body class="text-gray-900"> <body class="text-gray-900">
{% endblock %} {% endblock %}

View File

@ -847,6 +847,11 @@ static int emit_css_link(struct string_list_item *s, void *arg)
return 0; 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) static int emit_js_link(struct string_list_item *s, void *arg)
{ {
/* Do not emit anything if js= is specified. */ /* Do not emit anything if js= is specified. */

View File

@ -1,6 +1,7 @@
#ifndef UI_SHARED_H #ifndef UI_SHARED_H
#define 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 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_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); extern void cgit_shared_reporevlink_url(const char *page, const char *head, const char *rev, const char *path);