aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--cgit.c2
-rw-r--r--cgit.h1
-rw-r--r--cgit.js7
-rw-r--r--cgitrc.5.txt5
-rw-r--r--ui-shared.c17
6 files changed, 33 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 598e464..210118e 100644
--- a/Makefile
+++ b/Makefile
@@ -88,6 +88,7 @@ install: all
88 $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH) 88 $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH)
89 $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css 89 $(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
90 $(INSTALL) -m 0644 site.js $(DESTDIR)$(CGIT_DATA_PATH)/site.js 90 $(INSTALL) -m 0644 site.js $(DESTDIR)$(CGIT_DATA_PATH)/site.js
91 $(INSTALL) -m 0644 cgit.js $(DESTDIR)$(CGIT_DATA_PATH)/cgit.js
91 $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png 92 $(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
92 $(INSTALL) -m 0644 favicon.ico $(DESTDIR)$(CGIT_DATA_PATH)/favicon.ico 93 $(INSTALL) -m 0644 favicon.ico $(DESTDIR)$(CGIT_DATA_PATH)/favicon.ico
93 $(INSTALL) -m 0644 robots.txt $(DESTDIR)$(CGIT_DATA_PATH)/robots.txt 94 $(INSTALL) -m 0644 robots.txt $(DESTDIR)$(CGIT_DATA_PATH)/robots.txt
diff --git a/cgit.c b/cgit.c
index 75d9926..57d7097 100644
--- a/cgit.c
+++ b/cgit.c
@@ -143,6 +143,8 @@ static void config_cb(const char *name, const char *value)
143 ctx.cfg.root_readme = xstrdup(value); 143 ctx.cfg.root_readme = xstrdup(value);
144 else if (!strcmp(name, "css")) 144 else if (!strcmp(name, "css"))
145 string_list_append(&ctx.cfg.css, xstrdup(value)); 145 string_list_append(&ctx.cfg.css, xstrdup(value));
146 else if (!strcmp(name, "js"))
147 string_list_append(&ctx.cfg.js, xstrdup(value));
146 else if (!strcmp(name, "favicon")) 148 else if (!strcmp(name, "favicon"))
147 ctx.cfg.favicon = xstrdup(value); 149 ctx.cfg.favicon = xstrdup(value);
148 else if (!strcmp(name, "footer")) 150 else if (!strcmp(name, "footer"))
diff --git a/cgit.h b/cgit.h
index 1d88396..a0cf5e9 100644
--- a/cgit.h
+++ b/cgit.h
@@ -264,6 +264,7 @@ struct cgit_config {
264 int branch_sort; 264 int branch_sort;
265 int commit_sort; 265 int commit_sort;
266 struct string_list mimetypes; 266 struct string_list mimetypes;
267 struct string_list js;
267 struct cgit_filter *about_filter; 268 struct cgit_filter *about_filter;
268 struct cgit_filter *commit_filter; 269 struct cgit_filter *commit_filter;
269 struct cgit_filter *source_filter; 270 struct cgit_filter *source_filter;
diff --git a/cgit.js b/cgit.js
new file mode 100644
index 0000000..b35e0bc
--- /dev/null
+++ b/cgit.js
@@ -0,0 +1,7 @@
1/* cgit.js: javacript functions for cgit
2 *
3 * Copyright (C) 2006-2018 cgit Development Team <cgit@lists.zx2c4.com>
4 *
5 * Licensed under GNU General Public License v2
6 * (see COPYING for full license text)
7 */
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 45288bc..6f3e952 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -239,6 +239,11 @@ include::
239 Name of a configfile to include before the rest of the current config- 239 Name of a configfile to include before the rest of the current config-
240 file is parsed. Default value: none. See also: "MACRO EXPANSION". 240 file is parsed. Default value: none. See also: "MACRO EXPANSION".
241 241
242js::
243 Url which specifies the javascript script document to include in all cgit
244 pages. Default value: "/cgit.js". Setting this to an empty string will
245 disable generation of the link to this file in the head section.
246
242local-time:: 247local-time::
243 Flag which, if set to "1", makes cgit print commit and tag times in the 248 Flag which, if set to "1", makes cgit print commit and tag times in the
244 servers timezone. Default value: "0". 249 servers timezone. Default value: "0".
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);