diff options
author | Andy Green <andy@warmcat.com> | 2018-06-23 12:25:53 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2022-12-19 16:50:21 +0100 |
commit | aee39b4e9a45e1ba507c0017de50bb9dbbae7af8 (patch) | |
tree | 7c6328c363a06f12143e4d15b09c6d7158f8adfc /ui-shared.c | |
parent | 093ac9697068833a15cae2dbbd5ffbc0203741c0 (diff) | |
download | cgit-aee39b4e9a45e1ba507c0017de50bb9dbbae7af8.tar.gz cgit-aee39b4e9a45e1ba507c0017de50bb9dbbae7af8.tar.xz |
config: add js
Just like the config allows setting css URL path, add a config for
setting the js URL path
Signed-off-by: Andy Green <andy@warmcat.com>
Reviewed-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Christian Hesse <mail@eworm.de>
Diffstat (limited to 'ui-shared.c')
-rw-r--r-- | ui-shared.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ui-shared.c b/ui-shared.c index 7c7a537..c50b3e6 100644 --- a/ui-shared.c +++ b/ui-shared.c @@ -780,6 +780,18 @@ static int emit_css_link(struct string_list_item *s, void *arg) return 0; } +static int emit_js_link(struct string_list_item *s, void *arg) +{ + html("<script type='text/javascript' src='"); + if (s) + html_attr(s->string); + else + html_attr((const char *)arg); + html("'></script>\n"); + + return 0; +} + void cgit_print_docstart(void) { char *host = cgit_hosturl(); @@ -805,6 +817,11 @@ void cgit_print_docstart(void) else emit_css_link(NULL, "/cgit.css"); + if (ctx.cfg.js.items) + for_each_string_list(&ctx.cfg.js, emit_js_link, NULL); + else + emit_js_link(NULL, "/cgit.js"); + if (ctx.cfg.favicon) { html("<link rel='shortcut icon' href='"); html_attr(ctx.cfg.favicon); |