diff options
| author | 2022-11-02 10:49:16 +0100 | |
|---|---|---|
| committer | 2022-11-02 10:49:16 +0100 | |
| commit | 773be130ed4557c95fef2d54799a170ffea9e0de (patch) | |
| tree | 4144e8c5b13108efc851dc5465718bf168074982 /html.c | |
| parent | People page started. (diff) | |
| download | penes-snac2-773be130ed4557c95fef2d54799a170ffea9e0de.tar.gz penes-snac2-773be130ed4557c95fef2d54799a170ffea9e0de.tar.xz penes-snac2-773be130ed4557c95fef2d54799a170ffea9e0de.zip | |
More work in the people page.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 42 |
1 files changed, 26 insertions, 16 deletions
| @@ -820,28 +820,19 @@ d_char *html_timeline(snac *snac, char *list, int local) | |||
| 820 | } | 820 | } |
| 821 | 821 | ||
| 822 | 822 | ||
| 823 | d_char *html_people(snac *snac) | 823 | d_char *html_people_list(snac *snac, d_char *os, d_char *list, const char *header) |
| 824 | { | 824 | { |
| 825 | d_char *s = xs_str_new(NULL); | 825 | xs *s = xs_str_new(NULL); |
| 826 | xs *wers = NULL; | 826 | xs *h = xs_fmt("<h2>%s</h2>\n", header); |
| 827 | xs *wing = NULL; | ||
| 828 | char *p, *v; | 827 | char *p, *v; |
| 829 | 828 | ||
| 830 | s = html_user_header(snac, s, 0); | 829 | s = xs_str_cat(s, h); |
| 831 | |||
| 832 | s = xs_str_cat(s, "<h2>"); | ||
| 833 | s = xs_str_cat(s, L("People you follow")); | ||
| 834 | s = xs_str_cat(s, "</h2>\n"); | ||
| 835 | 830 | ||
| 836 | s = xs_str_cat(s, "<h2>"); | 831 | p = list; |
| 837 | s = xs_str_cat(s, L("People that follows you")); | ||
| 838 | s = xs_str_cat(s, "</h2>\n"); | ||
| 839 | |||
| 840 | p = wers = follower_list(snac); | ||
| 841 | while (xs_list_iter(&p, &v)) { | 832 | while (xs_list_iter(&p, &v)) { |
| 842 | char *actor_id = xs_dict_get(v, "actor"); | 833 | char *actor_id = xs_dict_get(v, "actor"); |
| 843 | xs *md5 = xs_md5_hex(actor_id, strlen(actor_id)); | 834 | xs *md5 = xs_md5_hex(actor_id, strlen(actor_id)); |
| 844 | xs *actor; | 835 | xs *actor = NULL; |
| 845 | 836 | ||
| 846 | if (valid_status(actor_get(snac, actor_id, &actor))) { | 837 | if (valid_status(actor_get(snac, actor_id, &actor))) { |
| 847 | s = xs_str_cat(s, "<div class=\"snac-post\">\n"); | 838 | s = xs_str_cat(s, "<div class=\"snac-post\">\n"); |
| @@ -888,7 +879,10 @@ d_char *html_people(snac *snac) | |||
| 888 | ); | 879 | ); |
| 889 | s = xs_str_cat(s, s1); | 880 | s = xs_str_cat(s, s1); |
| 890 | 881 | ||
| 891 | s = html_button(s, "unfollow", L("Unfollow")); | 882 | if (following_check(snac, actor_id)) |
| 883 | s = html_button(s, "unfollow", L("Unfollow")); | ||
| 884 | else | ||
| 885 | s = html_button(s, "follow", L("Follow")); | ||
| 892 | 886 | ||
| 893 | if (is_muted(snac, actor_id)) | 887 | if (is_muted(snac, actor_id)) |
| 894 | s = html_button(s, "unmute", L("Unmute")); | 888 | s = html_button(s, "unmute", L("Unmute")); |
| @@ -922,6 +916,22 @@ d_char *html_people(snac *snac) | |||
| 922 | } | 916 | } |
| 923 | } | 917 | } |
| 924 | 918 | ||
| 919 | return xs_str_cat(os, s); | ||
| 920 | } | ||
| 921 | |||
| 922 | |||
| 923 | d_char *html_people(snac *snac) | ||
| 924 | { | ||
| 925 | d_char *s = xs_str_new(NULL); | ||
| 926 | xs *wing = following_list(snac); | ||
| 927 | xs *wers = follower_list(snac); | ||
| 928 | |||
| 929 | s = html_user_header(snac, s, 0); | ||
| 930 | |||
| 931 | s = html_people_list(snac, s, wing, L("People you follow")); | ||
| 932 | |||
| 933 | s = html_people_list(snac, s, wers, L("People that follows you")); | ||
| 934 | |||
| 925 | s = html_user_footer(snac, s); | 935 | s = html_user_footer(snac, s); |
| 926 | 936 | ||
| 927 | s = xs_str_cat(s, "</body>\n</html>\n"); | 937 | s = xs_str_cat(s, "</body>\n</html>\n"); |