add timeline / current checkins
This commit is contained in:
parent
bee67f096a
commit
1cca278baa
9 changed files with 77 additions and 2 deletions
|
@ -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');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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">
|
||||||
|
|
|
@ -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>
|
||||||
|
|
7
templates/_timeline-checked-in.html.ep
Normal file
7
templates/_timeline-checked-in.html.ep
Normal 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>
|
||||||
|
% }
|
16
templates/_timeline_link.html.ep
Normal file
16
templates/_timeline_link.html.ep
Normal 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>
|
|
@ -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>
|
||||||
|
|
3
templates/timeline-checked-in.html.ep
Normal file
3
templates/timeline-checked-in.html.ep
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<div class="timeline-in-transit">
|
||||||
|
%= include '_timeline-checked-in', journeys => $journeys
|
||||||
|
</div>
|
Loading…
Reference in a new issue