فهرست منبع

Merge pull request 'Add short_description_raw option' (#266) from ltning/snac2:master into master

Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/266
grunfink 2 ماه پیش
والد
کامیت
43812a3721
3فایلهای تغییر یافته به همراه23 افزوده شده و 10 حذف شده
  1. 2 0
      doc/snac.8
  2. 20 10
      html.c
  3. 1 0
      utils.c

+ 2 - 0
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

+ 20 - 10
html.c

@@ -553,10 +553,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);
 
@@ -569,12 +570,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);

+ 1 - 0
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"
     "}";