From beb59221e733c6b9afe870aefc1c725baebb85cb Mon Sep 17 00:00:00 2001 From: Molly Miller Date: Mon, 12 Jun 2023 20:46:10 +0200 Subject: [PATCH] Add app version to default stashed values. This means that the version no longer needs to be passed to every version manually, and is automatically populated in templates where the parameter is not explicitly provided. --- lib/Travelynx.pm | 1 + lib/Travelynx/Controller/Profile.pm | 1 - lib/Travelynx/Controller/Static.pm | 6 ++---- lib/Travelynx/Controller/Traveling.pm | 14 -------------- 4 files changed, 3 insertions(+), 19 deletions(-) diff --git a/lib/Travelynx.pm b/lib/Travelynx.pm index 0f602fe..64f721c 100755 --- a/lib/Travelynx.pm +++ b/lib/Travelynx.pm @@ -72,6 +72,7 @@ sub startup { } chomp $self->config->{version}; + $self->defaults(version => $self->config->{version} // 'UNKNOWN'); $self->plugin( authentication => { diff --git a/lib/Travelynx/Controller/Profile.pm b/lib/Travelynx/Controller/Profile.pm index 52742fc..3923773 100755 --- a/lib/Travelynx/Controller/Profile.pm +++ b/lib/Travelynx/Controller/Profile.pm @@ -207,7 +207,6 @@ sub profile { journey => $status, journey_visibility => $visibility, journeys => [@journeys], - version => $self->app->config->{version} // 'UNKNOWN', ); } diff --git a/lib/Travelynx/Controller/Static.pm b/lib/Travelynx/Controller/Static.pm index b5f6d89..0f4b8bd 100644 --- a/lib/Travelynx/Controller/Static.pm +++ b/lib/Travelynx/Controller/Static.pm @@ -8,15 +8,13 @@ use Mojo::Base 'Mojolicious::Controller'; sub about { my ($self) = @_; - $self->render( 'about', - version => $self->app->config->{version} // 'UNKNOWN' ); + $self->render('about'); } sub changelog { my ($self) = @_; - $self->render( 'changelog', - version => $self->app->config->{version} // 'UNKNOWN' ); + $self->render('changelog'); } sub imprint { diff --git a/lib/Travelynx/Controller/Traveling.pm b/lib/Travelynx/Controller/Traveling.pm index d309753..23fb76d 100755 --- a/lib/Travelynx/Controller/Traveling.pm +++ b/lib/Travelynx/Controller/Traveling.pm @@ -398,8 +398,6 @@ sub homepage { my ( $connecting_trains, $transit_fyi ) = @_; $self->render( 'landingpage', - version => $self->app->config->{version} - // 'UNKNOWN', user_status => $status, journey_visibility => $journey_visibility, connections => $connecting_trains, @@ -412,8 +410,6 @@ sub homepage { sub { $self->render( 'landingpage', - version => $self->app->config->{version} - // 'UNKNOWN', user_status => $status, journey_visibility => $journey_visibility, ); @@ -426,7 +422,6 @@ sub homepage { else { $self->render( 'landingpage', - version => $self->app->config->{version} // 'UNKNOWN', user_status => $status, journey_visibility => $journey_visibility, ); @@ -441,7 +436,6 @@ sub homepage { } $self->render( 'landingpage', - version => $self->app->config->{version} // 'UNKNOWN', user_status => $status, recent_targets => \@recent_targets, with_autocomplete => 1, @@ -452,7 +446,6 @@ sub homepage { else { $self->render( 'landingpage', - version => $self->app->config->{version} // 'UNKNOWN', intro => 1 ); } @@ -899,8 +892,6 @@ sub station { can_check_out => $can_check_out, connections => $connecting_trains, title => "travelynx: $status->{station_name}", - version => $self->app->config->{version} - // 'UNKNOWN', ); } )->catch( @@ -915,8 +906,6 @@ sub station { user_status => $user_status, can_check_out => $can_check_out, title => "travelynx: $status->{station_name}", - version => $self->app->config->{version} - // 'UNKNOWN', ); } )->wait; @@ -932,7 +921,6 @@ sub station { user_status => $user_status, can_check_out => $can_check_out, title => "travelynx: $status->{station_name}", - version => $self->app->config->{version} // 'UNKNOWN', ); } } @@ -942,7 +930,6 @@ sub station { if ( ref($err) eq 'HASH' ) { $self->render( 'landingpage', - version => $self->app->config->{version} // 'UNKNOWN', with_autocomplete => 1, with_geolocation => 1, error => $err->{errstr}, @@ -1296,7 +1283,6 @@ sub year_in_review { $self->render( 'year_in_review', - version => $self->app->config->{version} // 'UNKNOWN', title => "travelynx Jahresrückblick $year", year => $year, stats => $stats,