mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 21:35:04 +00:00
More HTML work.
This commit is contained in:
parent
8be7c4927f
commit
86c27db435
1 changed files with 60 additions and 0 deletions
60
html.c
60
html.c
|
@ -375,6 +375,7 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg)
|
||||||
{
|
{
|
||||||
char *id = xs_dict_get(msg, "id");
|
char *id = xs_dict_get(msg, "id");
|
||||||
char *actor = xs_dict_get(msg, "attributedTo");
|
char *actor = xs_dict_get(msg, "attributedTo");
|
||||||
|
char *meta = xs_dict_get(msg, "_snac");
|
||||||
|
|
||||||
xs *s = xs_str_new(NULL);
|
xs *s = xs_str_new(NULL);
|
||||||
xs *md5 = xs_md5_hex(id, strlen(id));
|
xs *md5 = xs_md5_hex(id, strlen(id));
|
||||||
|
@ -404,6 +405,63 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg)
|
||||||
|
|
||||||
if (strcmp(actor, snac->actor) != 0) {
|
if (strcmp(actor, snac->actor) != 0) {
|
||||||
/* controls for other actors than this one */
|
/* controls for other actors than this one */
|
||||||
|
char *l;
|
||||||
|
|
||||||
|
l = xs_dict_get(meta, "liked_by");
|
||||||
|
if (xs_list_in(l, snac->actor) == -1) {
|
||||||
|
/* not already liked; add button */
|
||||||
|
xs *s1 = xs_fmt(
|
||||||
|
"<input type=\"submit\" name=\"action\" "
|
||||||
|
"class=\"snac-btn-like\" value=\"%s\">\n",
|
||||||
|
L("Like")
|
||||||
|
);
|
||||||
|
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
l = xs_dict_get(meta, "announced_by");
|
||||||
|
if (xs_list_in(l, snac->actor) == -1) {
|
||||||
|
/* not already boosted; add button */
|
||||||
|
xs *s1 = xs_fmt(
|
||||||
|
"<input type=\"submit\" name=\"action\" "
|
||||||
|
"class=\"snac-btn-boost\" value=\"%s\">\n",
|
||||||
|
L("Boost")
|
||||||
|
);
|
||||||
|
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (following_check(snac, actor)) {
|
||||||
|
xs *s1 = xs_fmt(
|
||||||
|
"<input type=\"submit\" name=\"action\" "
|
||||||
|
"class=\"snac-btn-unfollow\" value=\"%s\">\n",
|
||||||
|
L("Unfollow")
|
||||||
|
);
|
||||||
|
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
xs *s1 = xs_fmt(
|
||||||
|
"<input type=\"submit\" name=\"action\" "
|
||||||
|
"class=\"snac-btn-follow\" value=\"%s\">\n"
|
||||||
|
"<input type=\"submit\" name=\"action\" "
|
||||||
|
"class=\"snac-btn-mute\" value=\"%s\">\n",
|
||||||
|
L("Follow"),
|
||||||
|
L("MUTE")
|
||||||
|
);
|
||||||
|
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
xs *s1 = xs_fmt(
|
||||||
|
"<input type=\"submit\" name=\"action\" "
|
||||||
|
"class=\"snac-btn-delete\" value=\"%s\">\n",
|
||||||
|
L("Delete")
|
||||||
|
);
|
||||||
|
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</form>\n");
|
s = xs_str_cat(s, "</form>\n");
|
||||||
|
@ -430,6 +488,8 @@ d_char *html_entry_controls(snac *snac, d_char *os, char *msg)
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s = xs_str_cat(s, "</div>\n");
|
||||||
|
|
||||||
return xs_str_cat(os, s);
|
return xs_str_cat(os, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue