commit 6f2e407

default  ·  2023-08-07 04:06:04 +0000 UTC
parent 106791f
Added hints to web UI buttons.
1 files changed,  +31, -26
M html.c
M html.c
+31, -26
  1@@ -218,7 +218,7 @@ xs_str *html_msg_icon(snac *snac, xs_str *os, const xs_dict *msg)
  2 }
  3 
  4 
  5-d_char *html_user_header(snac *snac, d_char *s, int local)
  6+xs_str *html_user_header(snac *snac, xs_str *s, int local)
  7 /* creates the HTML header */
  8 {
  9     char *p, *v;
 10@@ -397,7 +397,7 @@ d_char *html_user_header(snac *snac, d_char *s, int local)
 11 }
 12 
 13 
 14-d_char *html_top_controls(snac *snac, d_char *s)
 15+xs_str *html_top_controls(snac *snac, xs_str *s)
 16 /* generates the top controls */
 17 {
 18     char *_tmpl =
 19@@ -423,7 +423,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
 20         "<details><summary>%s</summary>\n" /** poll **/
 21         "<p>%s:<br>\n"
 22         "<textarea class=\"snac-textarea\" name=\"poll_options\" "
 23-        "rows=\"6\" wrap=\"virtual\" placeholder=\"Option 1...\nOption 2...\nOption 3...\n....\"></textarea>\n"
 24+        "rows=\"6\" wrap=\"virtual\" placeholder=\"Option 1...\nOption 2...\nOption 3...\n...\"></textarea>\n"
 25         "<p><select name=\"poll_multiple\">\n"
 26         "<option value=\"off\">%s</option>\n"
 27         "<option value=\"on\">%s</option>\n"
 28@@ -449,7 +449,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
 29         "</form><p>\n"
 30 
 31         "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** boost **/
 32-        "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/....\">\n"
 33+        "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/...\">\n"
 34         "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n"
 35         "</form><p>\n"
 36         "</details>\n"
 37@@ -465,7 +465,7 @@ d_char *html_top_controls(snac *snac, d_char *s)
 38         "<p>%s: <input type=\"file\" name=\"avatar_file\"></p>\n"
 39 
 40         "<p>%s:<br>\n"
 41-        "<textarea name=\"bio\" cols=\"40\" rows=\"4\" placeholder=\"Write about yourself here....\">%s</textarea></p>\n"
 42+        "<textarea name=\"bio\" cols=\"40\" rows=\"4\" placeholder=\"Write about yourself here...\">%s</textarea></p>\n"
 43 
 44         "<p><input type=\"checkbox\" name=\"cw\" id=\"cw\" %s>\n"
 45         "<label for=\"cw\">%s</label></p>\n"
 46@@ -601,12 +601,12 @@ d_char *html_top_controls(snac *snac, d_char *s)
 47 }
 48 
 49 
 50-d_char *html_button(d_char *s, char *clss, char *label)
 51+xs_str *html_button(xs_str *s, const char *clss, const char *label, const char *hint)
 52 {
 53     xs *s1 = xs_fmt(
 54                "<input type=\"submit\" name=\"action\" "
 55-               "class=\"snac-btn-%s\" value=\"%s\">\n",
 56-                clss, label);
 57+               "class=\"snac-btn-%s\" value=\"%s\" title=\"%s\">\n",
 58+                clss, label, hint);
 59 
 60     return xs_str_cat(s, s1);
 61 }
 62@@ -690,37 +690,38 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch
 63     if (!xs_startswith(id, snac->actor)) {
 64         if (xs_list_in(likes, snac->md5) == -1) {
 65             /* not already liked; add button */
 66-            s = html_button(s, "like", L("Like"));
 67+            s = html_button(s, "like", L("Like"), L("Say you like this post"));
 68         }
 69     }
 70     else {
 71         if (is_pinned(snac, id))
 72-            s = html_button(s, "unpin", L("Unpin"));
 73+            s = html_button(s, "unpin", L("Unpin"), L("Unpin this post from your timeline"));
 74         else
 75-            s = html_button(s, "pin", L("Pin"));
 76+            s = html_button(s, "pin", L("Pin"), L("Pin this post to the top of your timeline"));
 77     }
 78 
 79     if (is_msg_public(snac, msg)) {
 80         if (strcmp(actor, snac->actor) == 0 || xs_list_in(boosts, snac->md5) == -1) {
 81             /* not already boosted or us; add button */
 82-            s = html_button(s, "boost", L("Boost"));
 83+            s = html_button(s, "boost", L("Boost"), L("Announce this post to your followers"));
 84         }
 85     }
 86 
 87     if (strcmp(actor, snac->actor) != 0) {
 88         /* controls for other actors than this one */
 89         if (following_check(snac, actor)) {
 90-            s = html_button(s, "unfollow", L("Unfollow"));
 91+            s = html_button(s, "unfollow", L("Unfollow"), L("Stop following this user's activity"));
 92         }
 93         else {
 94-            s = html_button(s, "follow", L("Follow"));
 95+            s = html_button(s, "follow", L("Follow"), L("Start following this user's activity"));
 96         }
 97 
 98-        s = html_button(s, "mute", L("MUTE"));
 99+        s = html_button(s, "mute", L("MUTE"),
100+            L("Block any activity from this user forever"));
101     }
102 
103-    s = html_button(s, "delete", L("Delete"));
104-    s = html_button(s, "hide",   L("Hide"));
105+    s = html_button(s, "delete", L("Delete"), L("Delete this post"));
106+    s = html_button(s, "hide",   L("Hide"), L("Hide this post and its children"));
107 
108     s = xs_str_cat(s, "</form>\n");
109 
110@@ -1433,7 +1434,7 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int
111 }
112 
113 
114-d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *header, const char *t)
115+xs_str *html_people_list(snac *snac, xs_str *os, xs_list *list, const char *header, const char *t)
116 {
117     xs *s = xs_str_new(NULL);
118     xs *es1 = encode_html(header);
119@@ -1488,18 +1489,22 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade
120             s = xs_str_cat(s, s1);
121 
122             if (following_check(snac, actor_id))
123-                s = html_button(s, "unfollow", L("Unfollow"));
124+                s = html_button(s, "unfollow", L("Unfollow"),
125+                                L("Stop following this user's activity"));
126             else {
127-                s = html_button(s, "follow", L("Follow"));
128+                s = html_button(s, "follow", L("Follow"),
129+                                L("Start following this user's activity"));
130 
131                 if (follower_check(snac, actor_id))
132-                    s = html_button(s, "delete", L("Delete"));
133+                    s = html_button(s, "delete", L("Delete"), L("Delete this user"));
134             }
135 
136             if (is_muted(snac, actor_id))
137-                s = html_button(s, "unmute", L("Unmute"));
138+                s = html_button(s, "unmute", L("Unmute"),
139+                                L("Stop blocking activities from this user"));
140             else
141-                s = html_button(s, "mute", L("MUTE"));
142+                s = html_button(s, "mute", L("MUTE"),
143+                                L("Block any activity from this user"));
144 
145             s = xs_str_cat(s, "</form>\n");
146 
147@@ -1537,9 +1542,9 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade
148 }
149 
150 
151-d_char *html_people(snac *snac)
152+xs_str *html_people(snac *snac)
153 {
154-    d_char *s = xs_str_new(NULL);
155+    xs_str *s = xs_str_new(NULL);
156     xs *wing = following_list(snac);
157     xs *wers = follower_list(snac);
158 
159@@ -1870,7 +1875,7 @@ int html_get_handler(const xs_dict *req, const char *q_path,
160     }
161     else
162     if (strcmp(p_path, ".rss") == 0) { /** public timeline in RSS format **/
163-        d_char *rss;
164+        xs_str *rss;
165         xs *elems = timeline_simple_list(&snac, "public", 0, 20);
166         xs *bio   = not_really_markdown(xs_dict_get(snac.config, "bio"), NULL);
167         char *p, *v;