diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 39 |
1 files changed, 25 insertions, 14 deletions
| @@ -143,6 +143,26 @@ xs_str *actor_name(xs_dict *actor, const char *proxy) | |||
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | 145 | ||
| 146 | xs_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 | |||
| 146 | xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date, | 166 | xs_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); |