Accounts and accounts item template

FossilOrigin-Name: 248b2707f4670077651f40f93bb928b75e70ec33789025d0ef8fe239f7858bc8
This commit is contained in:
nekobit 2022-08-13 05:56:43 +00:00
parent ca444fde1d
commit 6534dd27aa
4 changed files with 50 additions and 0 deletions

View File

@ -48,3 +48,20 @@ sub content_statuses
generate_account($ssn, $data, $acct, $relationship, to_template(\%vars, \$data->{'account_statuses.tt'}));
}
sub generate_account_item
{
my ($ssn, $data, $account) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
account => $account,
# Functions
icon => \&get_icon,
lang => \&lang,
format_username => \&format_username,
);
to_template(\%vars, \$data->{'account_item.tt'});
}

View File

@ -34,6 +34,8 @@
#include "../templates/content_notifs.ctt"
#include "../templates/content_lists.ctt"
#include "../templates/navigation.ctt"
#include "../templates/accounts.ctt"
#include "../templates/account_item.ctt"
PerlInterpreter* my_perl;
HV* template_files;
@ -58,6 +60,8 @@ void init_template_files(pTHX)
hv_stores(template_files, "content_notifs.tt", newSVpv(data_content_notifs_tt, data_content_notifs_tt_size));
hv_stores(template_files, "content_lists.tt", newSVpv(data_content_lists_tt, data_content_lists_tt_size));
hv_stores(template_files, "navigation.tt", newSVpv(data_navigation_tt, data_navigation_tt_size));
hv_stores(template_files, "accounts.tt", newSVpv(data_accounts_tt, data_accounts_tt_size));
hv_stores(template_files, "account_item.tt", newSVpv(data_account_item_tt, data_account_item_tt_size));
}
void cleanup_template_files()

19
templates/account_item.tt Normal file
View File

@ -0,0 +1,19 @@
<table class="account-stub">
<tr>
<td class="pfp-td">
<a href="/@[% account.acct %]"><img src="[% account.avatar %]"></a>
</td>
<td class="account-stub-info-wrapper">
<div class="account-stub-info">
<a href="/@[% account.acct %]">
<div class="account-stub-top">
<span class="username">[% format_username(account.display_name) %]</span>
</div>
<div class="account-stub-bottom">
<span class="instance-info">@[% account.acct %]</span>
</div>
</a>
</div>
</td>
</tr>
</table>

10
templates/accounts.tt Normal file
View File

@ -0,0 +1,10 @@
[% IF title %]
<h1 class="text-header">$title</h1>
[% END %]
[% FOREACH i IN accounts %]
[% create_account(i) %]
[% END %]
[%# TODO navigation %]
[% nav() %]