commit 5c8992d

grunfink  ·  2024-01-28 10:10:07 +0000 UTC
parents d5c2c44, fe89262
Merge pull request 'feature(favicon): Add favicon support (#107)' (#109) from gyptazy/snac2:feature/107-add-favicon-support-1st-ite into master

Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/109
2 files changed,  +9, -1
M html.c
M html.c
+8, -1
 1@@ -427,7 +427,9 @@ static xs_html *html_base_head(void)
 2             xs_html_attr("name", "generator"),
 3             xs_html_attr("content", USER_AGENT)));
 4 
 5-    /* add server CSS */
 6+    /* add server CSS and favicon */
 7+    xs *f;
 8+    f = xs_fmt("%s/favicon.ico", srv_baseurl);
 9     xs_list *p = xs_dict_get(srv_config, "cssurls");
10     char *v;
11     while (xs_list_iter(&p, &v)) {
12@@ -436,6 +438,11 @@ static xs_html *html_base_head(void)
13                 xs_html_attr("rel",  "stylesheet"),
14                 xs_html_attr("type", "text/css"),
15                 xs_html_attr("href", v)));
16+        xs_html_add(head,
17+            xs_html_sctag("link",
18+                xs_html_attr("rel",  "icon"),
19+                xs_html_attr("type", "image/x-icon"),
20+                xs_html_attr("href", f)));
21     }
22 
23     return head;
+1, -0
1@@ -81,6 +81,7 @@ static const char *greeting_html =
2     "<!DOCTYPE html>\n"
3     "<html><head>\n"
4     "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n"
5+    "<link rel=\"icon\" type=\"image/x-icon\" href=\"https://%host%/favicon.ico\"/>\n"
6     "<title>Welcome to %host%</title>\n"
7     "<body style=\"margin: auto; max-width: 50em\">\n"
8     "%blurb%"