commit 6af6194f55e751157f74a891738697e635c9c64e
parent fc9140bf1a94ea927c10db9c6bfb70afe5438bef
Author: default <nobody@localhost>
Date: Wed, 8 Jan 2025 16:51:30 +0100
Show hashtags that are not already linked from the post content.
Diffstat:
M | html.c | | | 33 | +++++++++++++++++++++++++++++++++ |
1 file changed, 33 insertions(+), 0 deletions(-)
diff --git a/html.c b/html.c
@@ -2189,6 +2189,39 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
au_tag);
}
+ /* show all hashtags that has not been shown previously in the content */
+ const xs_list *tags = xs_dict_get(msg, "tag");
+ if (xs_type(tags) == XSTYPE_LIST && xs_list_len(tags)) {
+ const char *content = xs_dict_get(msg, "content");
+ const xs_dict *tag;
+
+ xs_html *add_hashtags = xs_html_tag("ul",
+ xs_html_attr("class", "snac-more-hashtags"));
+
+ xs_list_foreach(tags, tag) {
+ const char *type = xs_dict_get(tag, "type");
+
+ if (xs_type(type) == XSTYPE_STRING && strcmp(type, "Hashtag") == 0) {
+ const char *href = xs_dict_get(tag, "href");
+
+ if (xs_type(href) == XSTYPE_STRING && xs_str_in(content, href) == -1) {
+ /* not in the content: add here */
+ const char *name = xs_dict_get(tag, "name");
+
+ xs_html_add(add_hashtags,
+ xs_html_tag("li",
+ xs_html_tag("a",
+ xs_html_attr("href", href),
+ xs_html_text(name),
+ xs_html_text(" "))));
+ }
+ }
+ }
+
+ xs_html_add(snac_content_wrap,
+ add_hashtags);
+ }
+
/** controls **/
if (!read_only && user) {