From: andy at warmcat.com (Andy Green)
Subject: [PATCH v5 1/6] config: add js
Date: Tue, 26 Jun 2018 19:25:19 +0800 [thread overview]
Message-ID: <153001231957.12484.9989994122833530304.stgit@mail.warmcat.com> (raw)
In-Reply-To: <153001215740.12484.13344875445662026876.stgit@mail.warmcat.com>
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 at warmcat.com>
Reviewed-by: John Keeping <john at keeping.me.uk>
---
Makefile | 1 +
cgit.c | 3 +++
cgit.h | 1 +
cgit.js | 0
cgitrc.5.txt | 5 +++++
ui-shared.c | 5 +++++
6 files changed, 15 insertions(+)
create mode 100644 cgit.js
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
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 0fe4cbf..ff2a3e1 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -792,6 +792,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);
next prev parent reply other threads:[~2018-06-26 11:25 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-20 9:39 Highlighting lines or line ranges in tree view andy
2018-06-21 5:42 ` [PATCH 1/3] ui-shared: introduce line range highlight javascript andy
2018-06-21 7:03 ` list
2018-06-21 7:30 ` andy
2018-06-21 5:42 ` [PATCH 2/3] ui-tree: use the line range highlight script andy
2018-06-21 5:43 ` [PATCH 3/3] ui-blame: " andy
2018-06-21 9:34 ` [PATCH v2 0/5] line range highlight andy
2018-06-21 9:34 ` [PATCH v2 1/5] config: add js andy
2018-06-23 10:20 ` john
2018-06-23 10:34 ` andy
2018-06-21 9:34 ` [PATCH v2 2/5] cgit.js: introduce andy
2018-06-23 10:18 ` john
2018-06-21 9:34 ` [PATCH v2 3/5] ui-shared: introduce line range highlight javascript andy
2018-06-23 10:17 ` john
2018-06-24 2:37 ` andy
2018-06-21 9:35 ` [PATCH v2 4/5] ui-tree: use the line range highlight script andy
2018-06-21 9:35 ` [PATCH v2 5/5] ui-blame: " andy
2018-06-22 23:01 ` [PATCH v2 1/2] cgit.js: make line range highlight responsive to url changes andy
2018-06-22 23:02 ` [PATCH v2 2/2] cgit.js: line range highlight: improve vertical scroll logic andy
2018-06-23 7:45 ` [PATCH v2] cgit.js: line range highlight: always hook hashchange in case hash added andy
2018-06-24 2:44 ` [PATCH v3 0/6] line range highlight andy
2018-06-24 2:44 ` [PATCH v3 1/6] config: add js andy
2018-06-24 11:01 ` john
2018-06-24 2:44 ` [PATCH v3 2/6] ui-shared: line range highlight: introduce javascript andy
2018-06-24 11:28 ` john
2018-06-25 2:04 ` andy
2018-06-24 2:44 ` [PATCH v3 3/6] cgit.js: line range highlight: make responsive to url changes andy
2018-06-24 2:44 ` [PATCH v3 4/6] cgit.js: line range highlight: improve vertical scroll logic andy
2018-06-24 2:44 ` [PATCH v3 5/6] line-range-highlight: onclick handler and range selection andy
2018-06-24 11:35 ` john
2018-06-25 2:07 ` andy
2018-06-24 2:44 ` [PATCH v3 6/6] line-range-highlight: copy URL to clipboard on click andy
2018-06-24 11:42 ` john
2018-06-24 12:00 ` andy
2018-06-24 13:39 ` john
2018-06-24 15:06 ` andy
2018-06-24 16:03 ` john
2018-06-25 0:46 ` andy
2018-06-25 5:49 ` [PATCH v4 0/6] line range highlight andy
2018-06-25 5:49 ` [PATCH v4 1/6] config: add js andy
2018-06-26 8:03 ` list
2018-06-25 5:49 ` [PATCH v4 2/6] cgit.js: line range highlight: introduce javascript andy
2018-06-25 5:49 ` [PATCH v4 3/6] cgit.js: line range highlight: make responsive to url changes andy
2018-06-25 5:50 ` [PATCH v4 4/6] cgit.js: line range highlight: improve vertical scroll logic andy
2018-06-25 5:50 ` [PATCH v4 5/6] line-range-highlight: onclick handler and range selection andy
2018-06-25 5:50 ` [PATCH v4 6/6] line-range-highlight: copy URL to clipboard UI andy
2018-06-26 11:25 ` [PATCH v5 0/6] line range highlight andy
2018-06-26 11:25 ` andy [this message]
2018-06-26 11:25 ` [PATCH v5 2/6] cgit.js: line range highlight: introduce javascript andy
2018-06-27 18:02 ` Jason
2018-06-27 21:45 ` andy
2018-06-28 23:58 ` [PATCH] cgit.css: add copyright lines andy
2018-06-26 11:25 ` [PATCH v5 3/6] cgit.js: line range highlight: make responsive to url changes andy
2018-06-26 11:25 ` [PATCH v5 4/6] cgit.js: line range highlight: improve vertical scroll logic andy
2018-06-26 11:25 ` [PATCH v5 5/6] line-range-highlight: onclick handler and range selection andy
2018-06-26 11:51 ` [PATCH v5-ninjaedit] " andy
2018-06-26 11:25 ` [PATCH v5 6/6] line-range-highlight: copy URL to clipboard UI andy
2018-06-27 18:07 ` Jason
2018-06-27 23:24 ` andy
2018-06-27 23:30 ` Jason
2018-06-27 23:38 ` andy
2018-06-29 1:39 ` [PATCH v6 0/7] line range highlight andy
2018-06-29 1:40 ` [PATCH v6 1/7] config: add js andy
2018-06-29 6:14 ` list
2018-06-29 6:16 ` [PATCH v6-ninjaedit] " andy
2018-06-29 6:31 ` [PATCH v6-ninjaedit2] " andy
2018-06-29 6:33 ` [PATCH v6-ninjaedit] " list
2018-06-29 1:40 ` [PATCH v6 2/7] cgit.js: line range highlight: introduce javascript andy
2018-06-29 1:40 ` [PATCH v6 3/7] cgit.js: line range highlight: make responsive to url changes andy
2018-06-29 1:40 ` [PATCH v6 4/7] cgit.js: line range highlight: improve vertical scroll logic andy
2018-06-29 1:40 ` [PATCH v6 5/7] line-range-highlight: onclick handler and range selection andy
2018-06-29 1:40 ` [PATCH v6 6/7] line-range-highlight: burger menu and popup menu andy
2018-06-29 1:40 ` [PATCH v6 7/7] line-range-highlight: copy text andy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=153001231957.12484.9989994122833530304.stgit@mail.warmcat.com \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).