Perlify status interactions
FossilOrigin-Name: de6177ca45c0d238fedbc8824f85220736453e0df45f3e2160ea6f027e763fae
This commit is contained in:
parent
bbdb95187b
commit
3b334562bf
4 changed files with 39 additions and 13 deletions
|
@ -4,7 +4,7 @@ use warnings;
|
|||
|
||||
use Exporter 'import';
|
||||
|
||||
our @EXPORT = qw( account content_statuses generate_account_list generate_account_item );
|
||||
our @EXPORT = qw( account content_statuses generate_account_list generate_account_item status_interactions );
|
||||
|
||||
use template_helpers 'to_template';
|
||||
use l10n 'lang';
|
||||
|
@ -81,6 +81,24 @@ sub generate_account_list
|
|||
to_template(\%vars, \$data->{'accounts.tt'});
|
||||
}
|
||||
|
||||
sub status_interactions
|
||||
{
|
||||
my ($ssn, $data, $accounts, $label) = @_;
|
||||
|
||||
my %vars = (
|
||||
prefix => '',
|
||||
ssn => $ssn,
|
||||
data => $data,
|
||||
accounts => $accounts,
|
||||
label => $label,
|
||||
# Functions
|
||||
create_account => sub { generate_account_item($ssn, $data, shift); },
|
||||
);
|
||||
|
||||
|
||||
to_template(\%vars, \$data->{'status_interactions.tt'});
|
||||
}
|
||||
|
||||
sub content_accounts
|
||||
{
|
||||
my ($ssn, $data, $acct, $relationship, $accounts, $title) = @_;
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "../templates/about.ctt"
|
||||
#include "../templates/license.ctt"
|
||||
#include "../templates/login.ctt"
|
||||
#include "../templates/status_interactions.ctt"
|
||||
|
||||
PerlInterpreter* my_perl;
|
||||
HV* template_files;
|
||||
|
@ -90,6 +91,7 @@ void init_template_files(pTHX)
|
|||
hv_stores(template_files, "about.tt", newSVpv(data_about_tt, data_about_tt_size));
|
||||
hv_stores(template_files, "license.tt", newSVpv(data_license_tt, data_license_tt_size));
|
||||
hv_stores(template_files, "login.tt", newSVpv(data_login_tt, data_login_tt_size));
|
||||
hv_stores(template_files, "status_interactions.tt", newSVpv(data_status_interactions_tt, data_status_interactions_tt_size));
|
||||
}
|
||||
|
||||
void cleanup_template_files()
|
||||
|
|
25
src/status.c
25
src/status.c
|
@ -898,28 +898,29 @@ void content_status_interactions(FCGX_Request* req,
|
|||
struct mstdnt_account* accts,
|
||||
size_t accts_len)
|
||||
{
|
||||
char* accounts_html = construct_accounts(api, accts, accts_len, 0, NULL);
|
||||
if (!accounts_html)
|
||||
accounts_html = construct_error("No accounts", E_NOTICE, 1, NULL);
|
||||
PERL_STACK_INIT;
|
||||
HV* session_hv = perlify_session(ssn);
|
||||
XPUSHs(newRV_noinc((SV*)session_hv));
|
||||
XPUSHs(newRV_noinc((SV*)template_files));
|
||||
if (accts)
|
||||
XPUSHs(newRV_noinc((SV*)perlify_accounts(accts, accts_len)));
|
||||
else ARG_UNDEFINED();
|
||||
XPUSHs(newSVpv(label, 0));
|
||||
|
||||
struct interactions_page_template tmpl = {
|
||||
.back_ref = GET_ENV("HTTP_REFERER", req),
|
||||
.interaction_str = label,
|
||||
.accts = accounts_html
|
||||
};
|
||||
PERL_STACK_SCALAR_CALL("account::status_interactions");
|
||||
|
||||
char* output = tmpl_gen_interactions_page(&tmpl, NULL);
|
||||
char* dup = PERL_GET_STACK_EXIT;
|
||||
|
||||
struct base_page page = {
|
||||
.category = BASE_CAT_NONE,
|
||||
.content = output,
|
||||
.content = dup,
|
||||
.session = session_hv,
|
||||
.sidebar_left = NULL
|
||||
};
|
||||
render_base_page(&page, req, ssn, api);
|
||||
|
||||
// Cleanup
|
||||
free(accounts_html);
|
||||
free(output);
|
||||
Safefree(dup);
|
||||
}
|
||||
|
||||
void content_status(PATH_ARGS, uint8_t flags)
|
||||
|
|
5
templates/status_interactions.tt
Normal file
5
templates/status_interactions.tt
Normal file
|
@ -0,0 +1,5 @@
|
|||
<h1 class="text-header">$label</h1>
|
||||
|
||||
[% FOREACH i IN accounts %]
|
||||
[% create_account(i) %]
|
||||
[% END %]
|
Loading…
Reference in a new issue