From b127c92b8f994471019f72f279c568513c431202 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Sun, 27 Feb 2022 21:03:43 +0000 Subject: [PATCH] Show numbers FossilOrigin-Name: 33b2e2d00e8ee2b062bfa22ca7e73244a5c27af6ea24fd32c3644c15194e0567 --- src/status.c | 21 +++++++++++++++++++++ static/status.html | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/status.c b/src/status.c index b9939de..b3e7c5f 100644 --- a/src/status.c +++ b/src/status.c @@ -30,6 +30,8 @@ // Pages #include "../static/status.chtml" +#define NUM_STR " (%u)" + int try_post_status(mastodont_t* api) { if (!post.content) return 1; @@ -82,6 +84,18 @@ int try_interact_status(mastodont_t* api, char* id) char* construct_status(struct mstdnt_status* status, int* size) { char* stat_html; + + // Counts + char* reply_count = NULL; + char* repeat_count = NULL; + char* favourites_count = NULL; + if (status->replies_count) + easprintf(&reply_count, NUM_STR, status->replies_count); + if (status->reblogs_count) + easprintf(&repeat_count, NUM_STR, status->reblogs_count); + if (status->favourites_count) + easprintf(&favourites_count, NUM_STR, status->favourites_count); + size_t s = easprintf(&stat_html, data_status_html, status->account.avatar, status->account.display_name, /* Username */ @@ -93,17 +107,24 @@ char* construct_status(struct mstdnt_status* status, int* size) status->content, config_url_prefix, status->id, + reply_count ? reply_count : "", config_url_prefix, status->id, status->reblogged ? "nobutton-active" : "", + repeat_count ? repeat_count : "", config_url_prefix, status->id, status->favourited ? "nobutton-active" : "", + favourites_count ? favourites_count : "", config_url_prefix, status->id, config_url_prefix, status->id); if (size) *size = s; + // Cleanup + if (reply_count) free(reply_count); + if (repeat_count) free(repeat_count); + if (favourites_count) free(favourites_count); return stat_html; } diff --git a/static/status.html b/static/status.html index 9863ec0..d13f94b 100644 --- a/static/status.html +++ b/static/status.html @@ -16,19 +16,19 @@