Load account stubs

FossilOrigin-Name: ec18c50cdcf12538dbc46e714318466a64f606c2931cd2fdbace47b14087b578
This commit is contained in:
me@ow.nekobit.net 2022-05-05 15:05:05 +00:00
parent 5e0d1949a5
commit 53aa15e831
5 changed files with 50 additions and 3 deletions

View file

@ -100,6 +100,8 @@ $(PAGES_DIR)/bookmarks_page.chtml: $(PAGES_DIR)/bookmarks_page.html
./filec $< data_bookmarks_page_html > $@
$(PAGES_DIR)/favourites_page.chtml: $(PAGES_DIR)/favourites_page.html
./filec $< data_favourites_page_html > $@
$(PAGES_DIR)/account_stub.chtml: $(PAGES_DIR)/account_stub.html
./filec $< data_account_stub_html > $@
$(MASTODONT_DIR):
git clone $(MASTODONT_URL) || true

View file

@ -36,9 +36,17 @@
#include "../static/account_follow_btn.chtml"
#include "../static/favourites_page.chtml"
#include "../static/bookmarks_page.chtml"
#include "../static/account_stub.chtml"
#define FOLLOWS_YOU_HTML "<span class=\"acct-badge\">%s</span>"
struct account_args
{
mastodont_t* api;
struct mstdnt_account* accts;
uint8_t flags;
};
char* load_account_info(struct mstdnt_account* acct,
size_t* size)
{
@ -290,6 +298,41 @@ size_t construct_account_page(char** result, struct account_page* page, char* co
return size;
}
char* construct_account(mastodont_t* api,
struct mstdnt_account* acct,
uint8_t flags,
int* size)
{
char* acct_html;
size_t s = easprintf(&acct_html, data_account_stub_html,
acct->acct);
if (size) *size = s;
return acct_html;
}
static char* construct_account_voidwrap(void* passed, size_t index, int* res)
{
struct account_args* args = passed;
return construct_account(args->api, args->accts + index, args->flags, res);
}
char* construct_accounts(mastodont_t* api,
struct mstdnt_account* accounts,
size_t size,
uint8_t flags,
size_t* ret_size)
{
if (!(accounts && size)) return NULL;
struct account_args acct_args = {
.api = api,
.accts = accounts,
.flags = flags,
};
return construct_func_strings(construct_account_voidwrap, &acct_args, size, ret_size);
}
char* load_account_page(mastodont_t* api,
struct mstdnt_account* acct,
struct mstdnt_relationship* relationship,

View file

@ -55,8 +55,8 @@ struct account_page
char* construct_account(mastodont_t* api,
struct mstdnt_account* account,
int* size,
uint8_t flags);
uint8_t flags,
int* size);
char* construct_accounts(mastodont_t* api,
struct mstdnt_account* accounts,
size_t size,

View file

@ -24,6 +24,7 @@
#include "base_page.h"
#include "status.h"
#include "error.h"
#include "account.h"
// Pages
#include "../static/search.chtml"
@ -104,7 +105,7 @@ void content_search_accounts(struct session* ssn, mastodont_t* api, char** data)
struct mstdnt_storage storage = { 0 };
struct mstdnt_search_args args = {
.account_id = NULL,
.type = MSTDNT_SEARCH_STATUSES,
.type = MSTDNT_SEARCH_ACCOUNTS,
.resolve = 0,
.following = 0,
.with_relationships = 0,

1
static/account_stub.html Normal file
View file

@ -0,0 +1 @@
%s<br>