summaryrefslogtreecommitdiff
path: root/lib/Travelynx
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2020-09-21 20:15:01 +0200
committerDaniel Friesel <derf@finalrewind.org>2020-09-21 20:15:01 +0200
commit362db912fa41a04afff6ac96acbe388149aafeb0 (patch)
tree0adb3dd535077a50dd89e6976498cea019fc9313 /lib/Travelynx
parent870e4333a82e8cbc28f3d182564ee29cc83c74ed (diff)
add twitter card to public journey view
Diffstat (limited to 'lib/Travelynx')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 24edaa3..64a0507 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -236,6 +236,21 @@ sub public_journey_details {
}
if ($journey) {
+ 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 am %s',
+ $journey->{from_name}, $journey->{to_name},
+ $journey->{rt_arrival}->strftime('%d.%m.%Y') );
+ $tw_data{description} = sprintf( 'Ankunft mit %s %s %s',
+ $journey->{type}, $journey->{no},
+ $journey->{rt_arrival}->strftime('um %H:%M') );
+ }
my $map_data = $self->journeys_to_map_data(
journeys => [$journey],
include_manual => 1,
@@ -252,6 +267,7 @@ sub public_journey_details {
with_map => 1,
username => $name,
readonly => 1,
+ twitter => \%tw_data,
%{$map_data},
);
}