From 3b818f557ae3c1073f1464fe0a7319a0e025ba86 Mon Sep 17 00:00:00 2001 From: Eirik Oeverby Date: Mon, 6 Jan 2025 20:03:00 +0100 Subject: Add short_description_raw option --- doc/snac.8 | 2 ++ html.c | 30 ++++++++++++++++++++---------- utils.c | 1 + 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/doc/snac.8 b/doc/snac.8 index 3a4bfcf..db47ae5 100644 --- a/doc/snac.8 +++ b/doc/snac.8 @@ -205,6 +205,8 @@ The email address of the instance administrator (optional). The user name of the instance administrator (optional). .It Ic short_description A textual short description about the instance (optional). +.It Ic short_description_raw +Whether to interpret short_descript as raw string or convert to HTML (optional) .It Ic fastcgi If set to true, .Nm diff --git a/html.c b/html.c index e8803ab..b54556d 100644 --- a/html.c +++ b/html.c @@ -537,10 +537,11 @@ xs_html *html_instance_head(void) static xs_html *html_instance_body(void) { - const char *host = xs_dict_get(srv_config, "host"); - const char *sdesc = xs_dict_get(srv_config, "short_description"); - const char *email = xs_dict_get(srv_config, "admin_email"); - const char *acct = xs_dict_get(srv_config, "admin_account"); + const char *host = xs_dict_get(srv_config, "host"); + const char *sdesc = xs_dict_get(srv_config, "short_description"); + const char *sdescraw = xs_dict_get(srv_config, "short_description_raw"); + const char *email = xs_dict_get(srv_config, "admin_email"); + const char *acct = xs_dict_get(srv_config, "admin_account"); xs *blurb = xs_replace(snac_blurb, "%host%", host); @@ -553,12 +554,21 @@ static xs_html *html_instance_body(void) dl = xs_html_tag("dl", NULL))); if (sdesc && *sdesc) { - xs_html_add(dl, - xs_html_tag("di", - xs_html_tag("dt", - xs_html_text(L("Site description"))), - xs_html_tag("dd", - xs_html_text(sdesc)))); + if (!xs_is_null(sdescraw) && xs_type(sdescraw) == XSTYPE_TRUE) { + xs_html_add(dl, + xs_html_tag("di", + xs_html_tag("dt", + xs_html_text(L("Site description"))), + xs_html_tag("dd", + xs_html_raw(sdesc)))); + } else { + xs_html_add(dl, + xs_html_tag("di", + xs_html_tag("dt", + xs_html_text(L("Site description"))), + xs_html_tag("dd", + xs_html_text(sdesc)))); + } } if (email && *email) { xs *mailto = xs_fmt("mailto:%s", email); diff --git a/utils.c b/utils.c index 0740d4d..0f97a2f 100644 --- a/utils.c +++ b/utils.c @@ -36,6 +36,7 @@ static const char *default_srv_config = "{" "\"admin_account\": \"\"," "\"title\": \"\"," "\"short_description\": \"\"," + "\"short_description_raw\": false," "\"protocol\": \"https\"," "\"fastcgi\": false" "}"; -- cgit v1.2.3 From 4528029dabb7d79cddefaa5677ae314e16ab51f4 Mon Sep 17 00:00:00 2001 From: Eirik Oeverby Date: Mon, 6 Jan 2025 20:03:28 +0100 Subject: Add short_description_raw option --- doc/snac.8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/snac.8 b/doc/snac.8 index db47ae5..c44a891 100644 --- a/doc/snac.8 +++ b/doc/snac.8 @@ -206,7 +206,7 @@ The user name of the instance administrator (optional). .It Ic short_description A textual short description about the instance (optional). .It Ic short_description_raw -Whether to interpret short_descript as raw string or convert to HTML (optional) +Whether to interpret short_descript as raw string or convert to HTML (optional). .It Ic fastcgi If set to true, .Nm -- cgit v1.2.3