diff options
| author | 2022-12-08 07:40:15 +0100 | |
|---|---|---|
| committer | 2022-12-08 07:40:15 +0100 | |
| commit | a1673e6d0c23136a571b89b3aa7933837a05daa6 (patch) | |
| tree | e315ddb2975732161f18842ba669b8e4c655d7d0 | |
| parent | Wrapped too long string literals. (diff) | |
| download | snac2-a1673e6d0c23136a571b89b3aa7933837a05daa6.tar.gz snac2-a1673e6d0c23136a571b89b3aa7933837a05daa6.tar.xz snac2-a1673e6d0c23136a571b89b3aa7933837a05daa6.zip | |
Some tweaks to improve the page position after like or boost.
| -rw-r--r-- | html.c | 22 |
1 files changed, 9 insertions, 13 deletions
| @@ -399,7 +399,7 @@ d_char *build_mentions(snac *snac, char *msg) | |||
| 399 | } | 399 | } |
| 400 | 400 | ||
| 401 | 401 | ||
| 402 | d_char *html_entry_controls(snac *snac, d_char *os, char *msg, int num) | 402 | d_char *html_entry_controls(snac *snac, d_char *os, char *msg, const char *md5) |
| 403 | { | 403 | { |
| 404 | char *id = xs_dict_get(msg, "id"); | 404 | char *id = xs_dict_get(msg, "id"); |
| 405 | char *actor = xs_dict_get(msg, "attributedTo"); | 405 | char *actor = xs_dict_get(msg, "attributedTo"); |
| @@ -407,7 +407,6 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, int num) | |||
| 407 | xs *boosts = object_announces(id); | 407 | xs *boosts = object_announces(id); |
| 408 | 408 | ||
| 409 | xs *s = xs_str_new(NULL); | 409 | xs *s = xs_str_new(NULL); |
| 410 | xs *md5 = xs_md5_hex(id, strlen(id)); | ||
| 411 | 410 | ||
| 412 | s = xs_str_cat(s, "<div class=\"snac-controls\">\n"); | 411 | s = xs_str_cat(s, "<div class=\"snac-controls\">\n"); |
| 413 | 412 | ||
| @@ -416,10 +415,10 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, int num) | |||
| 416 | "<form method=\"post\" action=\"%s/admin/action\">\n" | 415 | "<form method=\"post\" action=\"%s/admin/action\">\n" |
| 417 | "<input type=\"hidden\" name=\"id\" value=\"%s\">\n" | 416 | "<input type=\"hidden\" name=\"id\" value=\"%s\">\n" |
| 418 | "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n" | 417 | "<input type=\"hidden\" name=\"actor\" value=\"%s\">\n" |
| 419 | "<input type=\"hidden\" name=\"redir\" value=\"%d_entry\">\n" | 418 | "<input type=\"hidden\" name=\"redir\" value=\"%s_entry\">\n" |
| 420 | "\n", | 419 | "\n", |
| 421 | 420 | ||
| 422 | snac->actor, id, actor, num | 421 | snac->actor, id, actor, md5 |
| 423 | ); | 422 | ); |
| 424 | 423 | ||
| 425 | s = xs_str_cat(s, s1); | 424 | s = xs_str_cat(s, s1); |
| @@ -489,7 +488,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg, int num) | |||
| 489 | } | 488 | } |
| 490 | 489 | ||
| 491 | 490 | ||
| 492 | d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int *num) | 491 | d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, const char *md5) |
| 493 | { | 492 | { |
| 494 | char *id = xs_dict_get(msg, "id"); | 493 | char *id = xs_dict_get(msg, "id"); |
| 495 | char *type = xs_dict_get(msg, "type"); | 494 | char *type = xs_dict_get(msg, "type"); |
| @@ -511,10 +510,8 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int | |||
| 511 | else | 510 | else |
| 512 | s = xs_str_cat(s, "<div>\n"); | 511 | s = xs_str_cat(s, "<div>\n"); |
| 513 | 512 | ||
| 514 | if (level == 0) { | 513 | { |
| 515 | xs *s1 = xs_fmt("<a name=\"%d_entry\"></a>\n", *num); | 514 | xs *s1 = xs_fmt("<a name=\"%s_entry\"></a>\n", md5); |
| 516 | |||
| 517 | *num = *num + 1; | ||
| 518 | 515 | ||
| 519 | s = xs_str_cat(s, s1); | 516 | s = xs_str_cat(s, s1); |
| 520 | } | 517 | } |
| @@ -733,7 +730,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int | |||
| 733 | /** controls **/ | 730 | /** controls **/ |
| 734 | 731 | ||
| 735 | if (!local) | 732 | if (!local) |
| 736 | s = html_entry_controls(snac, s, msg, *num); | 733 | s = html_entry_controls(snac, s, msg, md5); |
| 737 | 734 | ||
| 738 | /** children **/ | 735 | /** children **/ |
| 739 | xs *children = object_children(id); | 736 | xs *children = object_children(id); |
| @@ -759,7 +756,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, int local, int level, int | |||
| 759 | s = xs_str_cat(s, "</details>\n"); | 756 | s = xs_str_cat(s, "</details>\n"); |
| 760 | 757 | ||
| 761 | if (chd != NULL) | 758 | if (chd != NULL) |
| 762 | s = html_entry(snac, s, chd, local, level + 1, num); | 759 | s = html_entry(snac, s, chd, local, level + 1, cmd5); |
| 763 | else | 760 | else |
| 764 | snac_debug(snac, 2, xs_fmt("cannot read from timeline child %s", cmd5)); | 761 | snac_debug(snac, 2, xs_fmt("cannot read from timeline child %s", cmd5)); |
| 765 | 762 | ||
| @@ -795,7 +792,6 @@ d_char *html_timeline(snac *snac, char *list, int local, int skip, int show, int | |||
| 795 | d_char *s = xs_str_new(NULL); | 792 | d_char *s = xs_str_new(NULL); |
| 796 | char *v; | 793 | char *v; |
| 797 | double t = ftime(); | 794 | double t = ftime(); |
| 798 | int num = 0; | ||
| 799 | 795 | ||
| 800 | s = html_user_header(snac, s, local); | 796 | s = html_user_header(snac, s, local); |
| 801 | 797 | ||
| @@ -811,7 +807,7 @@ d_char *html_timeline(snac *snac, char *list, int local, int skip, int show, int | |||
| 811 | if (!valid_status(object_get_by_md5(v, &msg, NULL))) | 807 | if (!valid_status(object_get_by_md5(v, &msg, NULL))) |
| 812 | continue; | 808 | continue; |
| 813 | 809 | ||
| 814 | s = html_entry(snac, s, msg, local, 0, &num); | 810 | s = html_entry(snac, s, msg, local, 0, v); |
| 815 | } | 811 | } |
| 816 | 812 | ||
| 817 | s = xs_str_cat(s, "</div>\n"); | 813 | s = xs_str_cat(s, "</div>\n"); |