summaryrefslogtreecommitdiff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/html.c b/html.c
index 599c6d8..bdf0bbe 100644
--- a/html.c
+++ b/html.c
@@ -375,6 +375,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg)
375{ 375{
376 char *id = xs_dict_get(msg, "id"); 376 char *id = xs_dict_get(msg, "id");
377 char *actor = xs_dict_get(msg, "attributedTo"); 377 char *actor = xs_dict_get(msg, "attributedTo");
378 char *meta = xs_dict_get(msg, "_snac");
378 379
379 xs *s = xs_str_new(NULL); 380 xs *s = xs_str_new(NULL);
380 xs *md5 = xs_md5_hex(id, strlen(id)); 381 xs *md5 = xs_md5_hex(id, strlen(id));
@@ -404,6 +405,63 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg)
404 405
405 if (strcmp(actor, snac->actor) != 0) { 406 if (strcmp(actor, snac->actor) != 0) {
406 /* controls for other actors than this one */ 407 /* controls for other actors than this one */
408 char *l;
409
410 l = xs_dict_get(meta, "liked_by");
411 if (xs_list_in(l, snac->actor) == -1) {
412 /* not already liked; add button */
413 xs *s1 = xs_fmt(
414 "<input type=\"submit\" name=\"action\" "
415 "class=\"snac-btn-like\" value=\"%s\">\n",
416 L("Like")
417 );
418
419 s = xs_str_cat(s, s1);
420 }
421
422 l = xs_dict_get(meta, "announced_by");
423 if (xs_list_in(l, snac->actor) == -1) {
424 /* not already boosted; add button */
425 xs *s1 = xs_fmt(
426 "<input type=\"submit\" name=\"action\" "
427 "class=\"snac-btn-boost\" value=\"%s\">\n",
428 L("Boost")
429 );
430
431 s = xs_str_cat(s, s1);
432 }
433
434 if (following_check(snac, actor)) {
435 xs *s1 = xs_fmt(
436 "<input type=\"submit\" name=\"action\" "
437 "class=\"snac-btn-unfollow\" value=\"%s\">\n",
438 L("Unfollow")
439 );
440
441 s = xs_str_cat(s, s1);
442 }
443 else {
444 xs *s1 = xs_fmt(
445 "<input type=\"submit\" name=\"action\" "
446 "class=\"snac-btn-follow\" value=\"%s\">\n"
447 "<input type=\"submit\" name=\"action\" "
448 "class=\"snac-btn-mute\" value=\"%s\">\n",
449 L("Follow"),
450 L("MUTE")
451 );
452
453 s = xs_str_cat(s, s1);
454 }
455 }
456
457 {
458 xs *s1 = xs_fmt(
459 "<input type=\"submit\" name=\"action\" "
460 "class=\"snac-btn-delete\" value=\"%s\">\n",
461 L("Delete")
462 );
463
464 s = xs_str_cat(s, s1);
407 } 465 }
408 466
409 s = xs_str_cat(s, "</form>\n"); 467 s = xs_str_cat(s, "</form>\n");
@@ -430,6 +488,8 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg)
430 s = xs_str_cat(s, s1); 488 s = xs_str_cat(s, s1);
431 } 489 }
432 490
491 s = xs_str_cat(s, "</div>\n");
492
433 return xs_str_cat(os, s); 493 return xs_str_cat(os, s);
434} 494}
435 495