allow showing past journeys on shared status page
This commit is contained in:
parent
2652ea6bab
commit
57f686b688
5 changed files with 143 additions and 88 deletions
|
@ -33,17 +33,45 @@ sub user_status {
|
|||
my ($self) = @_;
|
||||
|
||||
my $name = $self->stash('name');
|
||||
my $ts = $self->stash('ts');
|
||||
my $ts = $self->stash('ts') // 0;
|
||||
my $user = $self->get_privacy_by_name($name);
|
||||
|
||||
if ( not $user or not $user->{public_level} & 0x03 ) {
|
||||
$self->render('not_found');
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $user->{public_level} & 0x01 and not $self->is_user_authenticated ) {
|
||||
$self->render( 'login', redirect_to => $self->req->url );
|
||||
return;
|
||||
}
|
||||
|
||||
my $status = $self->get_user_status( $user->{id} );
|
||||
my $journey;
|
||||
|
||||
if (
|
||||
$user
|
||||
and ( $user->{public_level} & 0x02
|
||||
$ts
|
||||
and ( not $status->{checked_in}
|
||||
or $status->{sched_departure}->epoch != $ts )
|
||||
and ( $user->{public_level} & 0x20
|
||||
or
|
||||
( $user->{public_level} & 0x01 and $self->is_user_authenticated ) )
|
||||
( $user->{public_level} & 0x10 and $self->is_user_authenticated ) )
|
||||
)
|
||||
{
|
||||
my $status = $self->get_user_status( $user->{id} );
|
||||
for my $candidate (
|
||||
$self->get_user_travels(
|
||||
uid => $user->{id},
|
||||
limit => 10,
|
||||
verbose => 1,
|
||||
with_datetime => 1
|
||||
)
|
||||
)
|
||||
{
|
||||
if ( $candidate->{sched_departure}->epoch eq $ts ) {
|
||||
$journey = $candidate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my %tw_data = (
|
||||
card => 'summary',
|
||||
|
@ -52,7 +80,13 @@ sub user_status {
|
|||
->to_abs->scheme('https'),
|
||||
);
|
||||
|
||||
if (
|
||||
if ($journey) {
|
||||
$tw_data{title} = sprintf( 'Fahrt von %s nach %s',
|
||||
$journey->{from_name}, $journey->{to_name} );
|
||||
$tw_data{description}
|
||||
= $journey->{rt_arrival}->strftime('Ankunft am %d.%m.%Y um %H:%M');
|
||||
}
|
||||
elsif (
|
||||
$ts
|
||||
and ( not $status->{checked_in}
|
||||
or $status->{sched_departure}->epoch != $ts )
|
||||
|
@ -65,10 +99,8 @@ sub user_status {
|
|||
$tw_data{title} = "${name} ist unterwegs";
|
||||
$tw_data{description} = sprintf(
|
||||
'%s %s von %s nach %s',
|
||||
$status->{train_type},
|
||||
$status->{train_line} // $status->{train_no},
|
||||
$status->{dep_name},
|
||||
$status->{arr_name} // 'irgendwo'
|
||||
$status->{train_type}, $status->{train_line} // $status->{train_no},
|
||||
$status->{dep_name}, $status->{arr_name} // 'irgendwo'
|
||||
);
|
||||
if ( $status->{real_arrival}->epoch ) {
|
||||
$tw_data{description} .= $status->{real_arrival}
|
||||
|
@ -80,6 +112,19 @@ sub user_status {
|
|||
$tw_data{description} = "Letztes Fahrtziel: $status->{arr_name}";
|
||||
}
|
||||
|
||||
if ($journey) {
|
||||
if ( not $user->{public_level} & 0x04 ) {
|
||||
delete $journey->{user_data}{comment};
|
||||
}
|
||||
$self->render(
|
||||
'journey',
|
||||
error => undef,
|
||||
readonly => 1,
|
||||
journey => $journey,
|
||||
twitter => \%tw_data,
|
||||
);
|
||||
}
|
||||
else {
|
||||
$self->render(
|
||||
'user_status',
|
||||
name => $name,
|
||||
|
@ -88,12 +133,6 @@ sub user_status {
|
|||
twitter => \%tw_data,
|
||||
);
|
||||
}
|
||||
elsif ( $user->{public_level} & 0x01 ) {
|
||||
$self->render( 'login', redirect_to => $self->req->url );
|
||||
}
|
||||
else {
|
||||
$self->render('not_found');
|
||||
}
|
||||
}
|
||||
|
||||
sub public_status_card {
|
||||
|
|
|
@ -164,13 +164,14 @@
|
|||
<p>
|
||||
% if ($journey->{arr_name}) {
|
||||
Zuletzt gesehen
|
||||
% if ($public_level & 0x30 and $journey->{real_arrival}->epoch) {
|
||||
% if ($journey->{real_arrival}->epoch and ($public_level & 0x20 or ($public_level & 0x10 and is_user_authenticated()))) {
|
||||
%= $journey->{real_arrival}->strftime('am %d.%m.%Y')
|
||||
% }
|
||||
in <b><%= $journey->{arr_name} %></b>
|
||||
% if ($public_level & 0x30 and $journey->{real_arrival}->epoch) {
|
||||
%= $journey->{real_arrival}->strftime('(Ankunft um %H:%M Uhr)')
|
||||
% }
|
||||
% else {
|
||||
in <b><%= $journey->{arr_name} %></b>
|
||||
% }
|
||||
% }
|
||||
% else {
|
||||
Noch keine Zugfahrten geloggt.
|
||||
|
|
|
@ -75,6 +75,15 @@
|
|||
% if ($acc->{is_public} & 0x04) {
|
||||
mit Kommentar
|
||||
% }
|
||||
% if ($acc->{is_public} & 0x0f and $acc->{is_public} & 0xf0) {
|
||||
<br/>
|
||||
% }
|
||||
% if ($acc->{is_public} & 0x10) {
|
||||
Letzte zehn Fahrten (nur für angemeldete Accounts)
|
||||
% }
|
||||
% elsif ($acc->{is_public} & 0x20) {
|
||||
Letzte zehn Fahrten
|
||||
% }
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
|
|
@ -223,6 +223,7 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
% if (not stash('readonly')) {
|
||||
<div class="row hide-on-small-only">
|
||||
<div class="col s12 m6 l6 center-align">
|
||||
<a class="waves-effect waves-light red btn action-delete"
|
||||
|
@ -264,3 +265,4 @@
|
|||
</div>
|
||||
</div>
|
||||
% }
|
||||
% }
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
Wenn du eingecheckt bist, werden dort Zug, Start- und Zielstation,
|
||||
Abfahrts- und Ankunftszeit gezeigt; andernfalls lediglich der
|
||||
Zielbahnhof der letzten Reise. Wann die letzte Reise beendet wurde,
|
||||
wird bewusst nicht angegeben.
|
||||
wird nur angegeben, wenn deine vergangenen Zugfahrten sichtbar sind
|
||||
(siehe unten).
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@ -89,9 +90,12 @@
|
|||
<div class="col s12">
|
||||
Diese Einstellung bestimmt die Sichtbarkeit deiner letzten
|
||||
zehn Zugfahrten mit allen dazu bekannten Details (Abfahrt, Ankunft,
|
||||
Wagenreihung u.a.). Dies umfasst Angaben auf
|
||||
<a href="/status/<%= $name %>">/status/<%= $name %></a> sowie
|
||||
eine Liste deiner letzten Fahrten. Die Implementierung folgt noch...
|
||||
Wagenreihung u.a.). Derzeit sind diese nur mit einem von dir
|
||||
geteilten (oder korrekt erratenen) Link zu
|
||||
<a href="/status/<%= $name %>">/status/<%= $name %>/ID</a> abrufbar.
|
||||
In Zukunft kann eine auf deiner Statusseite eingebundene Liste
|
||||
deiner letzten Zugfahrten folgen, deren Sichtbarkeit ebenfalls von
|
||||
dieser Einstellung bestimmt wird.
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
Loading…
Reference in a new issue