summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/html.c b/html.c
index 055a27d..1e09c5e 100644
--- a/html.c
+++ b/html.c
@@ -60,7 +60,7 @@ xs_str *make_url(const char *href, const char *proxy)
60} 60}
61 61
62 62
63xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems) 63xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *proxy)
64/* replaces all the :shortnames: with the emojis in tag */ 64/* replaces all the :shortnames: with the emojis in tag */
65{ 65{
66 if (!xs_is_null(tag)) { 66 if (!xs_is_null(tag)) {
@@ -88,9 +88,11 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems)
88 88
89 if (n && i) { 89 if (n && i) {
90 const char *u = xs_dict_get(i, "url"); 90 const char *u = xs_dict_get(i, "url");
91 xs *url = make_url(u, proxy);
92
91 xs_html *img = xs_html_sctag("img", 93 xs_html *img = xs_html_sctag("img",
92 xs_html_attr("loading", "lazy"), 94 xs_html_attr("loading", "lazy"),
93 xs_html_attr("src", u), 95 xs_html_attr("src", url),
94 xs_html_attr("style", style)); 96 xs_html_attr("style", style));
95 97
96 xs *s1 = xs_html_render(img); 98 xs *s1 = xs_html_render(img);
@@ -104,7 +106,7 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems)
104} 106}
105 107
106 108
107xs_str *actor_name(xs_dict *actor) 109xs_str *actor_name(xs_dict *actor, const char *proxy)
108/* gets the actor name */ 110/* gets the actor name */
109{ 111{
110 const char *v; 112 const char *v;
@@ -115,7 +117,7 @@ xs_str *actor_name(xs_dict *actor)
115 } 117 }
116 } 118 }
117 119
118 return replace_shortnames(xs_html_encode(v), xs_dict_get(actor, "tag"), 1); 120 return replace_shortnames(xs_html_encode(v), xs_dict_get(actor, "tag"), 1, proxy);
119} 121}
120 122
121 123
@@ -129,7 +131,7 @@ xs_html *html_actor_icon(snac *user, xs_dict *actor, const char *date,
129 int fwing = 0; 131 int fwing = 0;
130 int fwer = 0; 132 int fwer = 0;
131 133
132 xs *name = actor_name(actor); 134 xs *name = actor_name(actor, proxy);
133 135
134 /* get the avatar */ 136 /* get the avatar */
135 if ((v = xs_dict_get(actor, "icon")) != NULL) { 137 if ((v = xs_dict_get(actor, "icon")) != NULL) {
@@ -700,6 +702,11 @@ xs_html *html_user_head(snac *user, const char *desc, const char *url)
700 702
701static xs_html *html_user_body(snac *user, int read_only) 703static xs_html *html_user_body(snac *user, int read_only)
702{ 704{
705 const char *proxy = NULL;
706
707 if (user && !read_only && xs_is_true(xs_dict_get(srv_config, "proxy_media")))
708 proxy = user->actor;
709
703 xs_html *body = xs_html_tag("body", NULL); 710 xs_html *body = xs_html_tag("body", NULL);
704 711
705 /* top nav */ 712 /* top nav */
@@ -845,7 +852,7 @@ static xs_html *html_user_body(snac *user, int read_only)
845 xs *bio1 = not_really_markdown(es1, NULL, &tags); 852 xs *bio1 = not_really_markdown(es1, NULL, &tags);
846 xs *bio2 = process_tags(user, bio1, &tags); 853 xs *bio2 = process_tags(user, bio1, &tags);
847 854
848 bio2 = replace_shortnames(bio2, tags, 2); 855 bio2 = replace_shortnames(bio2, tags, 2, proxy);
849 856
850 xs_html *top_user_bio = xs_html_tag("div", 857 xs_html *top_user_bio = xs_html_tag("div",
851 xs_html_attr("class", "p-note snac-top-user-bio"), 858 xs_html_attr("class", "p-note snac-top-user-bio"),
@@ -1648,7 +1655,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
1648 } 1655 }
1649 else 1656 else
1650 if (valid_status(object_get_by_md5(p, &actor_r))) { 1657 if (valid_status(object_get_by_md5(p, &actor_r))) {
1651 xs *name = actor_name(actor_r); 1658 xs *name = actor_name(actor_r, proxy);
1652 1659
1653 if (!xs_is_null(name)) { 1660 if (!xs_is_null(name)) {
1654 xs *href = NULL; 1661 xs *href = NULL;
@@ -1786,7 +1793,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
1786 c = xs_str_cat(c, "<p>"); 1793 c = xs_str_cat(c, "<p>");
1787 1794
1788 /* replace the :shortnames: */ 1795 /* replace the :shortnames: */
1789 c = replace_shortnames(c, xs_dict_get(msg, "tag"), 2); 1796 c = replace_shortnames(c, xs_dict_get(msg, "tag"), 2, proxy);
1790 1797
1791 /* Peertube videos content is in markdown */ 1798 /* Peertube videos content is in markdown */
1792 const char *mtype = xs_dict_get(msg, "mediaType"); 1799 const char *mtype = xs_dict_get(msg, "mediaType");
@@ -2652,7 +2659,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
2652 if (!valid_status(actor_get(actor_id, &actor))) 2659 if (!valid_status(actor_get(actor_id, &actor)))
2653 continue; 2660 continue;
2654 2661
2655 xs *a_name = actor_name(actor); 2662 xs *a_name = actor_name(actor, proxy);
2656 const char *label = type; 2663 const char *label = type;
2657 2664
2658 if (strcmp(type, "Create") == 0) 2665 if (strcmp(type, "Create") == 0)