diff options
| author | 2023-08-07 06:06:04 +0200 | |
|---|---|---|
| committer | 2023-08-07 06:06:04 +0200 | |
| commit | 6f2e407692b76fa45916e71153004129ebc269c1 (patch) | |
| tree | 58ab4ee4fee689c67d78b9f9f7f189ba13141015 | |
| parent | Added command-line interface for limit/unlimit users. (diff) | |
| download | snac2-6f2e407692b76fa45916e71153004129ebc269c1.tar.gz snac2-6f2e407692b76fa45916e71153004129ebc269c1.tar.xz snac2-6f2e407692b76fa45916e71153004129ebc269c1.zip | |
Added hints to web UI buttons.
| -rw-r--r-- | html.c | 57 |
1 files changed, 31 insertions, 26 deletions
| @@ -218,7 +218,7 @@ xs_str *html_msg_icon(snac *snac, xs_str *os, const xs_dict *msg) | |||
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | 220 | ||
| 221 | d_char *html_user_header(snac *snac, d_char *s, int local) | 221 | xs_str *html_user_header(snac *snac, xs_str *s, int local) |
| 222 | /* creates the HTML header */ | 222 | /* creates the HTML header */ |
| 223 | { | 223 | { |
| 224 | char *p, *v; | 224 | char *p, *v; |
| @@ -397,7 +397,7 @@ d_char *html_user_header(snac *snac, d_char *s, int local) | |||
| 397 | } | 397 | } |
| 398 | 398 | ||
| 399 | 399 | ||
| 400 | d_char *html_top_controls(snac *snac, d_char *s) | 400 | xs_str *html_top_controls(snac *snac, xs_str *s) |
| 401 | /* generates the top controls */ | 401 | /* generates the top controls */ |
| 402 | { | 402 | { |
| 403 | char *_tmpl = | 403 | char *_tmpl = |
| @@ -423,7 +423,7 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 423 | "<details><summary>%s</summary>\n" /** poll **/ | 423 | "<details><summary>%s</summary>\n" /** poll **/ |
| 424 | "<p>%s:<br>\n" | 424 | "<p>%s:<br>\n" |
| 425 | "<textarea class=\"snac-textarea\" name=\"poll_options\" " | 425 | "<textarea class=\"snac-textarea\" name=\"poll_options\" " |
| 426 | "rows=\"6\" wrap=\"virtual\" placeholder=\"Option 1...\nOption 2...\nOption 3...\n....\"></textarea>\n" | 426 | "rows=\"6\" wrap=\"virtual\" placeholder=\"Option 1...\nOption 2...\nOption 3...\n...\"></textarea>\n" |
| 427 | "<p><select name=\"poll_multiple\">\n" | 427 | "<p><select name=\"poll_multiple\">\n" |
| 428 | "<option value=\"off\">%s</option>\n" | 428 | "<option value=\"off\">%s</option>\n" |
| 429 | "<option value=\"on\">%s</option>\n" | 429 | "<option value=\"on\">%s</option>\n" |
| @@ -449,7 +449,7 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 449 | "</form><p>\n" | 449 | "</form><p>\n" |
| 450 | 450 | ||
| 451 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** boost **/ | 451 | "<form autocomplete=\"off\" method=\"post\" action=\"%s/admin/action\">\n" /** boost **/ |
| 452 | "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/....\">\n" | 452 | "<input type=\"text\" name=\"id\" required=\"required\" placeholder=\"https://fedi.example.com/bob/...\">\n" |
| 453 | "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" | 453 | "<input type=\"submit\" name=\"action\" value=\"%s\"> %s\n" |
| 454 | "</form><p>\n" | 454 | "</form><p>\n" |
| 455 | "</details>\n" | 455 | "</details>\n" |
| @@ -465,7 +465,7 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 465 | "<p>%s: <input type=\"file\" name=\"avatar_file\"></p>\n" | 465 | "<p>%s: <input type=\"file\" name=\"avatar_file\"></p>\n" |
| 466 | 466 | ||
| 467 | "<p>%s:<br>\n" | 467 | "<p>%s:<br>\n" |
| 468 | "<textarea name=\"bio\" cols=\"40\" rows=\"4\" placeholder=\"Write about yourself here....\">%s</textarea></p>\n" | 468 | "<textarea name=\"bio\" cols=\"40\" rows=\"4\" placeholder=\"Write about yourself here...\">%s</textarea></p>\n" |
| 469 | 469 | ||
| 470 | "<p><input type=\"checkbox\" name=\"cw\" id=\"cw\" %s>\n" | 470 | "<p><input type=\"checkbox\" name=\"cw\" id=\"cw\" %s>\n" |
| 471 | "<label for=\"cw\">%s</label></p>\n" | 471 | "<label for=\"cw\">%s</label></p>\n" |
| @@ -601,12 +601,12 @@ d_char *html_top_controls(snac *snac, d_char *s) | |||
| 601 | } | 601 | } |
| 602 | 602 | ||
| 603 | 603 | ||
| 604 | d_char *html_button(d_char *s, char *clss, char *label) | 604 | xs_str *html_button(xs_str *s, const char *clss, const char *label, const char *hint) |
| 605 | { | 605 | { |
| 606 | xs *s1 = xs_fmt( | 606 | xs *s1 = xs_fmt( |
| 607 | "<input type=\"submit\" name=\"action\" " | 607 | "<input type=\"submit\" name=\"action\" " |
| 608 | "class=\"snac-btn-%s\" value=\"%s\">\n", | 608 | "class=\"snac-btn-%s\" value=\"%s\" title=\"%s\">\n", |
| 609 | clss, label); | 609 | clss, label, hint); |
| 610 | 610 | ||
| 611 | return xs_str_cat(s, s1); | 611 | return xs_str_cat(s, s1); |
| 612 | } | 612 | } |
| @@ -690,37 +690,38 @@ xs_str *html_entry_controls(snac *snac, xs_str *os, const xs_dict *msg, const ch | |||
| 690 | if (!xs_startswith(id, snac->actor)) { | 690 | if (!xs_startswith(id, snac->actor)) { |
| 691 | if (xs_list_in(likes, snac->md5) == -1) { | 691 | if (xs_list_in(likes, snac->md5) == -1) { |
| 692 | /* not already liked; add button */ | 692 | /* not already liked; add button */ |
| 693 | s = html_button(s, "like", L("Like")); | 693 | s = html_button(s, "like", L("Like"), L("Say you like this post")); |
| 694 | } | 694 | } |
| 695 | } | 695 | } |
| 696 | else { | 696 | else { |
| 697 | if (is_pinned(snac, id)) | 697 | if (is_pinned(snac, id)) |
| 698 | s = html_button(s, "unpin", L("Unpin")); | 698 | s = html_button(s, "unpin", L("Unpin"), L("Unpin this post from your timeline")); |
| 699 | else | 699 | else |
| 700 | s = html_button(s, "pin", L("Pin")); | 700 | s = html_button(s, "pin", L("Pin"), L("Pin this post to the top of your timeline")); |
| 701 | } | 701 | } |
| 702 | 702 | ||
| 703 | if (is_msg_public(snac, msg)) { | 703 | if (is_msg_public(snac, msg)) { |
| 704 | if (strcmp(actor, snac->actor) == 0 || xs_list_in(boosts, snac->md5) == -1) { | 704 | if (strcmp(actor, snac->actor) == 0 || xs_list_in(boosts, snac->md5) == -1) { |
| 705 | /* not already boosted or us; add button */ | 705 | /* not already boosted or us; add button */ |
| 706 | s = html_button(s, "boost", L("Boost")); | 706 | s = html_button(s, "boost", L("Boost"), L("Announce this post to your followers")); |
| 707 | } | 707 | } |
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | if (strcmp(actor, snac->actor) != 0) { | 710 | if (strcmp(actor, snac->actor) != 0) { |
| 711 | /* controls for other actors than this one */ | 711 | /* controls for other actors than this one */ |
| 712 | if (following_check(snac, actor)) { | 712 | if (following_check(snac, actor)) { |
| 713 | s = html_button(s, "unfollow", L("Unfollow")); | 713 | s = html_button(s, "unfollow", L("Unfollow"), L("Stop following this user's activity")); |
| 714 | } | 714 | } |
| 715 | else { | 715 | else { |
| 716 | s = html_button(s, "follow", L("Follow")); | 716 | s = html_button(s, "follow", L("Follow"), L("Start following this user's activity")); |
| 717 | } | 717 | } |
| 718 | 718 | ||
| 719 | s = html_button(s, "mute", L("MUTE")); | 719 | s = html_button(s, "mute", L("MUTE"), |
| 720 | L("Block any activity from this user forever")); | ||
| 720 | } | 721 | } |
| 721 | 722 | ||
| 722 | s = html_button(s, "delete", L("Delete")); | 723 | s = html_button(s, "delete", L("Delete"), L("Delete this post")); |
| 723 | s = html_button(s, "hide", L("Hide")); | 724 | s = html_button(s, "hide", L("Hide"), L("Hide this post and its children")); |
| 724 | 725 | ||
| 725 | s = xs_str_cat(s, "</form>\n"); | 726 | s = xs_str_cat(s, "</form>\n"); |
| 726 | 727 | ||
| @@ -1433,7 +1434,7 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int | |||
| 1433 | } | 1434 | } |
| 1434 | 1435 | ||
| 1435 | 1436 | ||
| 1436 | d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *header, const char *t) | 1437 | xs_str *html_people_list(snac *snac, xs_str *os, xs_list *list, const char *header, const char *t) |
| 1437 | { | 1438 | { |
| 1438 | xs *s = xs_str_new(NULL); | 1439 | xs *s = xs_str_new(NULL); |
| 1439 | xs *es1 = encode_html(header); | 1440 | xs *es1 = encode_html(header); |
| @@ -1488,18 +1489,22 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade | |||
| 1488 | s = xs_str_cat(s, s1); | 1489 | s = xs_str_cat(s, s1); |
| 1489 | 1490 | ||
| 1490 | if (following_check(snac, actor_id)) | 1491 | if (following_check(snac, actor_id)) |
| 1491 | s = html_button(s, "unfollow", L("Unfollow")); | 1492 | s = html_button(s, "unfollow", L("Unfollow"), |
| 1493 | L("Stop following this user's activity")); | ||
| 1492 | else { | 1494 | else { |
| 1493 | s = html_button(s, "follow", L("Follow")); | 1495 | s = html_button(s, "follow", L("Follow"), |
| 1496 | L("Start following this user's activity")); | ||
| 1494 | 1497 | ||
| 1495 | if (follower_check(snac, actor_id)) | 1498 | if (follower_check(snac, actor_id)) |
| 1496 | s = html_button(s, "delete", L("Delete")); | 1499 | s = html_button(s, "delete", L("Delete"), L("Delete this user")); |
| 1497 | } | 1500 | } |
| 1498 | 1501 | ||
| 1499 | if (is_muted(snac, actor_id)) | 1502 | if (is_muted(snac, actor_id)) |
| 1500 | s = html_button(s, "unmute", L("Unmute")); | 1503 | s = html_button(s, "unmute", L("Unmute"), |
| 1504 | L("Stop blocking activities from this user")); | ||
| 1501 | else | 1505 | else |
| 1502 | s = html_button(s, "mute", L("MUTE")); | 1506 | s = html_button(s, "mute", L("MUTE"), |
| 1507 | L("Block any activity from this user")); | ||
| 1503 | 1508 | ||
| 1504 | s = xs_str_cat(s, "</form>\n"); | 1509 | s = xs_str_cat(s, "</form>\n"); |
| 1505 | 1510 | ||
| @@ -1537,9 +1542,9 @@ d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *heade | |||
| 1537 | } | 1542 | } |
| 1538 | 1543 | ||
| 1539 | 1544 | ||
| 1540 | d_char *html_people(snac *snac) | 1545 | xs_str *html_people(snac *snac) |
| 1541 | { | 1546 | { |
| 1542 | d_char *s = xs_str_new(NULL); | 1547 | xs_str *s = xs_str_new(NULL); |
| 1543 | xs *wing = following_list(snac); | 1548 | xs *wing = following_list(snac); |
| 1544 | xs *wers = follower_list(snac); | 1549 | xs *wers = follower_list(snac); |
| 1545 | 1550 | ||
| @@ -1870,7 +1875,7 @@ int html_get_handler(const xs_dict *req, const char *q_path, | |||
| 1870 | } | 1875 | } |
| 1871 | else | 1876 | else |
| 1872 | if (strcmp(p_path, ".rss") == 0) { /** public timeline in RSS format **/ | 1877 | if (strcmp(p_path, ".rss") == 0) { /** public timeline in RSS format **/ |
| 1873 | d_char *rss; | 1878 | xs_str *rss; |
| 1874 | xs *elems = timeline_simple_list(&snac, "public", 0, 20); | 1879 | xs *elems = timeline_simple_list(&snac, "public", 0, 20); |
| 1875 | xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio"), NULL); | 1880 | xs *bio = not_really_markdown(xs_dict_get(snac.config, "bio"), NULL); |
| 1876 | char *p, *v; | 1881 | char *p, *v; |