From 9b256f0f0245e597f21823b7078ee1f17fa9911c Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Sat, 15 Jun 2024 17:50:56 +0200 Subject: remove service / sb_template selection; hardcode DBF with variable hafas flag --- lib/Travelynx.pm | 3 +- lib/Travelynx/Controller/Account.pm | 23 ---------- lib/Travelynx/Model/Users.pm | 39 ++--------------- templates/_checked_in.html.ep | 25 ++--------- templates/account.html.ep | 15 ------- templates/use_external_links.html.ep | 82 ------------------------------------ 6 files changed, 8 insertions(+), 179 deletions(-) delete mode 100644 templates/use_external_links.html.ep diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index ec17090..e8d3902 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -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'); diff --git a/lib/Travelynx/Controller/Account.pm b/lib/Travelynx/Controller/Account.pm index f1dc43e..5c101b1 100644 --- a/lib/Travelynx/Controller/Account.pm +++ b/lib/Travelynx/Controller/Account.pm @@ -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) = @_; diff --git a/lib/Travelynx/Model/Users.pm b/lib/Travelynx/Model/Users.pm index 1154a02..4d90d92 100644 --- a/lib/Travelynx/Model/Users.pm +++ b/lib/Travelynx/Model/Users.pm @@ -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; diff --git a/templates/_checked_in.html.ep b/templates/_checked_in.html.ep index b42792e..19a94bb 100644 --- a/templates/_checked_in.html.ep +++ b/templates/_checked_in.html.ep @@ -111,12 +111,7 @@ % }
- % if ($user->{sb_template}) { - <%= $journey->{arr_name} %>
- % } - % else { - <%= $journey->{arr_name} %>
- % } + <%= $journey->{arr_name} %>
% if ($journey->{real_arrival}->epoch) { <%= $journey->{real_arrival}->strftime('%H:%M') %> % if ($journey->{real_arrival}->epoch != $journey->{sched_arrival}->epoch) { @@ -358,12 +353,7 @@
Ziel ändern? - % if ($user->{sb_template}) { -
- % } - % else { -

- % } +

% for my $station (@{$journey->{route_after}}) { % my $is_dest = ($journey->{arr_name} and $station->[0] eq $journey->{arr_name}); @@ -387,16 +377,9 @@ % } - % if ($user->{sb_template}) { - train - % } - % } - % if ($user->{sb_template}) { -
- % } - % else { -

+ <%= $journey->{is_hafas} ? 'directions' : 'train' %> % } +
diff --git a/templates/account.html.ep b/templates/account.html.ep index 7f689c2..036fb35 100644 --- a/templates/account.html.ep +++ b/templates/account.html.ep @@ -28,9 +28,6 @@ % elsif ($success eq 'use_history') { Einstellungen zu vorgeschlagenen Verbindungen geändert % } - % elsif ($success eq 'external') { - Einstellungen zu externen Diensten geändert - % } % elsif ($success eq 'webhook') { Web Hook aktualisiert % } @@ -151,18 +148,6 @@ % } - - Externe Dienste - - edit - % if ($acc->{sb_name}) { - Abfahrtstafel: <%= $acc->{sb_name} %> - % } - % else { - Keine - % } - - Registriert am <%= $acc->{registered_at}->strftime('%d.%m.%Y %H:%M') %> diff --git a/templates/use_external_links.html.ep b/templates/use_external_links.html.ep deleted file mode 100644 index 77dfd44..0000000 --- a/templates/use_external_links.html.ep +++ /dev/null @@ -1,82 +0,0 @@ -

Externe Dienste

-
-
-

- 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. -

-

-
-

Abfahrtstafel

-%= form_for '/account/services' => (method => 'POST') => begin - %= csrf_field -
-
- Angaben zu anderen an einer Station verkehrenden Verkehrsmitteln -
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-%= end -- cgit v1.2.3