mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-09 19:50:26 +03:00
Split html_actor_icon() from html_msg_icon().
This commit is contained in:
parent
9fafa78dc2
commit
2fd5f6fc61
51
html.c
51
html.c
@ -37,17 +37,10 @@ int login(snac *snac, char *headers)
|
||||
}
|
||||
|
||||
|
||||
d_char *html_msg_icon(snac *snac, d_char *os, char *msg)
|
||||
d_char *html_actor_icon(snac *snac, d_char *os, char *actor, char *date, char *url, int priv)
|
||||
{
|
||||
char *actor_id;
|
||||
xs *actor = NULL;
|
||||
|
||||
xs *s = xs_str_new(NULL);
|
||||
|
||||
if ((actor_id = xs_dict_get(msg, "attributedTo")) == NULL)
|
||||
actor_id = xs_dict_get(msg, "actor");
|
||||
|
||||
if (actor_id && valid_status(actor_get(snac, actor_id, &actor))) {
|
||||
xs *name = NULL;
|
||||
xs *avatar = NULL;
|
||||
char *p, *v;
|
||||
@ -97,34 +90,60 @@ d_char *html_msg_icon(snac *snac, d_char *os, char *msg)
|
||||
|
||||
{
|
||||
xs *s1 = xs_fmt("<a href=\"%s\" class=\"p-author h-card snac-author\">%s</a>",
|
||||
actor_id, name);
|
||||
xs_dict_get(actor, "id"), name);
|
||||
s = xs_str_cat(s, s1);
|
||||
}
|
||||
|
||||
if (strcmp(xs_dict_get(msg, "type"), "Note") == 0) {
|
||||
xs *s1 = xs_fmt(" <a href=\"%s\">»</a>", xs_dict_get(msg, "id"));
|
||||
if (!xs_is_null(url)) {
|
||||
xs *s1 = xs_fmt(" <a href=\"%s\">»</a>", url);
|
||||
s = xs_str_cat(s, s1);
|
||||
}
|
||||
|
||||
if (!is_msg_public(snac, msg))
|
||||
if (priv)
|
||||
s = xs_str_cat(s, " <span title=\"private\">🔒</span>");
|
||||
|
||||
if ((v = xs_dict_get(msg, "published")) == NULL) {
|
||||
s = xs_str_cat(s, "<br>\n<time> </time>\n");
|
||||
if (xs_is_null(date)) {
|
||||
s = xs_str_cat(s, "<br>\n \n");
|
||||
}
|
||||
else {
|
||||
xs *sd = xs_crop(xs_dup(v), 0, 10);
|
||||
xs *sd = xs_crop(xs_dup(date), 0, 10);
|
||||
xs *s1 = xs_fmt(
|
||||
"<br>\n<time class=\"dt-published snac-pubdate\">%s</time>\n", sd);
|
||||
|
||||
s = xs_str_cat(s, s1);
|
||||
}
|
||||
}
|
||||
|
||||
return xs_str_cat(os, s);
|
||||
}
|
||||
|
||||
|
||||
d_char *html_msg_icon(snac *snac, d_char *os, char *msg)
|
||||
{
|
||||
char *actor_id;
|
||||
xs *actor = NULL;
|
||||
|
||||
if ((actor_id = xs_dict_get(msg, "attributedTo")) == NULL)
|
||||
actor_id = xs_dict_get(msg, "actor");
|
||||
|
||||
if (actor_id && valid_status(actor_get(snac, actor_id, &actor))) {
|
||||
char *date = NULL;
|
||||
char *url = NULL;
|
||||
int priv = 0;
|
||||
|
||||
if (strcmp(xs_dict_get(msg, "type"), "Note") == 0)
|
||||
url = xs_dict_get(msg, "id");
|
||||
|
||||
priv = !is_msg_public(snac, msg);
|
||||
|
||||
date = xs_dict_get(msg, "published");
|
||||
|
||||
os = html_actor_icon(snac, os, actor, date, url, priv);
|
||||
}
|
||||
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
d_char *html_user_header(snac *snac, d_char *s, int local)
|
||||
/* creates the HTML header */
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user