1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
diff --git a/Makefile b/Makefile
index cd7639ccf3fc79ea2faf75cc4acb040e0a05ad41..ad825beadbace8665f0c9bf7bbd259cbc26a720e 100644
--- a/Makefile
+++ b/Makefile
@@ -87,6 +87,7 @@ $(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_SCRIPT_PATH)
$(INSTALL) -m 0755 cgit $(DESTDIR)$(CGIT_SCRIPT_PATH)/$(CGIT_SCRIPT_NAME)
$(INSTALL) -m 0755 -d $(DESTDIR)$(CGIT_DATA_PATH)
$(INSTALL) -m 0644 cgit.css $(DESTDIR)$(CGIT_DATA_PATH)/cgit.css
+ $(INSTALL) -m 0644 cgit.js $(DESTDIR)$(CGIT_DATA_PATH)/cgit.js
$(INSTALL) -m 0644 cgit.png $(DESTDIR)$(CGIT_DATA_PATH)/cgit.png
$(INSTALL) -m 0644 favicon.ico $(DESTDIR)$(CGIT_DATA_PATH)/favicon.ico
$(INSTALL) -m 0644 robots.txt $(DESTDIR)$(CGIT_DATA_PATH)/robots.txt
diff --git a/cgit.c b/cgit.c
index 75d9926539fb78f0976a3ce7ea34e3b6176bd8fb..57d70974c50fbd0ade407d8fd46b0ee480d046b1 100644
--- a/cgit.c
+++ b/cgit.c
@@ -143,6 +143,8 @@ else if (!strcmp(name, "root-readme"))
ctx.cfg.root_readme = xstrdup(value);
else if (!strcmp(name, "css"))
string_list_append(&ctx.cfg.css, xstrdup(value));
+ else if (!strcmp(name, "js"))
+ string_list_append(&ctx.cfg.js, xstrdup(value));
else if (!strcmp(name, "favicon"))
ctx.cfg.favicon = xstrdup(value);
else if (!strcmp(name, "footer"))
diff --git a/cgit.h b/cgit.h
index 1d88396dc4aa5a720ebfc2d6e78ab713412aeea4..a0cf5e904b697c5168d28e846ba153a41973d873 100644
--- a/cgit.h
+++ b/cgit.h
@@ -264,6 +264,7 @@ diff_type difftype;
int branch_sort;
int commit_sort;
struct string_list mimetypes;
+ struct string_list js;
struct cgit_filter *about_filter;
struct cgit_filter *commit_filter;
struct cgit_filter *source_filter;
diff --git a/cgit.js b/cgit.js
new file mode 100644
index 0000000000000000000000000000000000000000..b35e0bca0fb76ed1f688e51191b0166a4df64947
--- /dev/null
+++ b/cgit.js
@@ -0,0 +1,7 @@
+/* cgit.js: javacript functions for cgit
+ *
+ * Copyright (C) 2006-2018 cgit Development Team <cgit@lists.zx2c4.com>
+ *
+ * Licensed under GNU General Public License v2
+ * (see COPYING for full license text)
+ */
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 45288bc427daca6a62553b721103e49c7a545b25..6f3e9520c76b490756fe4096122ca07bc5efdca1 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -239,6 +239,11 @@ include::
Name of a configfile to include before the rest of the current config-
file is parsed. Default value: none. See also: "MACRO EXPANSION".
+js::
+ Url which specifies the javascript script document to include in all cgit
+ pages. Default value: "/cgit.js". Setting this to an empty string will
+ disable generation of the link to this file in the head section.
+
local-time::
Flag which, if set to "1", makes cgit print commit and tag times in the
servers timezone. Default value: "0".
diff --git a/ui-shared.c b/ui-shared.c
index 7c7a5375cec594485290ee82b676f27c5c8d38e6..c50b3e68568087221bb75ef25268af4d203b9338 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -780,6 +780,18 @@
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();
@@ -804,6 +816,11 @@ if (ctx.cfg.css.items)
for_each_string_list(&ctx.cfg.css, emit_css_link, NULL);
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='");
|