diff options
| -rw-r--r-- | html.c | 42 |
1 files changed, 29 insertions, 13 deletions
| @@ -774,34 +774,50 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local) | |||
| 774 | xs *bio1 = not_really_markdown(es1, NULL); | 774 | xs *bio1 = not_really_markdown(es1, NULL); |
| 775 | xs *tags = xs_list_new(); | 775 | xs *tags = xs_list_new(); |
| 776 | xs *bio2 = process_tags(snac, bio1, &tags); | 776 | xs *bio2 = process_tags(snac, bio1, &tags); |
| 777 | xs *s1 = xs_fmt("<div class=\"p-note snac-top-user-bio\">%s</div>\n", bio2); | ||
| 778 | 777 | ||
| 779 | s = xs_str_cat(s, s1); | 778 | xs_html *top_user_bio = xs_html_tag("div", |
| 779 | xs_html_attr("class", "p-note snac-top-user-bio"), | ||
| 780 | xs_html_raw(bio2)); /* already sanitized */ | ||
| 781 | |||
| 782 | { | ||
| 783 | xs *s1 = xs_html_render(top_user_bio); | ||
| 784 | s = xs_str_cat(s, s1); | ||
| 785 | } | ||
| 780 | 786 | ||
| 781 | xs_dict *metadata = xs_dict_get(snac->config, "metadata"); | 787 | xs_dict *metadata = xs_dict_get(snac->config, "metadata"); |
| 782 | if (xs_type(metadata) == XSTYPE_DICT) { | 788 | if (xs_type(metadata) == XSTYPE_DICT) { |
| 783 | xs_str *k; | 789 | xs_str *k; |
| 784 | xs_str *v; | 790 | xs_str *v; |
| 785 | 791 | ||
| 786 | s = xs_str_cat(s, "<br><div class=\"snac-metadata\">\n"); | 792 | xs_html *snac_metadata = xs_html_tag("div", |
| 793 | xs_html_attr("class", "snac-metadata")); | ||
| 787 | 794 | ||
| 788 | while (xs_dict_iter(&metadata, &k, &v)) { | 795 | while (xs_dict_iter(&metadata, &k, &v)) { |
| 789 | xs *k2 = encode_html(k); | 796 | xs_html *value; |
| 790 | xs *v2 = encode_html(v); | ||
| 791 | xs *v3 = NULL; | ||
| 792 | 797 | ||
| 793 | if (xs_startswith(v, "https:/" "/")) | 798 | if (xs_startswith(v, "https:/" "/")) |
| 794 | v3 = xs_fmt("<a href=\"%s\">%s</a>", v2, v2); | 799 | value = xs_html_tag("a", |
| 800 | xs_html_attr("href", v), | ||
| 801 | xs_html_text(v)); | ||
| 795 | else | 802 | else |
| 796 | v3 = xs_dup(v2); | 803 | value = xs_html_text(v); |
| 797 | 804 | ||
| 798 | xs *s1 = xs_fmt("<span class=\"snac-property-name\">%s</span>:<br>" | 805 | xs_html_add(snac_metadata, |
| 799 | "<span class=\"snac-property-value\">%s</span><br>\n", k2, v3); | 806 | xs_html_tag("span", |
| 807 | xs_html_attr("class", "snac-property-name"), | ||
| 808 | xs_html_text(k)), | ||
| 809 | xs_html_text(":"), | ||
| 810 | xs_html_sctag("br", NULL), | ||
| 811 | xs_html_tag("span", | ||
| 812 | xs_html_attr("class", "snac-property-value"), | ||
| 813 | value), | ||
| 814 | xs_html_sctag("br", NULL)); | ||
| 815 | } | ||
| 800 | 816 | ||
| 817 | { | ||
| 818 | xs *s1 = xs_html_render(snac_metadata); | ||
| 801 | s = xs_str_cat(s, s1); | 819 | s = xs_str_cat(s, s1); |
| 802 | } | 820 | } |
| 803 | |||
| 804 | s = xs_str_cat(s, "</div>\n"); | ||
| 805 | } | 821 | } |
| 806 | } | 822 | } |
| 807 | 823 | ||