mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-29 07:53:37 +00:00
Got rid of dead code.
This commit is contained in:
parent
b1a9279f85
commit
9419b80809
1 changed files with 6 additions and 240 deletions
246
html.c
246
html.c
|
@ -80,7 +80,8 @@ xs_str *actor_name(xs_dict *actor)
|
||||||
|
|
||||||
if (n && i) {
|
if (n && i) {
|
||||||
char *u = xs_dict_get(i, "url");
|
char *u = xs_dict_get(i, "url");
|
||||||
xs *img = xs_fmt("<img loading=\"lazy\" src=\"%s\" style=\"height: 1em; vertical-align: middle;\"/>", u);
|
xs *img = xs_fmt("<img loading=\"lazy\" src=\"%s\" "
|
||||||
|
"style=\"height: 1em; vertical-align: middle;\"/>", u);
|
||||||
|
|
||||||
name = xs_replace_i(name, n, img);
|
name = xs_replace_i(name, n, img);
|
||||||
}
|
}
|
||||||
|
@ -499,67 +500,6 @@ static xs_html *html_instance_body(char *tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static xs_str *html_instance_header(xs_str *s, char *tag)
|
|
||||||
/* TO BE REPLACED BY html_instance_body() */
|
|
||||||
{
|
|
||||||
xs_html *head = html_instance_head();
|
|
||||||
|
|
||||||
char *host = xs_dict_get(srv_config, "host");
|
|
||||||
char *sdesc = xs_dict_get(srv_config, "short_description");
|
|
||||||
char *email = xs_dict_get(srv_config, "admin_email");
|
|
||||||
char *acct = xs_dict_get(srv_config, "admin_account");
|
|
||||||
|
|
||||||
{
|
|
||||||
xs *s1 = xs_html_render(head);
|
|
||||||
s = xs_str_cat(s, "<!DOCTYPE html><html>\n", s1);
|
|
||||||
}
|
|
||||||
|
|
||||||
s = xs_str_cat(s, "<body>\n");
|
|
||||||
|
|
||||||
s = xs_str_cat(s, "<div class=\"snac-instance-blurb\">\n");
|
|
||||||
|
|
||||||
{
|
|
||||||
xs *s1 = xs_replace(snac_blurb, "%host%", host);
|
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
|
|
||||||
s = xs_str_cat(s, "<dl>\n");
|
|
||||||
|
|
||||||
if (sdesc && *sdesc) {
|
|
||||||
xs *s1 = xs_fmt("<di><dt>%s</dt><dd>%s</dd></di>\n", L("Site description"), sdesc);
|
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
if (email && *email) {
|
|
||||||
xs *s1 = xs_fmt("<di><dt>%s</dt><dd>"
|
|
||||||
"<a href=\"mailto:%s\">%s</a></dd></di>\n",
|
|
||||||
L("Admin email"), email, email);
|
|
||||||
|
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
if (acct && *acct) {
|
|
||||||
xs *s1 = xs_fmt("<di><dt>%s</dt><dd>"
|
|
||||||
"<a href=\"%s/%s\">@%s@%s</a></dd></di>\n",
|
|
||||||
L("Admin account"), srv_baseurl, acct, acct, host);
|
|
||||||
|
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
|
|
||||||
s = xs_str_cat(s, "</dl>\n");
|
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div>\n");
|
|
||||||
|
|
||||||
{
|
|
||||||
xs *l = tag ? xs_fmt(L("Search results for #%s"), tag) :
|
|
||||||
xs_dup(L("Recent posts by users in this instance"));
|
|
||||||
|
|
||||||
xs *s1 = xs_fmt("<h2 class=\"snac-header\">%s</h2>\n", l);
|
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
xs_html *html_user_head(snac *user)
|
xs_html *html_user_head(snac *user)
|
||||||
{
|
{
|
||||||
xs_html *head = html_base_head();
|
xs_html *head = html_base_head();
|
||||||
|
@ -815,182 +755,6 @@ static xs_html *html_user_body(snac *user, int local)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static xs_str *html_user_header(snac *snac, xs_str *s, int local)
|
|
||||||
/* TO BE REPLACED BY html_user_body() */
|
|
||||||
{
|
|
||||||
xs_html *head = html_user_head(snac);
|
|
||||||
|
|
||||||
{
|
|
||||||
xs *s1 = xs_html_render(head);
|
|
||||||
s = xs_str_cat(s, "<!DOCTYPE html><html>\n", s1);
|
|
||||||
}
|
|
||||||
|
|
||||||
s = xs_str_cat(s, "\n<body>\n");
|
|
||||||
|
|
||||||
/* top nav */
|
|
||||||
xs_html *top_nav = xs_html_tag("nav",
|
|
||||||
xs_html_attr("class", "snac-top-nav"));
|
|
||||||
|
|
||||||
xs *avatar = xs_dup(xs_dict_get(snac->config, "avatar"));
|
|
||||||
|
|
||||||
if (avatar == NULL || *avatar == '\0') {
|
|
||||||
xs_free(avatar);
|
|
||||||
avatar = xs_fmt("data:image/png;base64, %s", default_avatar_base64());
|
|
||||||
}
|
|
||||||
|
|
||||||
xs_html_add(top_nav,
|
|
||||||
xs_html_sctag("img",
|
|
||||||
xs_html_attr("src", avatar),
|
|
||||||
xs_html_attr("class", "snac-avatar"),
|
|
||||||
xs_html_attr("alt", "")));
|
|
||||||
|
|
||||||
{
|
|
||||||
if (local) {
|
|
||||||
xs *rss_url = xs_fmt("%s.rss", snac->actor);
|
|
||||||
xs *admin_url = xs_fmt("%s/admin", snac->actor);
|
|
||||||
|
|
||||||
xs_html_add(top_nav,
|
|
||||||
xs_html_tag("a",
|
|
||||||
xs_html_attr("href", rss_url),
|
|
||||||
xs_html_text(L("RSS"))),
|
|
||||||
xs_html_text(" - "),
|
|
||||||
xs_html_tag("a",
|
|
||||||
xs_html_attr("href", admin_url),
|
|
||||||
xs_html_attr("rel", "nofollow"),
|
|
||||||
xs_html_text(L("private"))));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xs *n_list = notify_list(snac, 1);
|
|
||||||
int n_len = xs_list_len(n_list);
|
|
||||||
xs *n_str = NULL;
|
|
||||||
xs_html *notify_count = NULL;
|
|
||||||
|
|
||||||
/* show the number of new notifications, if there are any */
|
|
||||||
if (n_len) {
|
|
||||||
xs *n_len_str = xs_fmt(" %d ", n_len);
|
|
||||||
notify_count = xs_html_tag("sup",
|
|
||||||
xs_html_attr("style", "background-color: red; color: white;"),
|
|
||||||
xs_html_text(n_len_str));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
notify_count = xs_html_text("");
|
|
||||||
|
|
||||||
xs *admin_url = xs_fmt("%s/admin", snac->actor);
|
|
||||||
xs *notify_url = xs_fmt("%s/notifications", snac->actor);
|
|
||||||
xs *people_url = xs_fmt("%s/people", snac->actor);
|
|
||||||
xs_html_add(top_nav,
|
|
||||||
xs_html_tag("a",
|
|
||||||
xs_html_attr("href", snac->actor),
|
|
||||||
xs_html_text(L("public"))),
|
|
||||||
xs_html_text(" - "),
|
|
||||||
xs_html_tag("a",
|
|
||||||
xs_html_attr("href", admin_url),
|
|
||||||
xs_html_text(L("private"))),
|
|
||||||
xs_html_text(" - "),
|
|
||||||
xs_html_tag("a",
|
|
||||||
xs_html_attr("href", notify_url),
|
|
||||||
xs_html_text(L("notifications"))),
|
|
||||||
notify_count,
|
|
||||||
xs_html_text(" - "),
|
|
||||||
xs_html_tag("a",
|
|
||||||
xs_html_attr("href", people_url),
|
|
||||||
xs_html_text(L("people"))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
xs *s1 = xs_html_render(top_nav);
|
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* user info */
|
|
||||||
{
|
|
||||||
xs_html *top_user = xs_html_tag("div",
|
|
||||||
xs_html_attr("class", "h-card snac-top-user"));
|
|
||||||
|
|
||||||
if (local) {
|
|
||||||
char *header = xs_dict_get(snac->config, "header");
|
|
||||||
if (header && *header) {
|
|
||||||
xs_html_add(top_user,
|
|
||||||
xs_html_tag("div",
|
|
||||||
xs_html_attr("class", "snac-top-user-banner"),
|
|
||||||
xs_html_attr("style", "clear: both"),
|
|
||||||
xs_html_sctag("br", NULL),
|
|
||||||
xs_html_sctag("img",
|
|
||||||
xs_html_attr("src", header))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xs *handle = xs_fmt("@%s@%s",
|
|
||||||
xs_dict_get(snac->config, "uid"),
|
|
||||||
xs_dict_get(srv_config, "host"));
|
|
||||||
|
|
||||||
xs_html_add(top_user,
|
|
||||||
xs_html_tag("p",
|
|
||||||
xs_html_attr("class", "p-name snac-top-user-name"),
|
|
||||||
xs_html_text(xs_dict_get(snac->config, "name"))),
|
|
||||||
xs_html_tag("p",
|
|
||||||
xs_html_attr("class", "snac-top-user-id"),
|
|
||||||
xs_html_text(handle)));
|
|
||||||
|
|
||||||
if (local) {
|
|
||||||
xs *es1 = encode_html(xs_dict_get(snac->config, "bio"));
|
|
||||||
xs *bio1 = not_really_markdown(es1, NULL);
|
|
||||||
xs *tags = xs_list_new();
|
|
||||||
xs *bio2 = process_tags(snac, bio1, &tags);
|
|
||||||
|
|
||||||
xs_html *top_user_bio = xs_html_tag("div",
|
|
||||||
xs_html_attr("class", "p-note snac-top-user-bio"),
|
|
||||||
xs_html_raw(bio2)); /* already sanitized */
|
|
||||||
|
|
||||||
xs_html_add(top_user,
|
|
||||||
top_user_bio);
|
|
||||||
|
|
||||||
xs_dict *metadata = xs_dict_get(snac->config, "metadata");
|
|
||||||
if (xs_type(metadata) == XSTYPE_DICT) {
|
|
||||||
xs_str *k;
|
|
||||||
xs_str *v;
|
|
||||||
|
|
||||||
xs_html *snac_metadata = xs_html_tag("div",
|
|
||||||
xs_html_attr("class", "snac-metadata"));
|
|
||||||
|
|
||||||
while (xs_dict_iter(&metadata, &k, &v)) {
|
|
||||||
xs_html *value;
|
|
||||||
|
|
||||||
if (xs_startswith(v, "https:/" "/"))
|
|
||||||
value = xs_html_tag("a",
|
|
||||||
xs_html_attr("href", v),
|
|
||||||
xs_html_text(v));
|
|
||||||
else
|
|
||||||
value = xs_html_text(v);
|
|
||||||
|
|
||||||
xs_html_add(snac_metadata,
|
|
||||||
xs_html_tag("span",
|
|
||||||
xs_html_attr("class", "snac-property-name"),
|
|
||||||
xs_html_text(k)),
|
|
||||||
xs_html_text(":"),
|
|
||||||
xs_html_sctag("br", NULL),
|
|
||||||
xs_html_tag("span",
|
|
||||||
xs_html_attr("class", "snac-property-value"),
|
|
||||||
value),
|
|
||||||
xs_html_sctag("br", NULL));
|
|
||||||
}
|
|
||||||
|
|
||||||
xs_html_add(top_user,
|
|
||||||
snac_metadata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
|
||||||
xs *s1 = xs_html_render(top_user);
|
|
||||||
s = xs_str_cat(s, s1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
xs_html *html_top_controls(snac *snac)
|
xs_html *html_top_controls(snac *snac)
|
||||||
/* generates the top controls */
|
/* generates the top controls */
|
||||||
{
|
{
|
||||||
|
@ -1196,7 +960,8 @@ xs_html *html_top_controls(snac *snac)
|
||||||
xs_html_attr(xs_type(a_private) == XSTYPE_TRUE ? "checked" : "", NULL)),
|
xs_html_attr(xs_type(a_private) == XSTYPE_TRUE ? "checked" : "", NULL)),
|
||||||
xs_html_tag("label",
|
xs_html_tag("label",
|
||||||
xs_html_attr("for", "private"),
|
xs_html_attr("for", "private"),
|
||||||
xs_html_text(L("This account is private (posts are not shown through the web)")))),
|
xs_html_text(L("This account is private "
|
||||||
|
"(posts are not shown through the web)")))),
|
||||||
xs_html_tag("p",
|
xs_html_tag("p",
|
||||||
xs_html_text(L("Profile metadata (key=value pairs in each line):")),
|
xs_html_text(L("Profile metadata (key=value pairs in each line):")),
|
||||||
xs_html_sctag("br", NULL),
|
xs_html_sctag("br", NULL),
|
||||||
|
@ -1204,7 +969,8 @@ xs_html *html_top_controls(snac *snac)
|
||||||
xs_html_attr("name", "metadata"),
|
xs_html_attr("name", "metadata"),
|
||||||
xs_html_attr("cols", "40"),
|
xs_html_attr("cols", "40"),
|
||||||
xs_html_attr("rows", "4"),
|
xs_html_attr("rows", "4"),
|
||||||
xs_html_attr("placeholder", "Blog=https:/" "/example.com/my-blog\nGPG Key=1FA54\n..."),
|
xs_html_attr("placeholder", "Blog=https:/"
|
||||||
|
"/example.com/my-blog\nGPG Key=1FA54\n..."),
|
||||||
xs_html_text(metadata))),
|
xs_html_text(metadata))),
|
||||||
|
|
||||||
xs_html_tag("p",
|
xs_html_tag("p",
|
||||||
|
|
Loading…
Reference in a new issue