diff options
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 45 |
1 files changed, 43 insertions, 2 deletions
| @@ -92,6 +92,7 @@ xs_str *replace_shortnames(xs_str *s, const xs_list *tag, int ems, const char *p | |||
| 92 | xs_html *img = xs_html_sctag("img", | 92 | xs_html *img = xs_html_sctag("img", |
| 93 | xs_html_attr("loading", "lazy"), | 93 | xs_html_attr("loading", "lazy"), |
| 94 | xs_html_attr("src", url), | 94 | xs_html_attr("src", url), |
| 95 | xs_html_attr("alt", n), | ||
| 95 | xs_html_attr("style", style)); | 96 | xs_html_attr("style", style)); |
| 96 | 97 | ||
| 97 | xs *s1 = xs_html_render(img); | 98 | xs *s1 = xs_html_render(img); |
| @@ -2584,6 +2585,12 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2584 | xs_html_add(entry, | 2585 | xs_html_add(entry, |
| 2585 | ch_details); | 2586 | ch_details); |
| 2586 | 2587 | ||
| 2588 | xs_html *fch_container = xs_html_tag("div", | ||
| 2589 | xs_html_attr("class", "snac-thread-cont")); | ||
| 2590 | |||
| 2591 | xs_html_add(ch_details, | ||
| 2592 | fch_container); | ||
| 2593 | |||
| 2587 | xs_html *ch_container = xs_html_tag("div", | 2594 | xs_html *ch_container = xs_html_tag("div", |
| 2588 | xs_html_attr("class", level < 4 ? "snac-children" : "snac-children-too-deep")); | 2595 | xs_html_attr("class", level < 4 ? "snac-children" : "snac-children-too-deep")); |
| 2589 | 2596 | ||
| @@ -2598,12 +2605,42 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2598 | xs_html_text(L("Older..."))))); | 2605 | xs_html_text(L("Older..."))))); |
| 2599 | } | 2606 | } |
| 2600 | 2607 | ||
| 2601 | xs_list *p = children; | 2608 | int ctxt = 0; |
| 2602 | const char *cmd5; | 2609 | const char *cmd5; |
| 2603 | int cnt = 0; | 2610 | int cnt = 0; |
| 2604 | int o_cnt = 0; | 2611 | int o_cnt = 0; |
| 2612 | int f_cnt = 0; | ||
| 2613 | |||
| 2614 | /* get the first child */ | ||
| 2615 | xs_list_next(children, &cmd5, &ctxt); | ||
| 2616 | xs *f_chd = NULL; | ||
| 2617 | |||
| 2618 | if (user) | ||
| 2619 | timeline_get_by_md5(user, cmd5, &f_chd); | ||
| 2620 | else | ||
| 2621 | object_get_by_md5(cmd5, &f_chd); | ||
| 2622 | |||
| 2623 | if (f_chd != NULL && xs_is_null(xs_dict_get(f_chd, "name"))) { | ||
| 2624 | const char *p_author = get_atto(msg); | ||
| 2625 | const char *author = get_atto(f_chd); | ||
| 2626 | |||
| 2627 | /* is the first child from the same author? */ | ||
| 2628 | if (xs_is_string(p_author) && xs_is_string(author) && strcmp(p_author, author) == 0) { | ||
| 2629 | /* then, don't add it to the children container, | ||
| 2630 | so that it appears unindented just before the parent | ||
| 2631 | like a fucking Twitter-like thread */ | ||
| 2632 | xs_html_add(fch_container, | ||
| 2633 | html_entry(user, f_chd, read_only, level + 1, cmd5, hide_children)); | ||
| 2634 | |||
| 2635 | cnt++; | ||
| 2636 | f_cnt++; | ||
| 2637 | left--; | ||
| 2638 | } | ||
| 2639 | else | ||
| 2640 | ctxt = 0; /* restart from the beginning */ | ||
| 2641 | } | ||
| 2605 | 2642 | ||
| 2606 | while (xs_list_iter(&p, &cmd5)) { | 2643 | while (xs_list_next(children, &cmd5, &ctxt)) { |
| 2607 | xs *chd = NULL; | 2644 | xs *chd = NULL; |
| 2608 | 2645 | ||
| 2609 | if (user) | 2646 | if (user) |
| @@ -2645,6 +2682,10 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2645 | if (o_cnt == 0 && ch_older) | 2682 | if (o_cnt == 0 && ch_older) |
| 2646 | xs_html_add(ch_older, | 2683 | xs_html_add(ch_older, |
| 2647 | xs_html_attr("style", "display: none")); | 2684 | xs_html_attr("style", "display: none")); |
| 2685 | |||
| 2686 | if (f_cnt == 0) | ||
| 2687 | xs_html_add(fch_container, | ||
| 2688 | xs_html_attr("style", "display: none")); | ||
| 2648 | } | 2689 | } |
| 2649 | } | 2690 | } |
| 2650 | 2691 | ||