remove service / sb_template selection; hardcode DBF with variable hafas flag

This commit is contained in:
Birte Kristina Friesel 2024-06-15 17:50:56 +02:00
parent b00c3698b2
commit 9b256f0f02
No known key found for this signature in database
GPG key ID: 19E6E524EBB177BA
6 changed files with 8 additions and 179 deletions

View file

@ -1551,6 +1551,7 @@ sub startup {
$ret =~ s{[{]tt[}]}{$opt{tt}}g;
$ret =~ s{[{]tn[}]}{$opt{tn}}g;
$ret =~ s{[{]id[}]}{$opt{id}}g;
$ret =~ s{[{]hafas[}]}{$opt{hafas}}g;
return $ret;
}
);
@ -2469,7 +2470,6 @@ sub startup {
$authed_r->get('/account/hooks')->to('account#webhook');
$authed_r->get('/account/traewelling')->to('traewelling#settings');
$authed_r->get('/account/insight')->to('account#insight');
$authed_r->get('/account/services')->to('account#services');
$authed_r->get('/ajax/status_card.html')->to('traveling#status_card');
$authed_r->get('/cancelled')->to('traveling#cancelled');
$authed_r->get('/fgr')->to('passengerrights#list_candidates');
@ -2497,7 +2497,6 @@ sub startup {
$authed_r->post('/account/hooks')->to('account#webhook');
$authed_r->post('/account/traewelling')->to('traewelling#settings');
$authed_r->post('/account/insight')->to('account#insight');
$authed_r->post('/account/services')->to('account#services');
$authed_r->post('/journey/add')->to('traveling#add_journey_form');
$authed_r->post('/journey/comment')->to('traveling#comment_form');
$authed_r->post('/journey/visibility')->to('traveling#visibility_form');

View file

@ -831,29 +831,6 @@ sub insight {
}
sub services {
my ($self) = @_;
my $user = $self->current_user;
if ( $self->param('action') and $self->param('action') eq 'save' ) {
my $sb = $self->param('stationboard');
my $value = 0;
if ( $sb =~ m{ ^ \d+ $ }x and $sb >= 0 and $sb <= 4 ) {
$value = int($sb);
}
$self->users->use_external_services(
uid => $user->{id},
set => $value
);
$self->flash( success => 'external' );
$self->redirect_to('account');
}
$self->param( stationboard =>
$self->users->use_external_services( uid => $user->{id} ) );
$self->render('use_external_links');
}
sub webhook {
my ($self) = @_;

View file

@ -40,17 +40,6 @@ my %predicate_atoi = (
is_blocked_by => 3,
);
my @sb_templates = (
undef,
[ 'DBF', 'https://dbf.finalrewind.org/{name}?rt=1#{tt}{tn}' ],
[ 'bahn.expert', 'https://bahn.expert/{name}#{id}' ],
[
'DBF HAFAS',
'https://dbf.finalrewind.org/{name}?rt=1&hafas=DB#{tt}{tn}'
],
[ 'bahn.expert/regional', 'https://bahn.expert/regional/{name}#{id}' ],
);
my %token_id = (
status => 1,
history => 2,
@ -414,7 +403,7 @@ sub get {
my $user = $db->select(
'users',
'id, name, status, public_level, email, '
. 'external_services, accept_follows, notifications, '
. 'accept_follows, notifications, '
. 'extract(epoch from registered_at) as registered_at_ts, '
. 'extract(epoch from last_seen) as last_seen_ts, '
. 'extract(epoch from deletion_requested) as deletion_requested_ts',
@ -438,12 +427,8 @@ sub get {
past_status => $user->{public_level} & 0x08000 ? 1 : 0,
past_all => $user->{public_level} & 0x10000 ? 1 : 0,
email => $user->{email},
sb_name => $user->{external_services}
? $sb_templates[ $user->{external_services} & 0x07 ][0]
: undef,
sb_template => $user->{external_services}
? $sb_templates[ $user->{external_services} & 0x07 ][1]
: undef,
sb_template =>
'https://dbf.finalrewind.org/{name}?rt=1&hafas={hafas}#{tt}{tn}',
registered_at => DateTime->from_epoch(
epoch => $user->{registered_at_ts},
time_zone => 'Europe/Berlin'
@ -662,24 +647,6 @@ sub use_history {
}
}
sub use_external_services {
my ( $self, %opt ) = @_;
my $db = $opt{db} // $self->{pg}->db;
my $uid = $opt{uid};
my $value = $opt{set};
if ( defined $value ) {
if ( $value < 0 or $value > 4 ) {
$value = 0;
}
$db->update( 'users', { external_services => $value }, { id => $uid } );
}
else {
return $db->select( 'users', ['external_services'], { id => $uid } )
->hash->{external_services};
}
}
sub get_webhook {
my ( $self, %opt ) = @_;
my $db = $opt{db} // $self->{pg}->db;

View file

@ -111,12 +111,7 @@
% }
</div>
<div style="float: right; text-align: right;">
% if ($user->{sb_template}) {
<b><a href="<%= resolve_sb_template($user->{sb_template}, name => $journey->{arr_name}, eva => $journey->{arr_eva}, tt => $journey->{train_type} // q{x}, tn => $journey->{train_no}, id => $journey->{train_id}) %>" class="unmarked"><%= $journey->{arr_name} %></a></b><br/>
% }
% else {
<b><%= $journey->{arr_name} %></b><br/>
% }
<b><a href="<%= resolve_sb_template($user->{sb_template}, name => $journey->{arr_name}, eva => $journey->{arr_eva}, tt => $journey->{train_type} // q{x}, tn => $journey->{train_no}, id => $journey->{train_id}, hafas => $journey->{is_hafas} ? $journey->{backend_name} : q{}) %>" class="unmarked"><%= $journey->{arr_name} %></a></b><br/>
% if ($journey->{real_arrival}->epoch) {
<b><%= $journey->{real_arrival}->strftime('%H:%M') %></b>
% if ($journey->{real_arrival}->epoch != $journey->{sched_arrival}->epoch) {
@ -358,12 +353,7 @@
<div class="card-content">
<i class="material-icons small right sync-failed-marker grey-text" style="display: none;">sync_problem</i>
<span class="card-title">Ziel ändern?</span>
% if ($user->{sb_template}) {
<div class="targetlist">
% }
% else {
<p>
% }
% for my $station (@{$journey->{route_after}}) {
% my $is_dest = ($journey->{arr_name} and $station->[0] eq $journey->{arr_name});
<a class="action-checkout tablerow" style="<%= $is_dest? 'font-weight: bold;' : '' %>" data-station="<%= $station->[1] // $station->[0] %>">
@ -387,16 +377,9 @@
% }
</span>
</a>
% if ($user->{sb_template}) {
<a class="nonflex" href="<%= resolve_sb_template($user->{sb_template}, name => $station->[0], eva => $station->[1], tt => $journey->{train_type} // q{x}, tn => $journey->{train_no}, id => $journey->{train_id}) %>"><i class="material-icons tiny">train</i></a>
<a class="nonflex" href="<%= resolve_sb_template($user->{sb_template}, name => $station->[0], eva => $station->[1], tt => $journey->{train_type} // q{x}, tn => $journey->{train_no}, id => $journey->{train_id}, hafas => $journey->{is_hafas} ? $journey->{backend_name} : q{}) %>"><i class="material-icons tiny"><%= $journey->{is_hafas} ? 'directions' : 'train' %></i></a>
% }
% }
% if ($user->{sb_template}) {
</div>
% }
% else {
</p>
% }
</div>
<div class="card-action">
<a class="action-undo blue-text" data-id="in_transit" data-checkints="<%= $journey->{timestamp}->epoch %>" style="margin-right: 0;">

View file

@ -28,9 +28,6 @@
% elsif ($success eq 'use_history') {
<span class="card-title">Einstellungen zu vorgeschlagenen Verbindungen geändert</span>
% }
% elsif ($success eq 'external') {
<span class="card-title">Einstellungen zu externen Diensten geändert</span>
% }
% elsif ($success eq 'webhook') {
<span class="card-title">Web Hook aktualisiert</span>
% }
@ -151,18 +148,6 @@
</td>
</tr>
% }
<tr>
<th scope="row">Externe Dienste</th>
<td>
<a href="/account/services"><i class="material-icons">edit</i></a>
% if ($acc->{sb_name}) {
Abfahrtstafel: <%= $acc->{sb_name} %>
% }
% else {
<span style="color: #999999;">Keine</span>
% }
</td>
</tr>
<tr>
<th scope="row">Registriert am</th>
<td><%= $acc->{registered_at}->strftime('%d.%m.%Y %H:%M') %></td>

View file

@ -1,82 +0,0 @@
<h1>Externe Dienste</h1>
<div class="row">
<div class="col s12">
<p>
Travelynx kann an geeigneten Stellen Links zu externen Diensten
(z.B. Abfahrstafeln oder Informationen zum gerade genutzten Zug)
einbinden. Hier lässt sich konfigurieren, welcher Dienst für welche
Art von Informationen genutzt wird.
<p/>
</div>
</div>
<h2>Abfahrtstafel</h2>
%= form_for '/account/services' => (method => 'POST') => begin
%= csrf_field
<div class="row">
<div class="col s12">
Angaben zu anderen an einer Station verkehrenden Verkehrsmitteln
</div>
</div>
<div class="row">
<div class="input-field col s12">
<div>
<label>
%= radio_button stationboard => '0'
<span>Keine</span>
</label>
</div>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<div>
<label>
%= radio_button stationboard => '1'
<span><a href="https://dbf.finalrewind.org/">DBF</a> (Schienenverkehr)</span>
</label>
</div>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<div>
<label>
%= radio_button stationboard => '2'
<span><a href="https://bahn.expert/">bahn.expert</a> (Schienenverkehr)</span>
</label>
</div>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<div>
<label>
%= radio_button stationboard => '3'
<span><a href="https://dbf.finalrewind.org/?hafas=DB">DBF</a> (Nahverkehr)</span>
</label>
</div>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<div>
<label>
%= radio_button stationboard => '4'
<span><a href="https://bahn.expert/regional">bahn.expert/regional</a> (Nahverkehr)</span>
</label>
</div>
</div>
</div>
<div class="row">
<div class="col s3 m3 l3">
</div>
<div class="col s6 m6 l6 center-align">
<button class="btn waves-effect waves-light" type="submit" name="action" value="save">
Speichern
<i class="material-icons right">send</i>
</button>
</div>
<div class="col s3 m3 l3">
</div>
</div>
%= end