mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-15 01:55:03 +00:00
More xs_html refactoring.
This commit is contained in:
parent
645a27d4ee
commit
c963a29923
1 changed files with 28 additions and 25 deletions
53
html.c
53
html.c
|
@ -745,29 +745,33 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local)
|
||||||
|
|
||||||
/* user info */
|
/* user info */
|
||||||
{
|
{
|
||||||
s = xs_str_cat(s, "<div class=\"h-card snac-top-user\">\n");
|
xs_html *top_user = xs_html_tag("div",
|
||||||
|
xs_html_attr("class", "h-card snac-top-user"));
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
const char *header = xs_dict_get(snac->config, "header");
|
char *header = xs_dict_get(snac->config, "header");
|
||||||
if (header && *header) {
|
if (header && *header) {
|
||||||
xs *h = encode_html(header);
|
xs_html_add(top_user,
|
||||||
xs *s1 = xs_fmt("<div class=\"snac-top-user-banner\" style=\"clear: both\">"
|
xs_html_tag("div",
|
||||||
"<br><img src=\"%s\"/></div>\n", h);
|
xs_html_attr("class", "snac-top-user-banner"),
|
||||||
s = xs_str_cat(s, s1);
|
xs_html_attr("style", "clear: both"),
|
||||||
|
xs_html_sctag("br", NULL),
|
||||||
|
xs_html_sctag("img",
|
||||||
|
xs_html_attr("src", header))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *_tmpl =
|
xs *handle = xs_fmt("@%s@%s",
|
||||||
"<p class=\"p-name snac-top-user-name\">%s</p>\n"
|
xs_dict_get(snac->config, "uid"),
|
||||||
"<p class=\"snac-top-user-id\">@%s@%s</p>\n";
|
xs_dict_get(srv_config, "host"));
|
||||||
|
|
||||||
xs *es1 = encode_html(xs_dict_get(snac->config, "name"));
|
xs_html_add(top_user,
|
||||||
xs *es2 = encode_html(xs_dict_get(snac->config, "uid"));
|
xs_html_tag("p",
|
||||||
xs *es3 = encode_html(xs_dict_get(srv_config, "host"));
|
xs_html_attr("class", "p-name snac-top-user-name"),
|
||||||
|
xs_html_text(xs_dict_get(snac->config, "name"))),
|
||||||
xs *s1 = xs_fmt(_tmpl, es1, es2, es3);
|
xs_html_tag("p",
|
||||||
|
xs_html_attr("class", "snac-top-user-id"),
|
||||||
s = xs_str_cat(s, s1);
|
xs_html_text(handle)));
|
||||||
|
|
||||||
if (local) {
|
if (local) {
|
||||||
xs *es1 = encode_html(xs_dict_get(snac->config, "bio"));
|
xs *es1 = encode_html(xs_dict_get(snac->config, "bio"));
|
||||||
|
@ -779,10 +783,8 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local)
|
||||||
xs_html_attr("class", "p-note snac-top-user-bio"),
|
xs_html_attr("class", "p-note snac-top-user-bio"),
|
||||||
xs_html_raw(bio2)); /* already sanitized */
|
xs_html_raw(bio2)); /* already sanitized */
|
||||||
|
|
||||||
{
|
xs_html_add(top_user,
|
||||||
xs *s1 = xs_html_render(top_user_bio);
|
top_user_bio);
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
|
|
||||||
xs_dict *metadata = xs_dict_get(snac->config, "metadata");
|
xs_dict *metadata = xs_dict_get(snac->config, "metadata");
|
||||||
if (xs_type(metadata) == XSTYPE_DICT) {
|
if (xs_type(metadata) == XSTYPE_DICT) {
|
||||||
|
@ -814,14 +816,15 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local)
|
||||||
xs_html_sctag("br", NULL));
|
xs_html_sctag("br", NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
xs_html_add(top_user,
|
||||||
xs *s1 = xs_html_render(snac_metadata);
|
snac_metadata);
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div>\n");
|
{
|
||||||
|
xs *s1 = xs_html_render(top_user);
|
||||||
|
s = xs_str_cat(s, s1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
Loading…
Reference in a new issue