aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Green2018-07-03 11:33:59 +0800
committerYigit Sever2023-07-21 03:03:51 +0300
commitf466091a0d5717d61853965aa3eb1441efdff007 (patch)
tree1b906a5012e27d580e1f82e39c3199398011515d
parent319e4e08ecfdabecce1304b2c60acb09d9d2a736 (diff)
downloadcgit-f466091a0d5717d61853965aa3eb1441efdff007.tar.gz
cgit-f466091a0d5717d61853965aa3eb1441efdff007.tar.bz2
cgit-f466091a0d5717d61853965aa3eb1441efdff007.zip
css: change to be a list
Without changing the default behaviour of including /cgit.css if nothing declared, allow the "css" config to be given multiple times listing one or more alternative URL paths to be included in the document head area. Signed-off-by: Andy Green <andy@warmcat.com> Signed-off-by: Christian Hesse <mail@eworm.de>
-rw-r--r--cgit.c3
-rw-r--r--cgit.h2
-rw-r--r--cgitrc.5.txt3
-rw-r--r--ui-shared.c21
4 files changed, 22 insertions, 7 deletions
diff --git a/cgit.c b/cgit.c
index 133f454..75d9926 100644
--- a/cgit.c
+++ b/cgit.c
@@ -142,7 +142,7 @@ static void config_cb(const char *name, const char *value)
142 else if (!strcmp(name, "root-readme")) 142 else if (!strcmp(name, "root-readme"))
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 ctx.cfg.css = xstrdup(value); 145 string_list_append(&ctx.cfg.css, xstrdup(value));
146 else if (!strcmp(name, "favicon")) 146 else if (!strcmp(name, "favicon"))
147 ctx.cfg.favicon = xstrdup(value); 147 ctx.cfg.favicon = xstrdup(value);
148 else if (!strcmp(name, "footer")) 148 else if (!strcmp(name, "footer"))
@@ -378,7 +378,6 @@ static void prepare_context(void)
378 ctx.cfg.case_sensitive_sort = 1; 378 ctx.cfg.case_sensitive_sort = 1;
379 ctx.cfg.branch_sort = 0; 379 ctx.cfg.branch_sort = 0;
380 ctx.cfg.commit_sort = 0; 380 ctx.cfg.commit_sort = 0;
381 ctx.cfg.css = "/cgit.css";
382 ctx.cfg.logo = "/cgit.png"; 381 ctx.cfg.logo = "/cgit.png";
383 ctx.cfg.favicon = "/favicon.ico"; 382 ctx.cfg.favicon = "/favicon.ico";
384 ctx.cfg.local_time = 0; 383 ctx.cfg.local_time = 0;
diff --git a/cgit.h b/cgit.h
index 69b5c13..1d88396 100644
--- a/cgit.h
+++ b/cgit.h
@@ -195,7 +195,6 @@ struct cgit_config {
195 char *cache_root; 195 char *cache_root;
196 char *clone_prefix; 196 char *clone_prefix;
197 char *clone_url; 197 char *clone_url;
198 char *css;
199 char *favicon; 198 char *favicon;
200 char *footer; 199 char *footer;
201 char *head_include; 200 char *head_include;
@@ -206,6 +205,7 @@ struct cgit_config {
206 char *module_link; 205 char *module_link;
207 char *project_list; 206 char *project_list;
208 struct string_list readme; 207 struct string_list readme;
208 struct string_list css;
209 char *robots; 209 char *robots;
210 char *root_title; 210 char *root_title;
211 char *root_desc; 211 char *root_desc;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 463d90c..45288bc 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -126,7 +126,8 @@ commit-sort::
126 126
127css:: 127css::
128 Url which specifies the css document to include in all cgit pages. 128 Url which specifies the css document to include in all cgit pages.
129 Default value: "/cgit.css". 129 Default value: "/cgit.css". May be given multiple times, each
130 css URL path is added in the head section of the document in turn.
130 131
131email-filter:: 132email-filter::
132 Specifies a command which will be invoked to format names and email 133 Specifies a command which will be invoked to format names and email
diff --git a/ui-shared.c b/ui-shared.c
index 3afa15e..1251c9a 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -768,6 +768,18 @@ static void print_rel_vcs_link(const char *url)
768 html(" Git repository'/>\n"); 768 html(" Git repository'/>\n");
769} 769}
770 770
771static int emit_css_link(struct string_list_item *s, void *arg)
772{
773 html("<link rel='stylesheet' type='text/css' href='");
774 if (s)
775 html_attr(s->string);
776 else
777 html_attr((const char *)arg);
778 html("'/>\n");
779
780 return 0;
781}
782
771void cgit_print_docstart(void) 783void cgit_print_docstart(void)
772{ 784{
773 char *host = cgit_hosturl(); 785 char *host = cgit_hosturl();
@@ -787,9 +799,12 @@ void cgit_print_docstart(void)
787 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version); 799 htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
788 if (ctx.cfg.robots && *ctx.cfg.robots) 800 if (ctx.cfg.robots && *ctx.cfg.robots)
789 htmlf("<meta name='robots' content='%s'/>\n", ctx.cfg.robots); 801 htmlf("<meta name='robots' content='%s'/>\n", ctx.cfg.robots);
790 html("<link rel='stylesheet' type='text/css' href='"); 802
791 html_attr(ctx.cfg.css); 803 if (ctx.cfg.css.items)
792 html("'/>\n"); 804 for_each_string_list(&ctx.cfg.css, emit_css_link, NULL);
805 else
806 emit_css_link(NULL, "/cgit.css");
807
793 if (ctx.cfg.favicon) { 808 if (ctx.cfg.favicon) {
794 html("<link rel='shortcut icon' href='"); 809 html("<link rel='shortcut icon' href='");
795 html_attr(ctx.cfg.favicon); 810 html_attr(ctx.cfg.favicon);