diff --git a/perl/l10n.pm b/perl/l10n.pm index e69fee3..b546acc 100644 --- a/perl/l10n.pm +++ b/perl/l10n.pm @@ -2,7 +2,7 @@ package l10n; use Exporter 'import'; -our @EXPORT = qw( %L10N ); +our @EXPORT = qw( &lang %L10N ); our %L10N = ( EN_US => { @@ -86,6 +86,11 @@ our %L10N = ( NOTIF_COMPACT_POLL => 'poll', }, # TODO bring over Spanish and Chinese -); + ); + +sub lang +{ + $L10N{'EN_US'}->{shift(@_)} +} return 1; diff --git a/perl/main.pl b/perl/main.pl index e9529ec..e7e6b7c 100644 --- a/perl/main.pl +++ b/perl/main.pl @@ -2,7 +2,7 @@ use strict; use warnings; # Modules use Template; -use l10n qw( %L10N ); +use l10n qw( &lang %L10N ); use notifications qw( notification_compact ); use template_helpers qw( &to_template ); use status (); @@ -27,7 +27,7 @@ sub base_page prefix => '', ssn => $ssn, title => $L10N{'EN_US'}->{'APP_NAME'}, - lang => sub { $L10N{'EN_US'}->{shift(@_)} }, + lang => \&lang, main => $main, sidebar_opacity => $ssn->{config}->{sidebar_opacity} / 255, acct => $ssn->{account}, diff --git a/perl/notifications.pm b/perl/notifications.pm index 613c946..c97377a 100644 --- a/perl/notifications.pm +++ b/perl/notifications.pm @@ -1,5 +1,6 @@ package notifications; - +use strict; +use warnings; use Exporter 'import'; our @EXPORT = qw( notification_compact ); diff --git a/perl/status.pm b/perl/status.pm index f14f2fc..232b621 100644 --- a/perl/status.pm +++ b/perl/status.pm @@ -1,5 +1,6 @@ package status; - +use strict; +use warnings; use Exporter 'import'; our @EXPORT = qw( status ); @@ -20,7 +21,17 @@ sub status sub content_status { - my ($ssn, $data, $statuses) = @_; + my ($ssn, $data, $status, $statuses_before, $statuses_after) = @_; - to_template(\%name, \$data->{'content_status.tt'}); + my %vars = ( + ssn => $ssn, + data => $data, + create_status => \&status, + status => $status, + statuses_before => $statuses_before, + statuses_after => $statuses_after, + ); + + + to_template(\%vars, \$data->{'content_status.tt'}); } diff --git a/perl/template_helpers.pm b/perl/template_helpers.pm index a31a11c..0e74d6a 100644 --- a/perl/template_helpers.pm +++ b/perl/template_helpers.pm @@ -1,5 +1,6 @@ package template_helpers; - +use strict; +use warnings; use Exporter 'import'; our @EXPORT = qw( &to_template ); diff --git a/src/global_perl.c b/src/global_perl.c index 4d37b4b..0bae575 100644 --- a/src/global_perl.c +++ b/src/global_perl.c @@ -21,6 +21,7 @@ #include "../templates/main.ctt" #include "../templates/notif_compact.ctt" #include "../templates/status.ctt" +#include "../templates/content_status.ctt" HV* template_files; pthread_mutex_t perl_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -32,7 +33,7 @@ void init_template_files() hv_stores(template_files, "main.tt", newSVpv(data_main_tt, data_main_tt_size)); hv_stores(template_files, "notif_compact.tt", newSVpv(data_notif_compact_tt, data_notif_compact_tt_size)); hv_stores(template_files, "status.tt", newSVpv(data_status_tt, data_status_tt_size)); - hv_stores(template_files, "content_status.tt", newSVpv(data_status_tt, data_status_tt_size)); + hv_stores(template_files, "content_status.tt", newSVpv(data_content_status_tt, data_content_status_tt_size)); } void cleanup_template_files() diff --git a/src/status.c b/src/status.c index 844d89f..58638be 100644 --- a/src/status.c +++ b/src/status.c @@ -1066,6 +1066,16 @@ void content_status(PATH_ARGS, uint8_t flags) HV* session_hv = perlify_session(ssn); XPUSHs(newRV_inc((SV*)session_hv)); XPUSHs(newRV_inc((SV*)template_files)); + XPUSHs(newRV_inc((SV*)perlify_status(&status))); + if (statuses_before) + XPUSHs(newRV_inc((AV*)perlify_statuses(statuses_before, stat_before_len))); + else + XPUSHs(&PL_sv_undef); + + if (statuses_after) + XPUSHs(newRV_inc((AV*)perlify_statuses(statuses_after, stat_after_len))); + else + XPUSHs(&PL_sv_undef); // ARGS PUTBACK; call_pv("status::content_status", G_SCALAR); @@ -1134,3 +1144,18 @@ HV* perlify_status(const struct mstdnt_status* status) return status_hv; } + + +AV* perlify_statuses(const struct mstdnt_status* statuses, size_t len) +{ + if (!(statuses && len)) return NULL; + AV* av = newAV(); + av_extend(av, len-1); + + for (int i = 0; i < len; ++i) + { + av_store(av, i, newRV_inc((SV*)perlify_status(statuses + i))); + } + + return av; +} diff --git a/src/status.h b/src/status.h index 0041ce7..7a3c36c 100644 --- a/src/status.h +++ b/src/status.h @@ -136,6 +136,7 @@ void notice_redirect(PATH_ARGS); void api_status_interact(PATH_ARGS); // Perl -HV* perlify_status(const struct mstdnt_status* status); +HV* perlify_status(const struct mstdnt_status* status); +AV* perlify_statuses(const struct mstdnt_status* statuses, size_t len); #endif // STATUS_H diff --git a/templates/content_status.tt b/templates/content_status.tt index bf7e899..3cd6cc9 100644 --- a/templates/content_status.tt +++ b/templates/content_status.tt @@ -1 +1,7 @@ -asdasd +[% FOREACH i IN statuses_before %] + [% create_status(ssn, data, i) %] +[% END %] +[% create_status(ssn, data, status) %] +[% FOREACH i IN statuses_after %] + [% create_status(ssn, data, i) %] +[% END %] diff --git a/templates/main.tt b/templates/main.tt index dd01af4..713398f 100644 --- a/templates/main.tt +++ b/templates/main.tt @@ -1,157 +1,157 @@ - - - $title - - - [% IF !(ssn.config.theme == "treebird" && ssn.config.themeclr == 0) %] - - [% END %] - - - [% IF ssn.config.sidebar_opacity %] - - [% END %] - - -
- - - - - - - - - - - - - - -
- $main -
-
- - - - - + + + + +