summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--html.c49
1 files changed, 19 insertions, 30 deletions
diff --git a/html.c b/html.c
index cfa7ede..49b0de2 100644
--- a/html.c
+++ b/html.c
@@ -944,18 +944,7 @@ xs_str *html_top_controls(snac *snac, xs_str *s)
944} 944}
945 945
946 946
947static xs_str *html_button(xs_str *s, const char *clss, const char *label, const char *hint) 947static xs_html *html_button(char *clss, char *label, char *hint)
948{
949 xs *s1 = xs_fmt(
950 "<input type=\"submit\" name=\"action\" "
951 "class=\"snac-btn-%s\" value=\"%s\" title=\"%s\">\n",
952 clss, label, hint);
953
954 return xs_str_cat(s, s1);
955}
956
957
958static xs_html *html_button_2(char *clss, char *label, char *hint)
959{ 948{
960 xs *c = xs_fmt("snac-btn-%s", clss); 949 xs *c = xs_fmt("snac-btn-%s", clss);
961 950
@@ -1058,23 +1047,23 @@ xs_html *html_entry_controls(snac *snac, const xs_dict *msg, const char *md5)
1058 if (xs_list_in(likes, snac->md5) == -1) { 1047 if (xs_list_in(likes, snac->md5) == -1) {
1059 /* not already liked; add button */ 1048 /* not already liked; add button */
1060 xs_html_add(form, 1049 xs_html_add(form,
1061 html_button_2("like", L("Like"), L("Say you like this post"))); 1050 html_button("like", L("Like"), L("Say you like this post")));
1062 } 1051 }
1063 } 1052 }
1064 else { 1053 else {
1065 if (is_pinned(snac, id)) 1054 if (is_pinned(snac, id))
1066 xs_html_add(form, 1055 xs_html_add(form,
1067 html_button_2("unpin", L("Unpin"), L("Unpin this post from your timeline"))); 1056 html_button("unpin", L("Unpin"), L("Unpin this post from your timeline")));
1068 else 1057 else
1069 xs_html_add(form, 1058 xs_html_add(form,
1070 html_button_2("pin", L("Pin"), L("Pin this post to the top of your timeline"))); 1059 html_button("pin", L("Pin"), L("Pin this post to the top of your timeline")));
1071 } 1060 }
1072 1061
1073 if (is_msg_public(msg)) { 1062 if (is_msg_public(msg)) {
1074 if (strcmp(actor, snac->actor) == 0 || xs_list_in(boosts, snac->md5) == -1) { 1063 if (strcmp(actor, snac->actor) == 0 || xs_list_in(boosts, snac->md5) == -1) {
1075 /* not already boosted or us; add button */ 1064 /* not already boosted or us; add button */
1076 xs_html_add(form, 1065 xs_html_add(form,
1077 html_button_2("boost", L("Boost"), L("Announce this post to your followers"))); 1066 html_button("boost", L("Boost"), L("Announce this post to your followers")));
1078 } 1067 }
1079 } 1068 }
1080 1069
@@ -1082,34 +1071,34 @@ xs_html *html_entry_controls(snac *snac, const xs_dict *msg, const char *md5)
1082 /* controls for other actors than this one */ 1071 /* controls for other actors than this one */
1083 if (following_check(snac, actor)) { 1072 if (following_check(snac, actor)) {
1084 xs_html_add(form, 1073 xs_html_add(form,
1085 html_button_2("unfollow", L("Unfollow"), L("Stop following this user's activity"))); 1074 html_button("unfollow", L("Unfollow"), L("Stop following this user's activity")));
1086 } 1075 }
1087 else { 1076 else {
1088 xs_html_add(form, 1077 xs_html_add(form,
1089 html_button_2("follow", L("Follow"), L("Start following this user's activity"))); 1078 html_button("follow", L("Follow"), L("Start following this user's activity")));
1090 } 1079 }
1091 1080
1092 if (!xs_is_null(group)) { 1081 if (!xs_is_null(group)) {
1093 if (following_check(snac, group)) { 1082 if (following_check(snac, group)) {
1094 xs_html_add(form, 1083 xs_html_add(form,
1095 html_button_2("unfollow", L("Unfollow Group"), 1084 html_button("unfollow", L("Unfollow Group"),
1096 L("Stop following this group or channel"))); 1085 L("Stop following this group or channel")));
1097 } 1086 }
1098 else { 1087 else {
1099 xs_html_add(form, 1088 xs_html_add(form,
1100 html_button_2("follow", L("Follow Group"), 1089 html_button("follow", L("Follow Group"),
1101 L("Start following this group or channel"))); 1090 L("Start following this group or channel")));
1102 } 1091 }
1103 } 1092 }
1104 1093
1105 xs_html_add(form, 1094 xs_html_add(form,
1106 html_button_2("mute", L("MUTE"), 1095 html_button("mute", L("MUTE"),
1107 L("Block any activity from this user forever"))); 1096 L("Block any activity from this user forever")));
1108 } 1097 }
1109 1098
1110 xs_html_add(form, 1099 xs_html_add(form,
1111 html_button_2("delete", L("Delete"), L("Delete this post")), 1100 html_button("delete", L("Delete"), L("Delete this post")),
1112 html_button_2("hide", L("Hide"), L("Hide this post and its children"))); 1101 html_button("hide", L("Hide"), L("Hide this post and its children")));
1113 1102
1114 char *prev_src = xs_dict_get(msg, "sourceContent"); 1103 char *prev_src = xs_dict_get(msg, "sourceContent");
1115 1104
@@ -1894,35 +1883,35 @@ xs_html *html_people_list(snac *snac, xs_list *list, char *header, char *t)
1894 1883
1895 if (following_check(snac, actor_id)) { 1884 if (following_check(snac, actor_id)) {
1896 xs_html_add(form, 1885 xs_html_add(form,
1897 html_button_2("unfollow", L("Unfollow"), 1886 html_button("unfollow", L("Unfollow"),
1898 L("Stop following this user's activity"))); 1887 L("Stop following this user's activity")));
1899 1888
1900 if (is_limited(snac, actor_id)) 1889 if (is_limited(snac, actor_id))
1901 xs_html_add(form, 1890 xs_html_add(form,
1902 html_button_2("unlimit", L("Unlimit"), 1891 html_button("unlimit", L("Unlimit"),
1903 L("Allow announces (boosts) from this user"))); 1892 L("Allow announces (boosts) from this user")));
1904 else 1893 else
1905 xs_html_add(form, 1894 xs_html_add(form,
1906 html_button_2("limit", L("Limit"), 1895 html_button("limit", L("Limit"),
1907 L("Block announces (boosts) from this user"))); 1896 L("Block announces (boosts) from this user")));
1908 } 1897 }
1909 else { 1898 else {
1910 xs_html_add(form, 1899 xs_html_add(form,
1911 html_button_2("follow", L("Follow"), 1900 html_button("follow", L("Follow"),
1912 L("Start following this user's activity"))); 1901 L("Start following this user's activity")));
1913 1902
1914 if (follower_check(snac, actor_id)) 1903 if (follower_check(snac, actor_id))
1915 xs_html_add(form, 1904 xs_html_add(form,
1916 html_button_2("delete", L("Delete"), L("Delete this user"))); 1905 html_button("delete", L("Delete"), L("Delete this user")));
1917 } 1906 }
1918 1907
1919 if (is_muted(snac, actor_id)) 1908 if (is_muted(snac, actor_id))
1920 xs_html_add(form, 1909 xs_html_add(form,
1921 html_button_2("unmute", L("Unmute"), 1910 html_button("unmute", L("Unmute"),
1922 L("Stop blocking activities from this user"))); 1911 L("Stop blocking activities from this user")));
1923 else 1912 else
1924 xs_html_add(form, 1913 xs_html_add(form,
1925 html_button_2("mute", L("MUTE"), 1914 html_button("mute", L("MUTE"),
1926 L("Block any activity from this user"))); 1915 L("Block any activity from this user")));
1927 1916
1928 /* the post textarea */ 1917 /* the post textarea */