[PATCH v2 1/5] config: add js

Andy Green andy at warmcat.com
Thu Jun 21 11:34:49 CEST 2018


Just like the config allows setting css URL path,
add a config for setting the js URL path

Signed-off-by: Andy Green <andy at warmcat.com>
---
 cgit.c       |    3 +++
 cgit.h       |    1 +
 cgitrc.5.txt |    4 ++++
 3 files changed, 8 insertions(+)

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 99ea7a2..e5a703e 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/cgitrc.5.txt b/cgitrc.5.txt
index 99fc799..a692aa5 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -248,6 +248,10 @@ 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".
+
 local-time::
 	Flag which, if set to "1", makes cgit print commit and tag times in the
 	servers timezone. Default value: "0".



More information about the CGit mailing list