diff options
| -rw-r--r-- | html.c | 86 |
1 files changed, 56 insertions, 30 deletions
| @@ -766,7 +766,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s) | |||
| 766 | } | 766 | } |
| 767 | 767 | ||
| 768 | 768 | ||
| 769 | xs_str *html_button(xs_str *s, const char *clss, const char *label, const char *hint) | 769 | static xs_str *html_button(xs_str *s, const char *clss, const char *label, const char *hint) |
| 770 | { | 770 | { |
| 771 | xs *s1 = xs_fmt( | 771 | xs *s1 = xs_fmt( |
| 772 | "<input type=\"submit\" name=\"action\" " | 772 | "<input type=\"submit\" name=\"action\" " |
| @@ -777,6 +777,19 @@ xs_str *html_button(xs_str *s, const char *clss, const char *label, const char * | |||
| 777 | } | 777 | } |
| 778 | 778 | ||
| 779 | 779 | ||
| 780 | static xs_html *html_button_2(char *clss, char *label, char *hint) | ||
| 781 | { | ||
| 782 | xs *c = xs_fmt("snac-btn-%s", clss); | ||
| 783 | |||
| 784 | return xs_html_sctag("input", | ||
| 785 | xs_html_attr("type", "submit"), | ||
| 786 | xs_html_attr("name", "action"), | ||
| 787 | xs_html_attr("class", c), | ||
| 788 | xs_html_attr("value", label), | ||
| 789 | xs_html_attr("title", hint)); | ||
| 790 | } | ||
| 791 | |||
| 792 | |||
| 780 | xs_str *build_mentions(snac *snac, const xs_dict *msg) | 793 | xs_str *build_mentions(snac *snac, const xs_dict *msg) |
| 781 | /* returns a string with the mentions in msg */ | 794 | /* returns a string with the mentions in msg */ |
| 782 | { | 795 | { |
| @@ -1739,46 +1752,59 @@ xs_str *html_people_list(snac *snac, xs_str *os, xs_list *list, const char *head | |||
| 1739 | } | 1752 | } |
| 1740 | } | 1753 | } |
| 1741 | 1754 | ||
| 1742 | |||
| 1743 | /* buttons */ | 1755 | /* buttons */ |
| 1744 | s = xs_str_cat(s, "<div class=\"snac-controls\">\n"); | 1756 | xs *btn_form_action = xs_fmt("%s/admin/action", snac->actor); |
| 1745 | 1757 | ||
| 1746 | xs *s1 = xs_fmt( | 1758 | xs_html *snac_controls = xs_html_tag("DIV", |
| 1747 | "<p><form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" | 1759 | xs_html_attr("class", "snac-controls")); |
| 1748 | "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n" | 1760 | |
| 1749 | "<input type=\"hidden\" name=\"actor-form\" value=\"yes\">\n", | 1761 | xs_html *form = xs_html_tag("form", |
| 1750 | 1762 | xs_html_attr("autocomplete", "off"), | |
| 1751 | snac->actor, actor_id | 1763 | xs_html_attr("method", "post"), |
| 1752 | ); | 1764 | xs_html_attr("action", btn_form_action), |
| 1753 | s = xs_str_cat(s, s1); | 1765 | xs_html_sctag("input", |
| 1766 | xs_html_attr("type", "hidden"), | ||
| 1767 | xs_html_attr("name", "actor"), | ||
| 1768 | xs_html_attr("value", actor_id)), | ||
| 1769 | xs_html_sctag("input", | ||
| 1770 | xs_html_attr("type", "hidden"), | ||
| 1771 | xs_html_attr("name", "actor-form"), | ||
| 1772 | xs_html_attr("value", "yes"))); | ||
| 1773 | |||
| 1774 | xs_html_add(snac_controls, form); | ||
| 1754 | 1775 | ||
| 1755 | if (following_check(snac, actor_id)) { | 1776 | if (following_check(snac, actor_id)) { |
| 1756 | s = html_button(s, "unfollow", L("Unfollow"), | 1777 | xs_html_add(form, |
| 1757 | L("Stop following this user's activity")); | 1778 | html_button_2("unfollow", L("Unfollow"), |
| 1779 | L("Stop following this user's activity"))); | ||
| 1758 | 1780 | ||
| 1759 | if (is_limited(snac, actor_id)) | 1781 | if (is_limited(snac, actor_id)) |
| 1760 | s = html_button(s, "unlimit", L("Unlimit"), | 1782 | xs_html_add(form, |
| 1761 | L("Allow announces (boosts) from this user")); | 1783 | html_button_2("unlimit", L("Unlimit"), |
| 1784 | L("Allow announces (boosts) from this user"))); | ||
| 1762 | else | 1785 | else |
| 1763 | s = html_button(s, "limit", L("Limit"), | 1786 | xs_html_add(form, |
| 1764 | L("Block announces (boosts) from this user")); | 1787 | html_button_2("limit", L("Limit"), |
| 1788 | L("Block announces (boosts) from this user"))); | ||
| 1765 | } | 1789 | } |
| 1766 | else { | 1790 | else { |
| 1767 | s = html_button(s, "follow", L("Follow"), | 1791 | xs_html_add(form, |
| 1768 | L("Start following this user's activity")); | 1792 | html_button_2("follow", L("Follow"), |
| 1793 | L("Start following this user's activity"))); | ||
| 1769 | 1794 | ||
| 1770 | if (follower_check(snac, actor_id)) | 1795 | if (follower_check(snac, actor_id)) |
| 1771 | s = html_button(s, "delete", L("Delete"), L("Delete this user")); | 1796 | xs_html_add(form, |
| 1797 | html_button_2("delete", L("Delete"), L("Delete this user"))); | ||
| 1772 | } | 1798 | } |
| 1773 | 1799 | ||
| 1774 | if (is_muted(snac, actor_id)) | 1800 | if (is_muted(snac, actor_id)) |
| 1775 | s = html_button(s, "unmute", L("Unmute"), | 1801 | xs_html_add(form, |
| 1776 | L("Stop blocking activities from this user")); | 1802 | html_button_2("unmute", L("Unmute"), |
| 1803 | L("Stop blocking activities from this user"))); | ||
| 1777 | else | 1804 | else |
| 1778 | s = html_button(s, "mute", L("MUTE"), | 1805 | xs_html_add(form, |
| 1779 | L("Block any activity from this user")); | 1806 | html_button_2("mute", L("MUTE"), |
| 1780 | 1807 | L("Block any activity from this user"))); | |
| 1781 | s = xs_str_cat(s, "</form>\n"); | ||
| 1782 | 1808 | ||
| 1783 | /* the post textarea */ | 1809 | /* the post textarea */ |
| 1784 | xs *dm_form_id = xs_fmt("%s_%s_dm", md5, t); | 1810 | xs *dm_form_id = xs_fmt("%s_%s_dm", md5, t); |
| @@ -1821,14 +1847,14 @@ xs_str *html_people_list(snac *snac, xs_str *os, xs_list *list, const char *head | |||
| 1821 | xs_html_sctag("p", NULL))), | 1847 | xs_html_sctag("p", NULL))), |
| 1822 | xs_html_sctag("p", NULL)); | 1848 | xs_html_sctag("p", NULL)); |
| 1823 | 1849 | ||
| 1850 | xs_html_add(snac_controls, dm_textarea); | ||
| 1851 | |||
| 1824 | { | 1852 | { |
| 1825 | xs *s1 = xs_html_render(dm_textarea); | 1853 | xs *s1 = xs_html_render(snac_controls); |
| 1826 | s = xs_str_cat(s, s1); | 1854 | s = xs_str_cat(s, s1); |
| 1827 | } | 1855 | } |
| 1828 | 1856 | ||
| 1829 | s = xs_str_cat(s, "</div>\n"); | 1857 | s = xs_str_cat(s, "</div>\n"); |
| 1830 | |||
| 1831 | s = xs_str_cat(s, "</div>\n"); | ||
| 1832 | } | 1858 | } |
| 1833 | } | 1859 | } |
| 1834 | 1860 | ||