Navigation

FossilOrigin-Name: e1f2a5e64b2f8ba9ddb5c96d4d3ad8e37195d8f40020304df7f10ffb112a3c38
This commit is contained in:
nekobit 2022-08-10 05:06:47 +00:00
parent ba24b6a993
commit c18179b52b
8 changed files with 74 additions and 1 deletions

8
dist/treebird.css vendored
View file

@ -597,7 +597,7 @@ input[type=submit].post-btn
display: block;
margin: 7px 8px;
border-radius: 4px;
padding: 4px 10px;
padding: 6px 10px;
font-size: 14px;
text-transform: uppercase;
color: #505050;
@ -2027,6 +2027,12 @@ input[type=checkbox].hidden:not(:checked) + .list-edit-content
padding: 6px;
}
.navigation .nav-up
{
width: 50px;
text-align: center;
}
.nav-symbol
{
color: #505050;

View file

@ -10,6 +10,7 @@ use template_helpers 'to_template';
use l10n 'lang';
use status 'generate_status';
use string_helpers qw( simple_escape emojify );
use navigation 'generate_navigation';
sub generate_account
{
@ -39,6 +40,7 @@ sub content_statuses
acct => $acct,
statuses => $statuses,
create_status => sub { generate_status($ssn, $data, shift); },
nav => generate_navigation($ssn, $data, $statuses->[0]->{id}, $statuses->[-1]->{id}),
);
generate_account($ssn, $data, $acct, $relationship, to_template(\%vars, \$data->{'account_statuses.tt'}));

25
perl/navigation.pm Normal file
View file

@ -0,0 +1,25 @@
package navigation;
use strict;
use warnings;
use Exporter 'import';
our @EXPORT = qw( generate_navigation );
use template_helpers 'to_template';
use l10n 'lang';
sub generate_navigation
{
my ($ssn, $data, $first_id, $last_id) = @_;
my %vars = (
prefix => '',
ssn => $ssn,
lang => \&lang,
start_id => $ssn->{post}->{start_id} || $first_id,
prev_id => $first_id,
next_id => $last_id,
);
to_template(\%vars, \$data->{'navigation.tt'});
}

View file

@ -9,6 +9,7 @@ use template_helpers 'to_template';
use icons 'get_icon';
use postbox 'generate_postbox';
use status 'generate_status';
use navigation 'generate_navigation';
sub content_timeline
{
@ -23,6 +24,7 @@ sub content_timeline
show_post_box => $show_post_box,
postbox => \&generate_postbox,
create_status => sub { generate_status($ssn, $data, shift); },
nav => generate_navigation($ssn, $data, $statuses->[0]->{id}, $statuses->[-1]->{id}),
);
to_template(\%vars, \$data->{'timeline.tt'});

View file

@ -33,6 +33,7 @@
#include "../templates/account_scrobbles.ctt"
#include "../templates/content_notifs.ctt"
#include "../templates/content_lists.ctt"
#include "../templates/navigation.ctt"
PerlInterpreter* my_perl;
HV* template_files;
@ -56,6 +57,7 @@ void init_template_files(pTHX)
hv_stores(template_files, "account_scrobbles.tt", newSVpv(data_account_scrobbles_tt, data_account_scrobbles_tt_size));
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));
}
void cleanup_template_files()

View file

@ -2,6 +2,7 @@
[% FOREACH i IN statuses %]
[% create_status(i) %]
[% END %]
[% nav %]
[% ELSE %]
<p>No statuses...</p>
[% END %]

34
templates/navigation.tt Normal file
View file

@ -0,0 +1,34 @@
<table class="navigation ui-table">
<tr>
<td class="nav-up btn">
<form action="" method="post">
<label class="pointer">
<span class="nav-btn">Up</span>
<input type="submit" class="hidden">
</label>
</form>
</td>
<td class="nav-prev btn">
<form action="" method="post">
<label class="pointer">
[% UNLESS prev_id == start_id %]
<input type="hidden" name="start_id" value="[% start_id %]">
<input type="hidden" name="min_id" value="[% prev_id %]">
<input type="submit" class="hidden">
[% END %]
<span class="nav-btn[% IF prev_id == start_id %] btn-disabled[% END %]">Previous</span>
</label>
</form>
</td>
<td class="nav-next btn">
<form action="" method="post">
<label class="pointer">
<input type="hidden" name="start_id" value="[% start_id %]">
<input type="hidden" name="max_id" value="[% next_id %]">
<span class="nav-btn">Next</span>
<input type="submit" class="hidden">
</label>
</form>
</td>
</tr>
</table>

View file

@ -22,3 +22,4 @@
[% END %]
[%# TODO navigation %]
[% nav %]