Template files and stuff

FossilOrigin-Name: 7b78c4539633a22909aa1d3d3c86d10d83897ee9e4db0796562fa290c34eb657
This commit is contained in:
nekobit 2022-08-04 16:17:59 +00:00
parent 50b0404c51
commit e002975c75
6 changed files with 48 additions and 0 deletions

35
perl/account.pm Normal file
View file

@ -0,0 +1,35 @@
package account;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw( generate_attachment );
use template_helpers 'to_template';
sub account
{
my ($ssn, $data, $acct, $content) = @_;
my %vars = (
prefix = '',
ssn => $ssn,
content => $content,
);
to_template(\%vars, \$data->{'account.tt'});
}
sub content_account_statuses
{
my ($ssn, $data, $acct, $statuses) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
acct => $acct,
);
account($ssn, $data, $acct, to_template(\%vars, \$data->{'account_statuses.tt'}));
}

View file

@ -18,6 +18,7 @@
#include <string.h>
#include <stdlib.h>
#include "global_perl.h"
#include "helpers.h"
#include "base_page.h"
#include "error.h"

View file

@ -18,6 +18,7 @@
#include "global_perl.h"
/* TODO let's generate this file dynamically with a Perl script? */
#include "../templates/main.ctt"
#include "../templates/notif_compact.ctt"
#include "../templates/status.ctt"
@ -27,6 +28,9 @@
#include "../templates/emoji.ctt"
#include "../templates/postbox.ctt"
#include "../templates/timeline.ctt"
#include "../templates/account.ctt"
#include "../templates/account_statuses.ctt"
#include "../templates/account_scrobbles.ctt"
HV* template_files;
pthread_mutex_t perl_mutex = PTHREAD_MUTEX_INITIALIZER;
@ -44,6 +48,9 @@ void init_template_files()
hv_stores(template_files, "emoji.tt", newSVpv(data_emoji_tt, data_emoji_tt_size));
hv_stores(template_files, "postbox.tt", newSVpv(data_postbox_tt, data_postbox_tt_size));
hv_stores(template_files, "timeline.tt", newSVpv(data_timeline_tt, data_timeline_tt_size));
hv_stores(template_files, "account.tt", newSVpv(data_account_tt, data_account_tt_size));
hv_stores(template_files, "account_statuses.tt", newSVpv(data_account_statuses_tt, data_account_statuses_tt_size));
hv_stores(template_files, "account_scrobbles.tt", newSVpv(data_account_scrobbles_tt, data_account_scrobbles_tt_size));
}
void cleanup_template_files()

3
templates/account.tt Normal file
View file

@ -0,0 +1,3 @@
account
[% content %]

View file

@ -0,0 +1 @@
Scrobbles

View file

@ -0,0 +1 @@
Account statuses