diff options
Diffstat (limited to '')
-rw-r--r--source/ui-shared.c41
1 file changed, 17 insertions, 24 deletions
diff --git a/source/ui-shared.c b/source/ui-shared.c
index e5afb2e..b88edec 100644
--- a/source/ui-shared.c
+++ b/source/ui-shared.c
@@ -343,36 +343,26 @@ static void print_rel_vcs_link(const char *url)
html(" Git repository'>\n");
}
-static int emit_css_link(struct string_list_item *item, void *fallback)
+static void emit_css_link(const char *href)
{
// An empty css entry is how a site turns the stylesheet off.
- if (item && *item->string == '\0')
- return 0;
+ if (!*href)
+ return;
html("<link rel='stylesheet' href='");
- if (item)
- html_attr(item->string);
- else
- html_attr((const char *)fallback);
+ html_attr(href);
html("'>\n");
-
- return 0;
}
-static int emit_js_link(struct string_list_item *item, void *fallback)
+static void emit_js_link(const char *src)
{
// An empty js entry is how a site turns the script off.
- if (item && *item->string == '\0')
- return 0;
+ if (!*src)
+ return;
html("<script src='");
- if (item)
- html_attr(item->string);
- else
- html_attr((const char *)fallback);
+ html_attr(src);
html("'></script>\n");
-
- return 0;
}
static void add_clone_urls(void (*fn)(const char *), char *urls, char *suffix)
@@ -1495,6 +1485,7 @@ void cgit_redirect(const char *url, const char *query, bool permanent)
void cgit_print_docstart(void)
{
const struct object_id *pinned;
+ struct string_list_item *item;
char *host = cgit_hosturl();
if (ctx.cfg.embedded) {
@@ -1538,15 +1529,17 @@ void cgit_print_docstart(void)
html("'>\n");
}
- if (ctx.cfg.css.items)
- for_each_string_list(&ctx.cfg.css, emit_css_link, NULL);
+ if (ctx.cfg.css.nr)
+ for_each_string_list_item(item, &ctx.cfg.css)
+ emit_css_link(item->string);
else
- emit_css_link(NULL, "/cgit.css");
+ emit_css_link("/cgit.css");
- if (ctx.cfg.js.items)
- for_each_string_list(&ctx.cfg.js, emit_js_link, NULL);
+ if (ctx.cfg.js.nr)
+ for_each_string_list_item(item, &ctx.cfg.js)
+ emit_js_link(item->string);
else
- emit_js_link(NULL, "/cgit.js");
+ emit_js_link("/cgit.js");
if (ctx.cfg.favicon && *ctx.cfg.favicon) {
html("<link rel='icon' href='");