summaryrefslogtreecommitdiff
path: root/lib/Travelynx/Controller
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2019-05-29 18:10:45 +0200
committerDaniel Friesel <derf@finalrewind.org>2019-05-29 18:11:25 +0200
commit146b3a2682c7c91984b15bfa34325558201203ba (patch)
tree7bcbdc2783bb47386ec47b3a2478eac27cac2cfe /lib/Travelynx/Controller
parent22eee81c1c50db24b2ded8fdb65dfb4352506d31 (diff)
add twitter preview tags to public user status page
Diffstat (limited to 'lib/Travelynx/Controller')
-rwxr-xr-xlib/Travelynx/Controller/Traveling.pm31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm
index 20a7e73..de79728 100755
--- a/lib/Travelynx/Controller/Traveling.pm
+++ b/lib/Travelynx/Controller/Traveling.pm
@@ -33,10 +33,39 @@ sub user_status {
if ( $user and ( $user->{public_level} & 0x02 ) ) {
my $status = $self->get_user_status( $user->{id} );
+
+ my %tw_data = (
+ card => 'summary',
+ site => '@derfnull',
+ image => $self->url_for('/static/icons/icon-512x512.png')
+ ->to_abs->scheme('https'),
+ );
+
+ if ( $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}";
+ }
+
$self->render(
'user_status',
name => $name,
- journey => $status
+ journey => $status,
+ twitter => \%tw_data,
);
}
else {