diff options
author | Andy Green | 2018-06-23 18:25:53 +0800 |
---|---|---|
committer | Yigit Sever | 2023-07-21 03:04:16 +0300 |
commit | f762d291b01eeda27fa9239c99efd607d5bf7a14 (patch) | |
tree | 2f76e1c7a5bdeac71eaef42f76cb3918a913a09d | |
parent | f466091a0d5717d61853965aa3eb1441efdff007 (diff) | |
download | cgit-f762d291b01eeda27fa9239c99efd607d5bf7a14.tar.gz cgit-f762d291b01eeda27fa9239c99efd607d5bf7a14.tar.bz2 cgit-f762d291b01eeda27fa9239c99efd607d5bf7a14.zip |
config: add js
Just like the config allows setting css URL path, add a config for
setting the js URL path
Signed-off-by: Andy Green <andy@warmcat.com>
Reviewed-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Christian Hesse <mail@eworm.de>
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | cgit.c | 2 | ||||
-rw-r--r-- | cgit.h | 1 | ||||
-rw-r--r-- | cgit.js | 7 | ||||
-rw-r--r-- | cgitrc.5.txt | 5 | ||||
-rw-r--r-- | ui-shared.c | 17 |
6 files changed, 33 insertions, 0 deletions
@@ -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 |
@@ -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")) |
@@ -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; |
@@ -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 | ||
242 | js:: | ||
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 | |||
242 | local-time:: | 247 | local-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 | ||
783 | static 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 | |||
783 | void cgit_print_docstart(void) | 795 | void 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); |