summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html.c39
-rw-r--r--httpd.c4
-rw-r--r--snac.h1
3 files changed, 29 insertions, 15 deletions
diff --git a/html.c b/html.c
index c8015a1..f3d5ee9 100644
--- a/html.c
+++ b/html.c
@@ -143,6 +143,26 @@ xs_str *actor_name(xs_dict *actor, const char *proxy)
143} 143}
144 144
145 145
146xs_str *format_text_with_emoji(snac *user, const char *text, int ems, const char *proxy)
147/* needed when we have local text with no tags attached */
148{
149 xs *tags = xs_list_new();
150 xs *name1 = not_really_markdown(text, NULL, &tags);
151
152 xs_str *name3;
153 if (user) {
154 xs *name2 = process_tags(user, name1, &tags);
155 name3 = sanitize(name2);
156 }
157 else {
158 name3 = sanitize(name1);
159 name3 = xs_replace_i(name3, "<br>", "");
160 }
161
162 return replace_shortnames(name3, tags, ems, proxy);
163}
164
165
146xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, 166xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
147 const char *udate, const char *url, int priv, 167 const char *udate, const char *url, int priv,
148 int in_people, const char *proxy, const char *lang, 168 int in_people, const char *proxy, const char *lang,
@@ -976,16 +996,12 @@ static xs_html *html_user_body(snac *user, int read_only)
976 xs_dict_get(user->config, "uid"), 996 xs_dict_get(user->config, "uid"),
977 xs_dict_get(srv_config, "host")); 997 xs_dict_get(srv_config, "host"));
978 998
979 // also try to make emojis render in local usernames, specifically in the user info thing in the web ui 999 xs *display_name = format_text_with_emoji(NULL, xs_dict_get(user->config, "name"), 1, proxy);
980 xs *name_tags = xs_list_new();
981 xs *name1 = not_really_markdown(xs_dict_get(user->config, "name"), NULL, &name_tags);
982 xs *name2 = sanitize(name1);
983 name2 = replace_shortnames(name2, name_tags, 1, proxy);
984 1000
985 xs_html_add(top_user, 1001 xs_html_add(top_user,
986 xs_html_tag("p", 1002 xs_html_tag("p",
987 xs_html_attr("class", "p-name snac-top-user-name"), 1003 xs_html_attr("class", "p-name snac-top-user-name"),
988 xs_html_raw(name2)), 1004 xs_html_raw(display_name)),
989 xs_html_tag("p", 1005 xs_html_tag("p",
990 xs_html_attr("class", "snac-top-user-id"), 1006 xs_html_attr("class", "snac-top-user-id"),
991 xs_html_text(handle))); 1007 xs_html_text(handle)));
@@ -1013,16 +1029,11 @@ static xs_html *html_user_body(snac *user, int read_only)
1013 } 1029 }
1014 1030
1015 if (read_only) { 1031 if (read_only) {
1016 xs *tags = xs_list_new(); 1032 xs *bio = format_text_with_emoji(user, xs_dict_get(user->config, "bio"), 2, proxy);
1017 xs *bio1 = not_really_markdown(xs_dict_get(user->config, "bio"), NULL, &tags);
1018 xs *bio2 = process_tags(user, bio1, &tags);
1019 xs *bio3 = sanitize(bio2);
1020
1021 bio3 = replace_shortnames(bio3, tags, 2, proxy);
1022 1033
1023 xs_html *top_user_bio = xs_html_tag("div", 1034 xs_html *top_user_bio = xs_html_tag("div",
1024 xs_html_attr("class", "p-note snac-top-user-bio"), 1035 xs_html_attr("class", "p-note snac-top-user-bio"),
1025 xs_html_raw(bio3)); /* already sanitized */ 1036 xs_html_raw(bio)); /* already sanitized */
1026 1037
1027 xs_html_add(top_user, 1038 xs_html_add(top_user,
1028 top_user_bio); 1039 top_user_bio);
@@ -3675,7 +3686,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
3675 3686
3676 if (xs_is_true(xs_dict_get(srv_config, "strict_public_timelines"))) 3687 if (xs_is_true(xs_dict_get(srv_config, "strict_public_timelines")))
3677 list = timeline_simple_list(&snac, "public", skip, show, &more); 3688 list = timeline_simple_list(&snac, "public", skip, show, &more);
3678 else 3689 else
3679 list = timeline_list(&snac, "public", skip, show, &more); 3690 list = timeline_list(&snac, "public", skip, show, &more);
3680 3691
3681 xs *pins = pinned_list(&snac); 3692 xs *pins = pinned_list(&snac);
diff --git a/httpd.c b/httpd.c
index 22a148d..836c256 100644
--- a/httpd.c
+++ b/httpd.c
@@ -139,6 +139,8 @@ static xs_str *greeting_html(void)
139 snac user; 139 snac user;
140 140
141 if (strcmp(uid, "relay") && user_open(&user, uid)) { 141 if (strcmp(uid, "relay") && user_open(&user, uid)) {
142 xs *formatted_name = format_text_with_emoji(NULL, xs_dict_get(user.config, "name"), 1, NULL);
143
142 xs_html_add(ul, 144 xs_html_add(ul,
143 xs_html_tag("li", 145 xs_html_tag("li",
144 xs_html_tag("a", 146 xs_html_tag("a",
@@ -148,7 +150,7 @@ static xs_str *greeting_html(void)
148 xs_html_text("@"), 150 xs_html_text("@"),
149 xs_html_text(host), 151 xs_html_text(host),
150 xs_html_text(" ("), 152 xs_html_text(" ("),
151 xs_html_text(xs_dict_get(user.config, "name")), 153 xs_html_raw(formatted_name),
152 xs_html_text(")")))); 154 xs_html_text(")"))));
153 155
154 user_free(&user); 156 user_free(&user);
diff --git a/snac.h b/snac.h
index 0d2aafe..90f8bd8 100644
--- a/snac.h
+++ b/snac.h
@@ -373,6 +373,7 @@ int activitypub_post_handler(const xs_dict *req, const char *q_path,
373 char **body, int *b_size, char **ctype); 373 char **body, int *b_size, char **ctype);
374 374
375xs_dict *emojis(void); 375xs_dict *emojis(void);
376xs_str *format_text_with_emoji(snac *user, const char *text, int ems, const char *proxy);
376xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag); 377xs_str *not_really_markdown(const char *content, xs_list **attach, xs_list **tag);
377xs_str *sanitize(const char *content); 378xs_str *sanitize(const char *content);
378xs_str *encode_html(const char *str); 379xs_str *encode_html(const char *str);