add public profile page and public journey details
This commit is contained in:
parent
ea0fe3ea3e
commit
482fa975b5
7 changed files with 139 additions and 14 deletions
|
@ -2685,6 +2685,8 @@ sub startup {
|
|||
$r->get('/status/:name/:ts')->to('traveling#user_status');
|
||||
$r->get('/ajax/status/:name')->to('traveling#public_status_card');
|
||||
$r->get('/ajax/status/:name/:ts')->to('traveling#public_status_card');
|
||||
$r->get('/p/:name')->to('traveling#public_profile');
|
||||
$r->get('/p/:name/j/:id')->to('traveling#public_journey_details');
|
||||
$r->post('/api/v1/import')->to('api#import_v1');
|
||||
$r->post('/api/v1/travel')->to('api#travel_v1');
|
||||
$r->post('/action')->to('traveling#log_action');
|
||||
|
|
|
@ -146,6 +146,94 @@ sub user_status {
|
|||
}
|
||||
}
|
||||
|
||||
sub public_profile {
|
||||
my ($self) = @_;
|
||||
|
||||
my $name = $self->stash('name');
|
||||
my $user = $self->users->get_privacy_by_name( name => $name );
|
||||
|
||||
if (
|
||||
$user
|
||||
and ( $user->{public_level} & 0x22
|
||||
or
|
||||
( $user->{public_level} & 0x11 and $self->is_user_authenticated ) )
|
||||
)
|
||||
{
|
||||
my $status = $self->get_user_status( $user->{id} );
|
||||
$self->render(
|
||||
'profile',
|
||||
name => $name,
|
||||
uid => $user->{id},
|
||||
public_level => $user->{public_level},
|
||||
journey => $status,
|
||||
version => $self->app->config->{version} // 'UNKNOWN',
|
||||
);
|
||||
}
|
||||
else {
|
||||
$self->render('not_found');
|
||||
}
|
||||
}
|
||||
|
||||
sub public_journey_details {
|
||||
my ($self) = @_;
|
||||
my $name = $self->stash('name');
|
||||
my $journey_id = $self->stash('id');
|
||||
my $user = $self->users->get_privacy_by_name( name => $name );
|
||||
|
||||
$self->param( journey_id => $journey_id );
|
||||
|
||||
if ( not( $journey_id and $journey_id =~ m{ ^ \d+ $ }x ) ) {
|
||||
$self->render(
|
||||
'journey',
|
||||
status => 404,
|
||||
error => 'notfound',
|
||||
journey => {}
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
$user
|
||||
and ( $user->{public_level} & 0x20
|
||||
or
|
||||
( $user->{public_level} & 0x10 and $self->is_user_authenticated ) )
|
||||
)
|
||||
{
|
||||
my $journey = $self->journeys->get_single(
|
||||
uid => $user->{id},
|
||||
journey_id => $journey_id,
|
||||
verbose => 1,
|
||||
with_datetime => 1,
|
||||
with_polyline => 1,
|
||||
);
|
||||
|
||||
if ($journey) {
|
||||
my $map_data = $self->journeys_to_map_data(
|
||||
journeys => [$journey],
|
||||
include_manual => 1,
|
||||
);
|
||||
if ( $journey->{user_data}{comment} ) {
|
||||
delete $journey->{user_data}{comment};
|
||||
}
|
||||
$self->render(
|
||||
'journey',
|
||||
error => undef,
|
||||
journey => $journey,
|
||||
with_map => 1,
|
||||
username => $name,
|
||||
readonly => 1,
|
||||
%{$map_data},
|
||||
);
|
||||
}
|
||||
else {
|
||||
$self->render( 'not_found', );
|
||||
}
|
||||
}
|
||||
else {
|
||||
$self->render('not_found');
|
||||
}
|
||||
}
|
||||
|
||||
sub public_status_card {
|
||||
my ($self) = @_;
|
||||
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
<tbody>
|
||||
% for my $travel (@{$journeys}) {
|
||||
% my $detail_link = '/journey/' . $travel->{id};
|
||||
% if (my $prefix = stash('link_prefix')) {
|
||||
% $detail_link = $prefix . $travel->{id};
|
||||
% }
|
||||
<tr>
|
||||
<td><%= $travel->{sched_departure}->strftime($date_format) %></td>
|
||||
<td><a href="<%= $detail_link %>"><%= $travel->{type} %> <%= $travel->{line} // $travel->{no} %></a></td>
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
<span style="color: #999999;">Keine</span>
|
||||
% }
|
||||
% if ($acc->{is_public} & 0x01) {
|
||||
Aktueller Status (nur für angemeldete Accounts)
|
||||
Aktueller Status (nur mit Anmeldung)
|
||||
% }
|
||||
% elsif ($acc->{is_public} & 0x02) {
|
||||
Aktueller Status
|
||||
|
@ -79,10 +79,10 @@
|
|||
<br/>
|
||||
% }
|
||||
% if ($acc->{is_public} & 0x10) {
|
||||
Letzte zehn Fahrten (nur für angemeldete Accounts)
|
||||
Vergangene Fahrten (nur mit Anmeldung)
|
||||
% }
|
||||
% elsif ($acc->{is_public} & 0x20) {
|
||||
Letzte zehn Fahrten
|
||||
Vergangene Fahrten
|
||||
% }
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
<div class="row">
|
||||
<div class="col s12">
|
||||
<p>
|
||||
% if (my $name = stash('username')) {
|
||||
<b><a href="/p/<%= $name %>"><%= $name %></a></b>s
|
||||
% }
|
||||
% if ($journey->{cancelled}) {
|
||||
Ausgefallene Fahrt
|
||||
% }
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<div class="input-field col s12">
|
||||
<label>
|
||||
%= radio_button status_level => 'intern'
|
||||
<span>Nur für angemeldete Accounts</span>
|
||||
<span>Nur mit Anmeldung</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -37,7 +37,8 @@
|
|||
<div class="row">
|
||||
<div class="col s12">
|
||||
Hier kannst du auswählen, ob dein aktueller Status unter <a
|
||||
href="/status/<%= $name %>">/status/<%= $name %></a> abrufbar ist.
|
||||
href="/status/<%= $name %>">/status/<%= $name %></a> sowie <a
|
||||
href="/p/<%= $name %>">/p/<%= $name %></a> abrufbar ist.
|
||||
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,
|
||||
|
@ -74,7 +75,7 @@
|
|||
<div class="input-field col s12">
|
||||
<label>
|
||||
%= radio_button history_level => 'intern'
|
||||
<span>Nur für angemeldete Accounts</span>
|
||||
<span>Nur mit Anmeldung</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -88,14 +89,13 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
Diese Einstellung bestimmt die Sichtbarkeit deiner letzten
|
||||
zehn Zugfahrten mit allen dazu bekannten Details (Abfahrt, Ankunft,
|
||||
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.
|
||||
Diese Einstellung bestimmt die Sichtbarkeit deiner vergangenen
|
||||
Zugfahrten mit allen dazu bekannten Details (Abfahrt, Ankunft,
|
||||
Wagenreihung u.a.). Die letzten zehn Fahrten werden unter <a
|
||||
href="/p/<%= $name %>">/p/<%= $name %></a> aufgelistet und verlinkt,
|
||||
ältere Fahrten sind jedoch weiterhin über /p/<%= $name %>/j/ID
|
||||
zugänglich. Da die ID (mit Lücken) aufsteigend vergeben wird, sind
|
||||
effektiv alle deiner vergangenen Fahrten öffentlich.
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
|
29
templates/profile.html.ep
Normal file
29
templates/profile.html.ep
Normal file
|
@ -0,0 +1,29 @@
|
|||
% if (stash('error')) {
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<div class="card caution-color">
|
||||
<div class="card-content white-text">
|
||||
<span class="card-title">Fehler</span>
|
||||
<p><%= stash('error') %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
% }
|
||||
% if ($public_level & 0x02 or ($public_level & 0x01 and is_user_authenticated())) {
|
||||
<div class="row">
|
||||
<div class="col s12 publicstatuscol" data-user="<%= $name %>">
|
||||
%= include '_public_status_card', name => $name, public_level => $public_level, journey => $journey
|
||||
</div>
|
||||
</div>
|
||||
% }
|
||||
% if ($public_level & 0x20 or ($public_level & 0x10 and is_user_authenticated())) {
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<h2>Letzte Fahrten von <%= $name %></h1>
|
||||
</div>
|
||||
</div>
|
||||
%= include '_history_trains', date_format => '%d.%m.%Y', link_prefix => "/p/${name}/j/", journeys => [journeys->get(uid => $uid, limit => 10, with_datetime => 1)];
|
||||
% }
|
||||
|
||||
%= include '_footer', version => stash('version')
|
Loading…
Reference in a new issue