diff options
| author | 2023-11-28 10:55:12 +0100 | |
|---|---|---|
| committer | 2023-11-28 10:55:12 +0100 | |
| commit | c963a29923fce0a4689f7c71e0c1c46d059382db (patch) | |
| tree | 9fe1a906d70b343810c459ef90a3514dd2836473 /html.c | |
| parent | Converted public user into to xs_html. (diff) | |
| download | snac2-c963a29923fce0a4689f7c71e0c1c46d059382db.tar.gz snac2-c963a29923fce0a4689f7c71e0c1c46d059382db.tar.xz snac2-c963a29923fce0a4689f7c71e0c1c46d059382db.zip | |
More xs_html refactoring.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 53 |
1 files changed, 28 insertions, 25 deletions
| @@ -745,29 +745,33 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local) | |||
| 745 | 745 | ||
| 746 | /* user info */ | 746 | /* user info */ |
| 747 | { | 747 | { |
| 748 | s = xs_str_cat(s, "<div class=\"h-card snac-top-user\">\n"); | 748 | xs_html *top_user = xs_html_tag("div", |
| 749 | xs_html_attr("class", "h-card snac-top-user")); | ||
| 749 | 750 | ||
| 750 | if (local) { | 751 | if (local) { |
| 751 | const char *header = xs_dict_get(snac->config, "header"); | 752 | char *header = xs_dict_get(snac->config, "header"); |
| 752 | if (header && *header) { | 753 | if (header && *header) { |
| 753 | xs *h = encode_html(header); | 754 | xs_html_add(top_user, |
| 754 | xs *s1 = xs_fmt("<div class=\"snac-top-user-banner\" style=\"clear: both\">" | 755 | xs_html_tag("div", |
| 755 | "<br><img src=\"%s\"/></div>\n", h); | 756 | xs_html_attr("class", "snac-top-user-banner"), |
| 756 | s = xs_str_cat(s, s1); | 757 | xs_html_attr("style", "clear: both"), |
| 758 | xs_html_sctag("br", NULL), | ||
| 759 | xs_html_sctag("img", | ||
| 760 | xs_html_attr("src", header)))); | ||
| 757 | } | 761 | } |
| 758 | } | 762 | } |
| 759 | 763 | ||
| 760 | const char *_tmpl = | 764 | xs *handle = xs_fmt("@%s@%s", |
| 761 | "<p class=\"p-name snac-top-user-name\">%s</p>\n" | 765 | xs_dict_get(snac->config, "uid"), |
| 762 | "<p class=\"snac-top-user-id\">@%s@%s</p>\n"; | 766 | xs_dict_get(srv_config, "host")); |
| 763 | |||
| 764 | xs *es1 = encode_html(xs_dict_get(snac->config, "name")); | ||
| 765 | xs *es2 = encode_html(xs_dict_get(snac->config, "uid")); | ||
| 766 | xs *es3 = encode_html(xs_dict_get(srv_config, "host")); | ||
| 767 | |||
| 768 | xs *s1 = xs_fmt(_tmpl, es1, es2, es3); | ||
| 769 | 767 | ||
| 770 | s = xs_str_cat(s, s1); | 768 | xs_html_add(top_user, |
| 769 | xs_html_tag("p", | ||
| 770 | xs_html_attr("class", "p-name snac-top-user-name"), | ||
| 771 | xs_html_text(xs_dict_get(snac->config, "name"))), | ||
| 772 | xs_html_tag("p", | ||
| 773 | xs_html_attr("class", "snac-top-user-id"), | ||
| 774 | xs_html_text(handle))); | ||
| 771 | 775 | ||
| 772 | if (local) { | 776 | if (local) { |
| 773 | xs *es1 = encode_html(xs_dict_get(snac->config, "bio")); | 777 | xs *es1 = encode_html(xs_dict_get(snac->config, "bio")); |
| @@ -779,10 +783,8 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local) | |||
| 779 | xs_html_attr("class", "p-note snac-top-user-bio"), | 783 | xs_html_attr("class", "p-note snac-top-user-bio"), |
| 780 | xs_html_raw(bio2)); /* already sanitized */ | 784 | xs_html_raw(bio2)); /* already sanitized */ |
| 781 | 785 | ||
| 782 | { | 786 | xs_html_add(top_user, |
| 783 | xs *s1 = xs_html_render(top_user_bio); | 787 | top_user_bio); |
| 784 | s = xs_str_cat(s, s1); | ||
| 785 | } | ||
| 786 | 788 | ||
| 787 | xs_dict *metadata = xs_dict_get(snac->config, "metadata"); | 789 | xs_dict *metadata = xs_dict_get(snac->config, "metadata"); |
| 788 | if (xs_type(metadata) == XSTYPE_DICT) { | 790 | if (xs_type(metadata) == XSTYPE_DICT) { |
| @@ -814,14 +816,15 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local) | |||
| 814 | xs_html_sctag("br", NULL)); | 816 | xs_html_sctag("br", NULL)); |
| 815 | } | 817 | } |
| 816 | 818 | ||
| 817 | { | 819 | xs_html_add(top_user, |
| 818 | xs *s1 = xs_html_render(snac_metadata); | 820 | snac_metadata); |
| 819 | s = xs_str_cat(s, s1); | ||
| 820 | } | ||
| 821 | } | 821 | } |
| 822 | } | 822 | } |
| 823 | 823 | ||
| 824 | s = xs_str_cat(s, "</div>\n"); | 824 | { |
| 825 | xs *s1 = xs_html_render(top_user); | ||
| 826 | s = xs_str_cat(s, s1); | ||
| 827 | } | ||
| 825 | } | 828 | } |
| 826 | 829 | ||
| 827 | return s; | 830 | return s; |