Commit 093ac9697068833a15cae2dbbd5ffbc0203741c0

Parents: 91f25909b9572ebdf3a0fed8224bf03d0d9bf3db

From: Andy Green <andy@warmcat.com>
Date: Tue Jul 3 11:33:59 2018 +0700

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>

Stats

cgit.c +1/-2
cgit.h +1/-1
cgitrc.5.txt +2/-1
ui-shared.c +18/-3

Changeset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
diff --git a/cgit.c b/cgit.c
index 133f454b6dc0b46e74d3d753a4c910a07109e24e..75d9926539fb78f0976a3ce7ea34e3b6176bd8fb 100644
--- a/cgit.c
+++ b/cgit.c
@@ -142,7 +142,7 @@ 		ctx.cfg.root_desc = xstrdup(value);
 	else if (!strcmp(name, "root-readme"))
 		ctx.cfg.root_readme = xstrdup(value);
 	else if (!strcmp(name, "css"))
-		ctx.cfg.css = xstrdup(value);
+		string_list_append(&ctx.cfg.css, xstrdup(value));
 	else if (!strcmp(name, "favicon"))
 		ctx.cfg.favicon = xstrdup(value);
 	else if (!strcmp(name, "footer"))
@@ -378,7 +378,6 @@ 	ctx.cfg.cache_static_ttl = -1;
 	ctx.cfg.case_sensitive_sort = 1;
 	ctx.cfg.branch_sort = 0;
 	ctx.cfg.commit_sort = 0;
-	ctx.cfg.css = "/cgit.css";
 	ctx.cfg.logo = "/cgit.png";
 	ctx.cfg.favicon = "/favicon.ico";
 	ctx.cfg.local_time = 0;
diff --git a/cgit.h b/cgit.h
index 69b5c13232e74845907a2212ade32f36f861bba8..1d88396dc4aa5a720ebfc2d6e78ab713412aeea4 100644
--- a/cgit.h
+++ b/cgit.h
@@ -195,7 +195,6 @@ 	char *agefile;
 	char *cache_root;
 	char *clone_prefix;
 	char *clone_url;
-	char *css;
 	char *favicon;
 	char *footer;
 	char *head_include;
@@ -206,6 +205,7 @@ 	char *mimetype_file;
 	char *module_link;
 	char *project_list;
 	struct string_list readme;
+	struct string_list css;
 	char *robots;
 	char *root_title;
 	char *root_desc;
diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 463d90ced9fe9c12fd477c936ed126a7e9f90eb0..45288bc427daca6a62553b721103e49c7a545b25 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -126,7 +126,8 @@ 	value: unset.
 
 css::
 	Url which specifies the css document to include in all cgit pages.
-	Default value: "/cgit.css".
+	Default value: "/cgit.css".  May be given multiple times, each
+	css URL path is added in the head section of the document in turn.
 
 email-filter::
 	Specifies a command which will be invoked to format names and email
diff --git a/ui-shared.c b/ui-shared.c
index fbf5a2d9dbe0bca892bd8f65071eac809c2667d2..7c7a5375cec594485290ee82b676f27c5c8d38e6 100644
--- a/ui-shared.c
+++ b/ui-shared.c
@@ -768,6 +768,18 @@ 	html_attr(ctx.repo->name);
 	html(" Git repository'/>\n");
 }
 
+static int emit_css_link(struct string_list_item *s, void *arg)
+{
+	html("<link rel='stylesheet' type='text/css' href='");
+	if (s)
+		html_attr(s->string);
+	else
+		html_attr((const char *)arg);
+	html("'/>\n");
+
+	return 0;
+}
+
 void cgit_print_docstart(void)
 {
 	char *host = cgit_hosturl();
@@ -787,9 +799,12 @@ 	html("</title>\n");
 	htmlf("<meta name='generator' content='cgit %s'/>\n", cgit_version);
 	if (ctx.cfg.robots && *ctx.cfg.robots)
 		htmlf("<meta name='robots' content='%s'/>\n", ctx.cfg.robots);
-	html("<link rel='stylesheet' type='text/css' href='");
-	html_attr(ctx.cfg.css);
-	html("'/>\n");
+
+	if (ctx.cfg.css.items)
+		for_each_string_list(&ctx.cfg.css, emit_css_link, NULL);
+	else
+		emit_css_link(NULL, "/cgit.css");
+
 	if (ctx.cfg.favicon) {
 		html("<link rel='shortcut icon' href='");
 		html_attr(ctx.cfg.favicon);