summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2018-06-23 18:25:53 +0800
committerAndy Green <andy@warmcat.com>2018-06-29 07:53:21 +0800
commit7d3b96e760a73a584df393ce1e5324ed21046100 (patch)
tree1cbcaad5a2a599b9732ccc75605703ae24264174
parente633a42223fc4ab7d74df90e47d7c2a7e5c79377 (diff)
downloadcgit-7d3b96e760a73a584df393ce1e5324ed21046100.tar.gz
config: add js
Just like the config allows setting css URL path, add a config for setting the js URL path Setting the js path to an empty string disables emitting the reference to it in the head section. Signed-off-by: Andy Green <andy@warmcat.com> Reviewed-by: John Keeping <john@keeping.me.uk>
-rw-r--r--Makefile1
-rw-r--r--cgit.c3
-rw-r--r--cgit.h1
-rw-r--r--cgit.js0
-rw-r--r--cgitrc.5.txt5
-rw-r--r--ui-shared.c5
6 files changed, 15 insertions, 0 deletions
diff --git a/Makefile b/Makefile
index 137150c..de7e13e 100644
--- a/Makefile
+++ b/Makefile
@@ -87,6 +87,7 @@ install: all
$(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 bdb2fad..8b23c8f 100644
--- a/cgit.c
+++ b/cgit.c
@@ -146,6 +146,8 @@ static void config_cb(const char *name, const char *value)
ctx.cfg.root_readme = xstrdup(value);
else if (!strcmp(name, "css"))
ctx.cfg.css = xstrdup(value);
+ else if (!strcmp(name, "js"))
+ ctx.cfg.js = xstrdup(value);
else if (!strcmp(name, "favicon"))
ctx.cfg.favicon = xstrdup(value);
else if (!strcmp(name, "footer"))
@@ -384,6 +386,7 @@ static void prepare_context(void)
ctx.cfg.branch_sort = 0;
ctx.cfg.commit_sort = 0;
ctx.cfg.css = "/cgit.css";
+ ctx.cfg.js = "/cgit.js";
ctx.cfg.logo = "/cgit.png";
ctx.cfg.favicon = "/favicon.ico";
ctx.cfg.local_time = 0;
diff --git a/cgit.h b/cgit.h
index 999db9e..582416e 100644
--- a/cgit.h
+++ b/cgit.h
@@ -194,6 +194,7 @@ struct cgit_config {
char *clone_prefix;
char *clone_url;
char *css;
+ char *js;
char *favicon;
char *footer;
char *head_include;
diff --git a/cgit.js b/cgit.js
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/cgit.js
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 99fc799..2737008 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -248,6 +248,11 @@ inline-readme::
individually also choose to ignore this global list, and create a
repo-specific list by using 'repo.inline-readme'.
+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 74ace10..e1ff349 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -798,6 +798,11 @@ void cgit_print_docstart(void)
html("<link rel='stylesheet' type='text/css' href='");
html_attr(ctx.cfg.css);
html("'/>\n");
+ if (*ctx.cfg.js) {
+ html("<script type='text/javascript' src='");
+ html_attr(ctx.cfg.js);
+ html("'></script>\n");
+ }
if (ctx.cfg.favicon) {
html("<link rel='shortcut icon' href='");
html_attr(ctx.cfg.favicon);