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,53 +33,98 @@ sub user_status {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
|
|
||||||
my $name = $self->stash('name');
|
my $name = $self->stash('name');
|
||||||
my $ts = $self->stash('ts');
|
my $ts = $self->stash('ts') // 0;
|
||||||
my $user = $self->get_privacy_by_name($name);
|
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 (
|
if (
|
||||||
$user
|
$ts
|
||||||
and ( $user->{public_level} & 0x02
|
and ( not $status->{checked_in}
|
||||||
|
or $status->{sched_departure}->epoch != $ts )
|
||||||
|
and ( $user->{public_level} & 0x20
|
||||||
or
|
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(
|
||||||
my %tw_data = (
|
uid => $user->{id},
|
||||||
card => 'summary',
|
limit => 10,
|
||||||
site => '@derfnull',
|
verbose => 1,
|
||||||
image => $self->url_for('/static/icons/icon-512x512.png')
|
with_datetime => 1
|
||||||
->to_abs->scheme('https'),
|
)
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
$ts
|
|
||||||
and ( not $status->{checked_in}
|
|
||||||
or $status->{sched_departure}->epoch != $ts )
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$tw_data{title} = "Bahnfahrt beendet";
|
if ( $candidate->{sched_departure}->epoch eq $ts ) {
|
||||||
$tw_data{description} = "${name} hat das Ziel erreicht";
|
$journey = $candidate;
|
||||||
}
|
|
||||||
elsif ( $status->{checked_in} ) {
|
|
||||||
$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'
|
|
||||||
);
|
|
||||||
if ( $status->{real_arrival}->epoch ) {
|
|
||||||
$tw_data{description} .= $status->{real_arrival}
|
|
||||||
->strftime(' – Ankunft gegen %H:%M Uhr');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
$tw_data{title} = "${name} ist gerade nicht eingecheckt";
|
|
||||||
$tw_data{description} = "Letztes Fahrtziel: $status->{arr_name}";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
my %tw_data = (
|
||||||
|
card => 'summary',
|
||||||
|
site => '@derfnull',
|
||||||
|
image => $self->url_for('/static/icons/icon-512x512.png')
|
||||||
|
->to_abs->scheme('https'),
|
||||||
|
);
|
||||||
|
|
||||||
|
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 )
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$tw_data{title} = "Bahnfahrt beendet";
|
||||||
|
$tw_data{description} = "${name} hat das Ziel erreicht";
|
||||||
|
}
|
||||||
|
elsif ( $status->{checked_in} ) {
|
||||||
|
$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'
|
||||||
|
);
|
||||||
|
if ( $status->{real_arrival}->epoch ) {
|
||||||
|
$tw_data{description} .= $status->{real_arrival}
|
||||||
|
->strftime(' – Ankunft gegen %H:%M Uhr');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$tw_data{title} = "${name} ist gerade nicht eingecheckt";
|
||||||
|
$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(
|
$self->render(
|
||||||
'user_status',
|
'user_status',
|
||||||
name => $name,
|
name => $name,
|
||||||
|
@ -88,12 +133,6 @@ sub user_status {
|
||||||
twitter => \%tw_data,
|
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 {
|
sub public_status_card {
|
||||||
|
|
|
@ -164,13 +164,14 @@
|
||||||
<p>
|
<p>
|
||||||
% if ($journey->{arr_name}) {
|
% if ($journey->{arr_name}) {
|
||||||
Zuletzt gesehen
|
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')
|
%= $journey->{real_arrival}->strftime('am %d.%m.%Y')
|
||||||
% }
|
in <b><%= $journey->{arr_name} %></b>
|
||||||
in <b><%= $journey->{arr_name} %></b>
|
|
||||||
% if ($public_level & 0x30 and $journey->{real_arrival}->epoch) {
|
|
||||||
%= $journey->{real_arrival}->strftime('(Ankunft um %H:%M Uhr)')
|
%= $journey->{real_arrival}->strftime('(Ankunft um %H:%M Uhr)')
|
||||||
% }
|
% }
|
||||||
|
% else {
|
||||||
|
in <b><%= $journey->{arr_name} %></b>
|
||||||
|
% }
|
||||||
% }
|
% }
|
||||||
% else {
|
% else {
|
||||||
Noch keine Zugfahrten geloggt.
|
Noch keine Zugfahrten geloggt.
|
||||||
|
|
|
@ -75,6 +75,15 @@
|
||||||
% if ($acc->{is_public} & 0x04) {
|
% if ($acc->{is_public} & 0x04) {
|
||||||
mit Kommentar
|
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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -223,44 +223,46 @@
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row hide-on-small-only">
|
% if (not stash('readonly')) {
|
||||||
<div class="col s12 m6 l6 center-align">
|
<div class="row hide-on-small-only">
|
||||||
<a class="waves-effect waves-light red btn action-delete"
|
<div class="col s12 m6 l6 center-align">
|
||||||
data-id="<%= $journey->{id} %>"
|
<a class="waves-effect waves-light red btn action-delete"
|
||||||
data-checkin="<%= $journey->{checkin}->epoch %>"
|
data-id="<%= $journey->{id} %>"
|
||||||
data-checkout="<%= $journey->{checkout}->epoch %>">
|
data-checkin="<%= $journey->{checkin}->epoch %>"
|
||||||
<i class="material-icons left">delete_forever</i>
|
data-checkout="<%= $journey->{checkout}->epoch %>">
|
||||||
Löschen
|
<i class="material-icons left">delete_forever</i>
|
||||||
</a>
|
Löschen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="col s12 m6 l6 center-align">
|
||||||
|
%= form_for '/journey/edit' => (method => 'POST') => begin
|
||||||
|
%= hidden_field 'journey_id' => param('journey_id')
|
||||||
|
<button class="btn waves-effect waves-light" type="submit" name="action" value="edit">
|
||||||
|
<i class="material-icons left" aria-hidden="true">edit</i>
|
||||||
|
Bearbeiten
|
||||||
|
</button>
|
||||||
|
%= end
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col s12 m6 l6 center-align">
|
<div class="row hide-on-med-and-up">
|
||||||
%= form_for '/journey/edit' => (method => 'POST') => begin
|
<div class="col s12 m6 l6 center-align">
|
||||||
%= hidden_field 'journey_id' => param('journey_id')
|
%= form_for '/journey/edit' => (method => 'POST') => begin
|
||||||
<button class="btn waves-effect waves-light" type="submit" name="action" value="edit">
|
%= hidden_field 'journey_id' => param('journey_id')
|
||||||
<i class="material-icons left" aria-hidden="true">edit</i>
|
<button class="btn waves-effect waves-light" type="submit" name="action" value="edit">
|
||||||
Bearbeiten
|
<i class="material-icons left" aria-hidden="true">edit</i>
|
||||||
</button>
|
Bearbeiten
|
||||||
%= end
|
</button>
|
||||||
|
%= end
|
||||||
|
</div>
|
||||||
|
<div class="col s12 m6 l6 center-align" style="margin-top: 1em;">
|
||||||
|
<a class="waves-effect waves-light red btn action-delete"
|
||||||
|
data-id="<%= $journey->{id} %>"
|
||||||
|
data-checkin="<%= $journey->{checkin}->epoch %>"
|
||||||
|
data-checkout="<%= $journey->{checkout}->epoch %>">
|
||||||
|
<i class="material-icons left" aria-hidden="true">delete_forever</i>
|
||||||
|
Löschen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
% }
|
||||||
<div class="row hide-on-med-and-up">
|
|
||||||
<div class="col s12 m6 l6 center-align">
|
|
||||||
%= form_for '/journey/edit' => (method => 'POST') => begin
|
|
||||||
%= hidden_field 'journey_id' => param('journey_id')
|
|
||||||
<button class="btn waves-effect waves-light" type="submit" name="action" value="edit">
|
|
||||||
<i class="material-icons left" aria-hidden="true">edit</i>
|
|
||||||
Bearbeiten
|
|
||||||
</button>
|
|
||||||
%= end
|
|
||||||
</div>
|
|
||||||
<div class="col s12 m6 l6 center-align" style="margin-top: 1em;">
|
|
||||||
<a class="waves-effect waves-light red btn action-delete"
|
|
||||||
data-id="<%= $journey->{id} %>"
|
|
||||||
data-checkin="<%= $journey->{checkin}->epoch %>"
|
|
||||||
data-checkout="<%= $journey->{checkout}->epoch %>">
|
|
||||||
<i class="material-icons left" aria-hidden="true">delete_forever</i>
|
|
||||||
Löschen
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
% }
|
% }
|
||||||
|
|
|
@ -41,7 +41,8 @@
|
||||||
Wenn du eingecheckt bist, werden dort Zug, Start- und Zielstation,
|
Wenn du eingecheckt bist, werden dort Zug, Start- und Zielstation,
|
||||||
Abfahrts- und Ankunftszeit gezeigt; andernfalls lediglich der
|
Abfahrts- und Ankunftszeit gezeigt; andernfalls lediglich der
|
||||||
Zielbahnhof der letzten Reise. Wann die letzte Reise beendet wurde,
|
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>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -89,9 +90,12 @@
|
||||||
<div class="col s12">
|
<div class="col s12">
|
||||||
Diese Einstellung bestimmt die Sichtbarkeit deiner letzten
|
Diese Einstellung bestimmt die Sichtbarkeit deiner letzten
|
||||||
zehn Zugfahrten mit allen dazu bekannten Details (Abfahrt, Ankunft,
|
zehn Zugfahrten mit allen dazu bekannten Details (Abfahrt, Ankunft,
|
||||||
Wagenreihung u.a.). Dies umfasst Angaben auf
|
Wagenreihung u.a.). Derzeit sind diese nur mit einem von dir
|
||||||
<a href="/status/<%= $name %>">/status/<%= $name %></a> sowie
|
geteilten (oder korrekt erratenen) Link zu
|
||||||
eine Liste deiner letzten Fahrten. Die Implementierung folgt noch...
|
<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>
|
</div>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
Loading…
Reference in a new issue