add timeline / current checkins

This commit is contained in:
Birte Kristina Friesel 2023-07-15 19:20:37 +02:00
parent bee67f096a
commit 1cca278baa
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA
9 changed files with 77 additions and 2 deletions

View file

@ -2201,6 +2201,7 @@ sub startup {
$authed_r->post('/delete')->to('account#delete'); $authed_r->post('/delete')->to('account#delete');
$authed_r->post('/logout')->to('account#do_logout'); $authed_r->post('/logout')->to('account#do_logout');
$authed_r->post('/set_token')->to('api#set_token'); $authed_r->post('/set_token')->to('api#set_token');
$authed_r->get('/timeline/in-transit')->to('profile#checked_in');
} }

View file

@ -546,4 +546,28 @@ sub status_card {
); );
} }
sub checked_in {
my ($self) = @_;
my $uid = $self->current_user->{id};
my @journeys = $self->in_transit->get_timeline(
uid => $uid,
with_data => 1
);
if ( $self->param('ajax') ) {
delete $self->stash->{layout};
$self->render(
'_timeline-checked-in',
journeys => [@journeys],
);
}
else {
$self->render(
'timeline-checked-in',
journeys => [@journeys],
);
}
}
1; 1;

View file

@ -382,7 +382,13 @@ sub compute_effective_visibility {
sub homepage { sub homepage {
my ($self) = @_; my ($self) = @_;
if ( $self->is_user_authenticated ) { if ( $self->is_user_authenticated ) {
my $uid = $self->current_user->{id};
my $status = $self->get_user_status; my $status = $self->get_user_status;
my @timeline = $self->in_transit->get_timeline(
uid => $uid,
short => 1
);
$self->stash( timeline => [@timeline] );
my @recent_targets; my @recent_targets;
if ( $status->{checked_in} ) { if ( $status->{checked_in} ) {
my $journey_visibility my $journey_visibility
@ -457,6 +463,12 @@ sub status_card {
delete $self->stash->{layout}; delete $self->stash->{layout};
my @timeline = $self->in_transit->get_timeline(
uid => $self->current_user->{id},
short => 1
);
$self->stash( timeline => [@timeline] );
if ( $status->{checked_in} ) { if ( $status->{checked_in} ) {
my $journey_visibility my $journey_visibility
= $self->compute_effective_visibility( = $self->compute_effective_visibility(

View file

@ -1,4 +1,7 @@
% my $user = current_user(); % my $user = current_user();
% if (@{stash('timeline') // []}) {
%= include '_timeline_link', timeline => stash('timeline')
% }
<div class="autorefresh"> <div class="autorefresh">
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">

View file

@ -7,6 +7,9 @@
% if (stash('from_profile')) { % if (stash('from_profile')) {
Unterwegs mit <%= include '_format_train', journey => $journey %> Unterwegs mit <%= include '_format_train', journey => $journey %>
% } % }
% elsif (stash('from_timeline')) {
<a href="/p/<%= $name %>"><%= $name %></a>: <%= include '_format_train', journey => $journey %>
% }
% else { % else {
<a href="/p/<%= $name %>"><%= $name %></a> ist unterwegs <a href="/p/<%= $name %>"><%= $name %></a> ist unterwegs
% } % }
@ -16,7 +19,7 @@
<p>„<%= $journey->{comment} %>“</p> <p>„<%= $journey->{comment} %>“</p>
% } % }
<p> <p>
% if (not stash('from_profile')) { % if (not stash('from_profile') and not stash('from_timeline')) {
<div class="center-align"> <div class="center-align">
%= include '_format_train', journey => $journey %= include '_format_train', journey => $journey
</div> </div>

View file

@ -0,0 +1,7 @@
% for my $journey (@{$journeys}) {
<div class="row">
<div class="col s12 autorefresh">
%= include '_public_status_card', name => $journey->{followee_name}, privacy => {}, journey => $journey, from_timeline => 1
</div>
</div>
% }

View file

@ -0,0 +1,16 @@
<div>
<a href="/timeline/in-transit">
% if (@{$timeline} <= 2) {
<strong><%= $timeline->[0]->{followee_name} %></strong>
% }
% if (@{$timeline} == 1) {
ist gerade unterwegs
% }
% elsif (@{$timeline} == 2) {
und <strong><%= $timeline->[1]->{followee_name} %></strong> sind gerade unterwegs
% }
% else {
<strong><%= scalar @{$timeline} %></strong> Accounts sind gerade unterwegs
% }
</a>
</div>

View file

@ -18,6 +18,9 @@
%= include '_checked_in', journey => $status, journey_visibility => stash('journey_visibility'); %= include '_checked_in', journey => $status, journey_visibility => stash('journey_visibility');
% } % }
% elsif ($status->{cancelled}) { % elsif ($status->{cancelled}) {
% if ( @{stash('timeline') // [] } ) {
%= include '_timeline_link', timeline => stash('timeline')
% }
<div class="card info-color"> <div class="card info-color">
<div class="card-content"> <div class="card-content">
<span class="card-title">Zugausfall dokumentieren</span> <span class="card-title">Zugausfall dokumentieren</span>
@ -45,6 +48,9 @@
</div> </div>
% } % }
% else { % else {
% if ( @{stash('timeline') // [] } ) {
%= include '_timeline_link', timeline => stash('timeline')
% }
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">
<span class="card-title">Hallo, <%= current_user->{name} %>!</span> <span class="card-title">Hallo, <%= current_user->{name} %>!</span>

View file

@ -0,0 +1,3 @@
<div class="timeline-in-transit">
%= include '_timeline-checked-in', journeys => $journeys
</div>