]> granicus.if.org Git - cgit/commitdiff
css: change to be a list ch/css-list
authorAndy Green <andy@warmcat.com>
Tue, 3 Jul 2018 03:33:59 +0000 (11:33 +0800)
committerChristian Hesse <mail@eworm.de>
Fri, 25 Oct 2019 15:03:28 +0000 (17:03 +0200)
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>
cgit.c
cgit.h
cgitrc.5.txt
ui-shared.c

diff --git a/cgit.c b/cgit.c
index ac8c6418ba46061da375fe26c82b39d1be6e51fc..c6111dd9f58156e73c6b1b39e4166a2065f4d27d 100644 (file)
--- a/cgit.c
+++ b/cgit.c
@@ -142,7 +142,7 @@ static void config_cb(const char *name, const char *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"))
@@ -376,7 +376,6 @@ static void prepare_context(void)
        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 7ec46b48464039a8b94393df5d6ce3fabca3e6ab..9a5ca57bcb06962301d8e60881c048f8c2d389cb 100644 (file)
--- a/cgit.h
+++ b/cgit.h
@@ -195,7 +195,6 @@ struct cgit_config {
        char *cache_root;
        char *clone_prefix;
        char *clone_url;
-       char *css;
        char *favicon;
        char *footer;
        char *head_include;
@@ -206,6 +205,7 @@ struct cgit_config {
        char *module_link;
        char *project_list;
        struct string_list readme;
+       struct string_list css;
        char *robots;
        char *root_title;
        char *root_desc;
index ba77826fd0c23d54bbf990f9251e0b7f27c3a602..7a3a81c08bbedbbda118157bb36c717b87da8524 100644 (file)
@@ -126,7 +126,8 @@ commit-sort::
 
 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
index d2358f292823ce11bfe91523ed833cdf4cdca235..8b378c9528d3eba60475da3a9ca3347167ef699a 100644 (file)
@@ -767,6 +767,18 @@ static void print_rel_vcs_link(const char *url)
        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();
@@ -786,9 +798,12 @@ void cgit_print_docstart(void)
        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);