diff options
| author | 2023-11-28 10:13:27 +0100 | |
|---|---|---|
| committer | 2023-11-28 10:13:27 +0100 | |
| commit | 179a7ae014bae0c995f34b446d3868dd42a2207c (patch) | |
| tree | 2e0a388d52a99e6691f0c909952f96dd0ea8b336 /html.c | |
| parent | Refactored to xs_html the poll part of html_entry(). (diff) | |
| download | snac2-179a7ae014bae0c995f34b446d3868dd42a2207c.tar.gz snac2-179a7ae014bae0c995f34b446d3868dd42a2207c.tar.xz snac2-179a7ae014bae0c995f34b446d3868dd42a2207c.zip | |
Converted top_nav to xs_html.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 83 |
1 files changed, 53 insertions, 30 deletions
| @@ -668,7 +668,8 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local) | |||
| 668 | s = xs_str_cat(s, "\n<body>\n"); | 668 | s = xs_str_cat(s, "\n<body>\n"); |
| 669 | 669 | ||
| 670 | /* top nav */ | 670 | /* top nav */ |
| 671 | s = xs_str_cat(s, "<nav class=\"snac-top-nav\">"); | 671 | xs_html *top_nav = xs_html_tag("nav", |
| 672 | xs_html_attr("class", "snac-top-nav")); | ||
| 672 | 673 | ||
| 673 | xs *avatar = xs_dup(xs_dict_get(snac->config, "avatar")); | 674 | xs *avatar = xs_dup(xs_dict_get(snac->config, "avatar")); |
| 674 | 675 | ||
| @@ -677,46 +678,68 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local) | |||
| 677 | avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64()); | 678 | avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64()); |
| 678 | } | 679 | } |
| 679 | 680 | ||
| 680 | { | 681 | xs_html_add(top_nav, |
| 681 | xs *s1; | 682 | xs_html_sctag("img", |
| 682 | 683 | xs_html_attr("src", avatar), | |
| 683 | s1 = xs_fmt("<img src=\"%s\" class=\"snac-avatar\" alt=\"\"/> ", avatar); | 684 | xs_html_attr("class", "snac-avatar"), |
| 684 | 685 | xs_html_attr("alt", ""))); | |
| 685 | s = xs_str_cat(s, s1); | ||
| 686 | } | ||
| 687 | 686 | ||
| 688 | { | 687 | { |
| 689 | xs *s1; | 688 | if (local) { |
| 690 | 689 | xs *rss_url = xs_fmt("%s.rss", snac->actor); | |
| 691 | if (local) | 690 | xs *admin_url = xs_fmt("%s/admin", snac->actor); |
| 692 | s1 = xs_fmt( | 691 | |
| 693 | "<a href=\"%s.rss\">%s</a> - " | 692 | xs_html_add(top_nav, |
| 694 | "<a href=\"%s/admin\" rel=\"nofollow\">%s</a></nav>\n", | 693 | xs_html_tag("a", |
| 695 | snac->actor, L("RSS"), | 694 | xs_html_attr("href", rss_url), |
| 696 | snac->actor, L("private")); | 695 | xs_html_text(L("RSS"))), |
| 696 | xs_html_text(" - "), | ||
| 697 | xs_html_tag("a", | ||
| 698 | xs_html_attr("href", admin_url), | ||
| 699 | xs_html_attr("rel", "nofollow"), | ||
| 700 | xs_html_text(L("private")))); | ||
| 701 | } | ||
| 697 | else { | 702 | else { |
| 698 | xs *n_list = notify_list(snac, 1); | 703 | xs *n_list = notify_list(snac, 1); |
| 699 | int n_len = xs_list_len(n_list); | 704 | int n_len = xs_list_len(n_list); |
| 700 | xs *n_str = NULL; | 705 | xs *n_str = NULL; |
| 706 | xs_html *notify_count = NULL; | ||
| 701 | 707 | ||
| 702 | /* show the number of new notifications, if there are any */ | 708 | /* show the number of new notifications, if there are any */ |
| 703 | if (n_len) | 709 | if (n_len) { |
| 704 | n_str = xs_fmt("<sup style=\"background-color: red; " | 710 | xs *n_len_str = xs_fmt(" %d ", n_len); |
| 705 | "color: white;\"> %d </sup> ", n_len); | 711 | notify_count = xs_html_tag("sup", |
| 712 | xs_html_attr("style", "background-color: red; color: white;"), | ||
| 713 | xs_html_text(n_len_str)); | ||
| 714 | } | ||
| 706 | else | 715 | else |
| 707 | n_str = xs_str_new(""); | 716 | notify_count = xs_html_text(""); |
| 708 | 717 | ||
| 709 | s1 = xs_fmt( | 718 | xs *admin_url = xs_fmt("%s/admin", snac->actor); |
| 710 | "<a href=\"%s\">%s</a> - " | 719 | xs *notify_url = xs_fmt("%s/notifications", snac->actor); |
| 711 | "<a href=\"%s/admin\">%s</a> - " | 720 | xs *people_url = xs_fmt("%s/people", snac->actor); |
| 712 | "<a href=\"%s/notifications\">%s</a>%s - " | 721 | xs_html_add(top_nav, |
| 713 | "<a href=\"%s/people\">%s</a></nav>\n", | 722 | xs_html_tag("a", |
| 714 | snac->actor, L("public"), | 723 | xs_html_attr("href", snac->actor), |
| 715 | snac->actor, L("private"), | 724 | xs_html_text(L("public"))), |
| 716 | snac->actor, L("notifications"), n_str, | 725 | xs_html_text(" - "), |
| 717 | snac->actor, L("people")); | 726 | xs_html_tag("a", |
| 727 | xs_html_attr("href", admin_url), | ||
| 728 | xs_html_text(L("private"))), | ||
| 729 | xs_html_text(" - "), | ||
| 730 | xs_html_tag("a", | ||
| 731 | xs_html_attr("href", notify_url), | ||
| 732 | xs_html_text(L("notifications"))), | ||
| 733 | notify_count, | ||
| 734 | xs_html_text(" - "), | ||
| 735 | xs_html_tag("a", | ||
| 736 | xs_html_attr("href", people_url), | ||
| 737 | xs_html_text(L("people")))); | ||
| 718 | } | 738 | } |
| 739 | } | ||
| 719 | 740 | ||
| 741 | { | ||
| 742 | xs *s1 = xs_html_render(top_nav); | ||
| 720 | s = xs_str_cat(s, s1); | 743 | s = xs_str_cat(s, s1); |
| 721 | } | 744 | } |
| 722 | 745 | ||