diff options
author | Andy Green | 2018-06-23 18:25:53 +0800 |
---|---|---|
committer | Yigit Sever | 2023-07-21 03:04:16 +0300 |
commit | f762d291b01eeda27fa9239c99efd607d5bf7a14 (patch) | |
tree | 2f76e1c7a5bdeac71eaef42f76cb3918a913a09d /ui-shared.c | |
parent | f466091a0d5717d61853965aa3eb1441efdff007 (diff) | |
download | cgit-f762d291b01eeda27fa9239c99efd607d5bf7a14.tar.gz cgit-f762d291b01eeda27fa9239c99efd607d5bf7a14.tar.bz2 cgit-f762d291b01eeda27fa9239c99efd607d5bf7a14.zip |
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 1251c9a..bc76a6e 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) | |||
780 | return 0; | 780 | return 0; |
781 | } | 781 | } |
782 | 782 | ||
783 | static int emit_js_link(struct string_list_item *s, void *arg) | ||
784 | { | ||
785 | html("<script type='text/javascript' src='"); | ||
786 | if (s) | ||
787 | html_attr(s->string); | ||
788 | else | ||
789 | html_attr((const char *)arg); | ||
790 | html("'></script>\n"); | ||
791 | |||
792 | return 0; | ||
793 | } | ||
794 | |||
783 | void cgit_print_docstart(void) | 795 | void cgit_print_docstart(void) |
784 | { | 796 | { |
785 | char *host = cgit_hosturl(); | 797 | char *host = cgit_hosturl(); |
@@ -805,6 +817,11 @@ void cgit_print_docstart(void) | |||
805 | else | 817 | else |
806 | emit_css_link(NULL, "/cgit.css"); | 818 | emit_css_link(NULL, "/cgit.css"); |
807 | 819 | ||
820 | if (ctx.cfg.js.items) | ||
821 | for_each_string_list(&ctx.cfg.js, emit_js_link, NULL); | ||
822 | else | ||
823 | emit_js_link(NULL, "/cgit.js"); | ||
824 | |||
808 | if (ctx.cfg.favicon) { | 825 | if (ctx.cfg.favicon) { |
809 | html("<link rel='shortcut icon' href='"); | 826 | html("<link rel='shortcut icon' href='"); |
810 | html_attr(ctx.cfg.favicon); | 827 | html_attr(ctx.cfg.favicon); |