aboutsummaryrefslogtreecommitdiffstats
path: root/ui-shared.c
diff options
context:
space:
mode:
authorAndy Green2018-06-23 18:25:53 +0800
committerYigit Sever2023-07-21 03:04:16 +0300
commitf762d291b01eeda27fa9239c99efd607d5bf7a14 (patch)
tree2f76e1c7a5bdeac71eaef42f76cb3918a913a09d /ui-shared.c
parentf466091a0d5717d61853965aa3eb1441efdff007 (diff)
downloadcgit-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.c17
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
783static 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
783void cgit_print_docstart(void) 795void 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);