Show numbers

FossilOrigin-Name: 33b2e2d00e8ee2b062bfa22ca7e73244a5c27af6ea24fd32c3644c15194e0567
This commit is contained in:
me@ow.nekobit.net 2022-02-27 21:03:43 +00:00
parent 2a328bbf68
commit b127c92b8f
2 changed files with 24 additions and 3 deletions

View file

@ -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;
}

View file

@ -16,19 +16,19 @@
<ul>
<li>
<form action="%s/status/%s/reply" method="post">
<input class="nobutton" type="submit" value="Reply">
<input class="nobutton" type="submit" value="Reply%s">
</form>
</li>
<li>
<form action="%s/status/%s/interact" method="post">
<input type="hidden" name="itype" value="repeat">
<input class="nobutton %s" type="submit" value="Repeat">
<input class="nobutton %s" type="submit" value="Repeat%s">
</form>
</li>
<li>
<form action="%s/status/%s/interact" method="post">
<input type="hidden" name="itype" value="like">
<input class="nobutton %s" type="submit" value="Like">
<input class="nobutton %s" type="submit" value="Yeah!%s">
</form>
</li>
<li>