journey: add share button
This commit is contained in:
parent
1e1c71cfd8
commit
978c7b03c2
3 changed files with 51 additions and 5 deletions
|
@ -2155,7 +2155,8 @@ sub startup {
|
||||||
$r->get('/ajax/status/#name')->to('traveling#public_status_card');
|
$r->get('/ajax/status/#name')->to('traveling#public_status_card');
|
||||||
$r->get('/ajax/status/:name/:ts')->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')->to('traveling#public_profile');
|
||||||
$r->get('/p/:name/j/:id')->to('traveling#public_journey_details');
|
$r->get( '/p/:name/j/:id' => 'public_journey' )
|
||||||
|
->to('traveling#public_journey_details');
|
||||||
$r->get('/.well-known/webfinger')->to('account#webfinger');
|
$r->get('/.well-known/webfinger')->to('account#webfinger');
|
||||||
$r->post('/api/v1/import')->to('api#import_v1');
|
$r->post('/api/v1/import')->to('api#import_v1');
|
||||||
$r->post('/api/v1/travel')->to('api#travel_v1');
|
$r->post('/api/v1/travel')->to('api#travel_v1');
|
||||||
|
|
|
@ -1677,7 +1677,8 @@ sub journey_details {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my $journey_id = $self->stash('id');
|
my $journey_id = $self->stash('id');
|
||||||
|
|
||||||
my $uid = $self->current_user->{id};
|
my $user = $self->current_user;
|
||||||
|
my $uid = $user->{id};
|
||||||
|
|
||||||
$self->param( journey_id => $journey_id );
|
$self->param( journey_id => $journey_id );
|
||||||
|
|
||||||
|
@ -1704,11 +1705,41 @@ sub journey_details {
|
||||||
journeys => [$journey],
|
journeys => [$journey],
|
||||||
include_manual => 1,
|
include_manual => 1,
|
||||||
);
|
);
|
||||||
|
my $share_text;
|
||||||
|
my $with_share = $user->{is_public} & 0x40 ? 1 : 0;
|
||||||
|
if ( not $with_share and $user->{is_public} & 0x20 ) {
|
||||||
|
my $month_ago = DateTime->now( time_zone => 'Europe/Berlin' )
|
||||||
|
->subtract( weeks => 4 )->epoch;
|
||||||
|
$with_share = $journey->{rt_dep_ts} > $month_ago ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($with_share) {
|
||||||
|
my $delay = 'pünktlich ';
|
||||||
|
if ( $journey->{rt_arrival} != $journey->{sched_arrival} ) {
|
||||||
|
$delay = sprintf(
|
||||||
|
'mit %+d ',
|
||||||
|
(
|
||||||
|
$journey->{rt_arrival}->epoch
|
||||||
|
- $journey->{sched_arrival}->epoch
|
||||||
|
) / 60
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$share_text
|
||||||
|
= $journey->{km_route}
|
||||||
|
? sprintf( '%.0f km', $journey->{km_route} )
|
||||||
|
: 'Fahrt';
|
||||||
|
$share_text .= sprintf( ' mit %s %s – Ankunft %sum %s',
|
||||||
|
$journey->{type}, $journey->{no},
|
||||||
|
$delay, $journey->{rt_arrival}->strftime('%H:%M') );
|
||||||
|
}
|
||||||
|
|
||||||
$self->render(
|
$self->render(
|
||||||
'journey',
|
'journey',
|
||||||
error => undef,
|
error => undef,
|
||||||
journey => $journey,
|
journey => $journey,
|
||||||
with_map => 1,
|
with_map => 1,
|
||||||
|
with_share => $with_share,
|
||||||
|
share_text => $share_text,
|
||||||
%{$map_data},
|
%{$map_data},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,6 +230,20 @@
|
||||||
%= include '_map', station_coordinates => stash('station_coordinates'), polyline_groups => stash('polyline_groups')
|
%= include '_map', station_coordinates => stash('station_coordinates'), polyline_groups => stash('polyline_groups')
|
||||||
% }
|
% }
|
||||||
% if (not stash('readonly')) {
|
% if (not stash('readonly')) {
|
||||||
|
% if (stash('with_share')) {
|
||||||
|
<div class="row">
|
||||||
|
<div class="col s12 m6 l6">
|
||||||
|
</div>
|
||||||
|
<div class="col s12 m6 l6 center-align">
|
||||||
|
<a class="btn waves-effect waves-light action-share"
|
||||||
|
data-url="<%= url_for('public_journey', name => current_user()->{name}, id => $journey->{id} )->to_abs->scheme('https'); %>"
|
||||||
|
data-text="<%= stash('share_text') %>"
|
||||||
|
>
|
||||||
|
<i class="material-icons left" aria-hidden="true">share</i> Teilen
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
% }
|
||||||
<div class="row hide-on-small-only">
|
<div class="row hide-on-small-only">
|
||||||
<div class="col s12 m6 l6 center-align">
|
<div class="col s12 m6 l6 center-align">
|
||||||
<a class="waves-effect waves-light red btn action-delete"
|
<a class="waves-effect waves-light red btn action-delete"
|
||||||
|
|
Loading…
Reference in a new issue