Added the score for local posts.

This commit is contained in:
default 2022-09-28 17:39:32 +02:00
parent e7e89d2d57
commit 484a7f1fd8
2 changed files with 33 additions and 1 deletions

20
doc/style.css Normal file
View file

@ -0,0 +1,20 @@
body { max-width: 48em; margin: auto; line-height: 1.5; padding: 0.8em }
img { max-width: 100% }
.snac-origin { font-size: 85% }
.snac-score { float: right; font-size: 85% }
.snac-top-user { text-align: center; padding-bottom: 2em }
.snac-top-user-name { font-size: 200% }
.snac-top-user-id { font-size: 150% }
.snac-avatar { float: left; height: 2.5em; padding: 0.25em }
.snac-author { font-size: 90% }
.snac-pubdate { color: #a0a0a0; font-size: 90% }
.snac-top-controls { padding-bottom: 1.5em }
.snac-post { border-top: 1px solid #a0a0a0; }
.snac-children { padding-left: 2em; border-left: 1px solid #a0a0a0; }
.snac-textarea { font-family: inherit; width: 95% }
.snac-history { border: 1px solid #606060; border-radius: 3px; margin: 2.5em 0; padding: 0 2em }
.snac-btn-mute { float: right; margin-left: 0.5em }
.snac-btn-follow { float: right; margin-left: 0.5em }
.snac-btn-unfollow { float: right; margin-left: 0.5em }
.snac-btn-delete { float: right; margin-left: 0.5em }
.snac-footer { margin-top: 2em; font-size: 75% }

14
html.c
View file

@ -243,7 +243,7 @@ d_char *html_user_header(snac *snac, d_char *s, int local)
s = xs_str_cat(s, "</head>\n<body>\n"); s = xs_str_cat(s, "</head>\n<body>\n");
/* top nav */ /* top nav */
s = xs_str_cat(s, "<nav style=\"snac-top-nav\">"); s = xs_str_cat(s, "<nav class=\"snac-top-nav\">");
{ {
xs *s1; xs *s1;
@ -390,6 +390,18 @@ d_char *html_entry(snac *snac, d_char *s, char *msg, xs_set *seen, int level)
if (!valid_status(actor_get(snac, actor, &actor_o))) if (!valid_status(actor_get(snac, actor, &actor_o)))
return s; return s;
/* if this is our post, add the score */
if (xs_startswith(id, snac->actor)) {
int likes = xs_list_len(xs_dict_get(meta, "liked_by"));
int boosts = xs_list_len(xs_dict_get(meta, "announced_by"));
xs *s1 = xs_fmt(
"<div class=\"snac-score\">%d &#9733; %d &#8634;</div>\n",
likes, boosts);
s = xs_str_cat(s, s1);
}
if (level == 0) { if (level == 0) {
char *referrer; char *referrer;