From c18179b52b352f4af8f44edf87c2da3c2e412809 Mon Sep 17 00:00:00 2001 From: nekobit Date: Wed, 10 Aug 2022 05:06:47 +0000 Subject: [PATCH] Navigation FossilOrigin-Name: e1f2a5e64b2f8ba9ddb5c96d4d3ad8e37195d8f40020304df7f10ffb112a3c38 --- dist/treebird.css | 8 +++++++- perl/account.pm | 2 ++ perl/navigation.pm | 25 +++++++++++++++++++++++++ perl/timeline.pm | 2 ++ src/global_perl.c | 2 ++ templates/account_statuses.tt | 1 + templates/navigation.tt | 34 ++++++++++++++++++++++++++++++++++ templates/timeline.tt | 1 + 8 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 perl/navigation.pm create mode 100644 templates/navigation.tt diff --git a/dist/treebird.css b/dist/treebird.css index 18bc5d5..bb80050 100644 --- a/dist/treebird.css +++ b/dist/treebird.css @@ -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; diff --git a/perl/account.pm b/perl/account.pm index 9919b96..b2e593a 100644 --- a/perl/account.pm +++ b/perl/account.pm @@ -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'})); diff --git a/perl/navigation.pm b/perl/navigation.pm new file mode 100644 index 0000000..7b27737 --- /dev/null +++ b/perl/navigation.pm @@ -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'}); +} diff --git a/perl/timeline.pm b/perl/timeline.pm index f430188..31284cc 100644 --- a/perl/timeline.pm +++ b/perl/timeline.pm @@ -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'}); diff --git a/src/global_perl.c b/src/global_perl.c index 6de0585..688f71f 100644 --- a/src/global_perl.c +++ b/src/global_perl.c @@ -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() diff --git a/templates/account_statuses.tt b/templates/account_statuses.tt index bc05150..711e104 100644 --- a/templates/account_statuses.tt +++ b/templates/account_statuses.tt @@ -2,6 +2,7 @@ [% FOREACH i IN statuses %] [% create_status(i) %] [% END %] + [% nav %] [% ELSE %]

No statuses...

[% END %] diff --git a/templates/navigation.tt b/templates/navigation.tt new file mode 100644 index 0000000..a442c32 --- /dev/null +++ b/templates/navigation.tt @@ -0,0 +1,34 @@ + + + + + + + diff --git a/templates/timeline.tt b/templates/timeline.tt index bb4158d..d12d781 100644 --- a/templates/timeline.tt +++ b/templates/timeline.tt @@ -22,3 +22,4 @@ [% END %] [%# TODO navigation %] +[% nav %]