commit 6af6194

default  ·  2025-01-08 15:51:30 +0000 UTC
parent fc9140b
Show hashtags that are not already linked from the post content.
1 files changed,  +33, -0
M html.c
M html.c
+33, -0
 1@@ -2189,6 +2189,39 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
 2             au_tag);
 3     }
 4 
 5+    /* show all hashtags that has not been shown previously in the content */
 6+    const xs_list *tags = xs_dict_get(msg, "tag");
 7+    if (xs_type(tags) == XSTYPE_LIST && xs_list_len(tags)) {
 8+        const char *content = xs_dict_get(msg, "content");
 9+        const xs_dict *tag;
10+
11+        xs_html *add_hashtags = xs_html_tag("ul",
12+            xs_html_attr("class", "snac-more-hashtags"));
13+
14+        xs_list_foreach(tags, tag) {
15+            const char *type = xs_dict_get(tag, "type");
16+
17+            if (xs_type(type) == XSTYPE_STRING && strcmp(type, "Hashtag") == 0) {
18+                const char *href = xs_dict_get(tag, "href");
19+
20+                if (xs_type(href) == XSTYPE_STRING && xs_str_in(content, href) == -1) {
21+                    /* not in the content: add here */
22+                    const char *name = xs_dict_get(tag, "name");
23+
24+                    xs_html_add(add_hashtags,
25+                        xs_html_tag("li",
26+                            xs_html_tag("a",
27+                                xs_html_attr("href", href),
28+                                xs_html_text(name),
29+                                xs_html_text(" "))));
30+                }
31+            }
32+        }
33+
34+        xs_html_add(snac_content_wrap,
35+            add_hashtags);
36+    }
37+
38     /** controls **/
39 
40     if (!read_only && user) {