diff options
| author | 2022-10-01 19:10:12 +0200 | |
|---|---|---|
| committer | 2022-10-01 19:10:12 +0200 | |
| commit | 450c0e7aad09491b2abd177e695d3080c352af5e (patch) | |
| tree | 9d5c64096c76f40b2bf090148515c430a3e42496 /html.c | |
| parent | Show a link in the snac-origin in level 0 entries. (diff) | |
| download | snac2-450c0e7aad09491b2abd177e695d3080c352af5e.tar.gz snac2-450c0e7aad09491b2abd177e695d3080c352af5e.tar.xz snac2-450c0e7aad09491b2abd177e695d3080c352af5e.zip | |
More snac-origin work.
Diffstat (limited to 'html.c')
| -rw-r--r-- | html.c | 35 |
1 files changed, 29 insertions, 6 deletions
| @@ -525,16 +525,15 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i | |||
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | if (level == 0) { | 527 | if (level == 0) { |
| 528 | char *referrer; | 528 | char *p; |
| 529 | char *parent; | ||
| 530 | 529 | ||
| 531 | s = xs_str_cat(s, "<div class=\"snac-post\">\n"); | 530 | s = xs_str_cat(s, "<div class=\"snac-post\">\n"); |
| 532 | 531 | ||
| 533 | /* print the origin of the post, if any */ | 532 | /* print the origin of the post, if any */ |
| 534 | if (!xs_is_null(referrer = xs_dict_get(meta, "referrer"))) { | 533 | if (!xs_is_null(p = xs_dict_get(meta, "referrer"))) { |
| 535 | xs *actor_r = NULL; | 534 | xs *actor_r = NULL; |
| 536 | 535 | ||
| 537 | if (valid_status(actor_get(snac, referrer, &actor_r))) { | 536 | if (valid_status(actor_get(snac, p, &actor_r))) { |
| 538 | char *name; | 537 | char *name; |
| 539 | 538 | ||
| 540 | if ((name = xs_dict_get(actor_r, "name")) == NULL) | 539 | if ((name = xs_dict_get(actor_r, "name")) == NULL) |
| @@ -552,12 +551,36 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i | |||
| 552 | } | 551 | } |
| 553 | } | 552 | } |
| 554 | else | 553 | else |
| 555 | if (!xs_is_null((parent = xs_dict_get(meta, "parent")))) { | 554 | if (!xs_is_null((p = xs_dict_get(meta, "parent"))) && *p) { |
| 556 | /* this may happen if any of the autor or the parent aren't here */ | 555 | /* this may happen if any of the autor or the parent aren't here */ |
| 557 | xs *s1 = xs_fmt( | 556 | xs *s1 = xs_fmt( |
| 558 | "<div class=\"snac-origin\">%s " | 557 | "<div class=\"snac-origin\">%s " |
| 559 | "<a href=\"%s\">»</a></div>\n", | 558 | "<a href=\"%s\">»</a></div>\n", |
| 560 | L("in reply to"), parent | 559 | L("in reply to"), p |
| 560 | ); | ||
| 561 | |||
| 562 | s = xs_str_cat(s, s1); | ||
| 563 | } | ||
| 564 | else | ||
| 565 | if (!xs_is_null((p = xs_dict_get(meta, "announced_by"))) && | ||
| 566 | xs_list_in(p, snac->actor) != -1) { | ||
| 567 | /* we boosted this */ | ||
| 568 | xs *s1 = xs_fmt( | ||
| 569 | "<div class=\"snac-origin\">" | ||
| 570 | "<a href=\"%s\">%s</a> %s</a></div>", | ||
| 571 | snac->actor, xs_dict_get(snac->config, "name"), L("liked") | ||
| 572 | ); | ||
| 573 | |||
| 574 | s = xs_str_cat(s, s1); | ||
| 575 | } | ||
| 576 | else | ||
| 577 | if (!xs_is_null((p = xs_dict_get(meta, "liked_by"))) && | ||
| 578 | xs_list_in(p, snac->actor) != -1) { | ||
| 579 | /* we liked this */ | ||
| 580 | xs *s1 = xs_fmt( | ||
| 581 | "<div class=\"snac-origin\">" | ||
| 582 | "<a href=\"%s\">%s</a> %s</a></div>", | ||
| 583 | snac->actor, xs_dict_get(snac->config, "name"), L("liked") | ||
| 561 | ); | 584 | ); |
| 562 | 585 | ||
| 563 | s = xs_str_cat(s, s1); | 586 | s = xs_str_cat(s, s1); |