Commit 7f0a644f authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

set version via config

parent 4609b731
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -19,9 +19,7 @@ WORKDIR /app
RUN ln -sf ../ext-templates/imprint.html.ep templates/imprint.html.ep \
	&& ln -sf ../ext-templates/privacy.html.ep templates/privacy.html.ep

RUN find lib -name *.pm | xargs sed -i \
	-e "s/VERSION *= *.*;/VERSION = '${dbf_version}';/" \
	-e "s/dbf_version *= *.*;/dbf_version = '${dbf_version}';/"
RUN sed -i "s/version => \$ENV{DBFAKEDISPLAY_VERSION}.*,/version => '${dbf_version}',/" lib/DBInfoscreen.pm

FROM perl:5.30-slim

+21 −22
Original line number Diff line number Diff line
@@ -20,10 +20,6 @@ use utf8;

no if $] >= 5.018, warnings => 'experimental::smartmatch';

our $VERSION = qx{git describe --dirty} || '0.05';

chomp $VERSION;

my %default = (
	backend => 'iris',
	mode    => 'app',
@@ -33,6 +29,21 @@ my %default = (
sub startup {
	my ($self) = @_;

	$self->config(
		hypnotoad => {
			accepts => $ENV{DBFAKEDISPLAY_ACCEPTS} // 100,
			clients => $ENV{DBFAKEDISPLAY_CLIENTS} // 10,
			listen   => [ $ENV{DBFAKEDISPLAY_LISTEN} // 'http://*:8092' ],
			pid_file => $ENV{DBFAKEDISPLAY_PID_FILE}
			  // '/tmp/db-fakedisplay.pid',
			spare   => $ENV{DBFAKEDISPLAY_SPARE}   // 2,
			workers => $ENV{DBFAKEDISPLAY_WORKERS} // 2,
		},
		version => $ENV{DBFAKEDISPLAY_VERSION} // qx{git describe --dirty} // '???',
	);

	chomp $self->config->{version};

	$self->hook(
		before_dispatch => sub {
			my ($self) = @_;
@@ -118,7 +129,7 @@ sub startup {
				realtime_cache => $self->app->cache_iris_rt,
				root_url       => $self->url_for('/')->to_abs,
				user_agent     => $self->ua,
				version        => $VERSION,
				version        => $self->config->{version},
			);
		}
	);
@@ -132,7 +143,7 @@ sub startup {
				realtime_cache => $self->app->cache_iris_rt,
				root_url       => $self->url_for('/')->to_abs,
				user_agent     => $self->ua,
				version        => $VERSION,
				version        => $self->config->{version},
			);
		}
	);
@@ -146,7 +157,7 @@ sub startup {
				realtime_cache => $self->app->cache_iris_rt,
				root_url       => $self->url_for('/')->to_abs,
				user_agent     => $self->ua,
				version        => $VERSION,
				version        => $self->config->{version},
			);
		}
	);
@@ -211,7 +222,7 @@ sub startup {
				$json = $self->render_to_string(
					json => {
						api_version => $api_version,
						version     => $VERSION,
						version     => $self->config->{version},
						error       => $errstr,
					}
				);
@@ -226,7 +237,7 @@ sub startup {
					$json = $self->render_to_string(
						json => {
							api_version => $api_version,
							version     => $VERSION,
							version     => $self->config->{version},
							error       => 'ambiguous station code/name',
							candidates  => \@candidates,
						}
@@ -236,7 +247,7 @@ sub startup {
					$json = $self->render_to_string(
						json => {
							api_version => $api_version,
							version     => $VERSION,
							version     => $self->config->{version},
							error =>
							  ( $errstr // "Got no results for '$station'" )
						}
@@ -419,18 +430,6 @@ sub startup {
	$r->get('/multi/*station')->to('stationboard#handle_request');
	$r->get('/*station')->to('stationboard#handle_request');

	$self->config(
		hypnotoad => {
			accepts => $ENV{DBFAKEDISPLAY_ACCEPTS} // 100,
			clients => $ENV{DBFAKEDISPLAY_CLIENTS} // 10,
			listen   => [ $ENV{DBFAKEDISPLAY_LISTEN} // 'http://*:8092' ],
			pid_file => $ENV{DBFAKEDISPLAY_PID_FILE}
			  // '/tmp/db-fakedisplay.pid',
			spare   => $ENV{DBFAKEDISPLAY_SPARE}   // 2,
			workers => $ENV{DBFAKEDISPLAY_WORKERS} // 2,
		},
	);

	$self->types->type( json => 'application/json; charset=utf-8' );

}
+0 −4
Original line number Diff line number Diff line
@@ -12,15 +12,11 @@ use DateTime::Format::Strptime;
use Geo::Distance;
use List::Util qw();

my $dbf_version = qx{git describe --dirty} || 'experimental';

my $strp = DateTime::Format::Strptime->new(
	pattern   => '%Y-%m-%dT%H:%M:%S%z',
	time_zone => 'Europe/Berlin',
);

chomp $dbf_version;

sub get_route_indexes {
	my ( $features, $from_name, $to_name ) = @_;
	my ( $from_index, $to_index );
+1 −3
Original line number Diff line number Diff line
@@ -10,8 +10,6 @@ my %default = (
	admode => 'deparr',
);

my $dbf_version = qx{git describe --dirty} || 'experimental';

sub redirect {
	my ($self)  = @_;
	my $station = $self->param('station');
@@ -51,7 +49,7 @@ sub about {
	$self->render(
		'about',
		hide_opts => 1,
		version   => $dbf_version
		version   => $self->config->{version}
	);
}

+3 −7
Original line number Diff line number Diff line
@@ -23,10 +23,6 @@ use utf8;

no if $] >= 5.018, warnings => 'experimental::smartmatch';

my $dbf_version = qx{git describe --dirty} || 'experimental';

chomp $dbf_version;

my %default = (
	backend => 'iris',
	mode    => 'app',
@@ -229,7 +225,7 @@ sub handle_request {

	$self->stash( departures => [] );
	$self->stash( title      => 'DBF' );
	$self->stash( version    => $dbf_version );
	$self->stash( version    => $self->config->{version} );

	if ( not( $template ~~ [qw[app infoscreen json multi single text]] ) ) {
		$template = 'app';
@@ -704,7 +700,7 @@ sub train_details {

	$self->stash( departures => [] );
	$self->stash( title      => 'DBF' );
	$self->stash( version    => $dbf_version );
	$self->stash( version    => $self->config->{version} );

	$opt{datetime} = DateTime->now( time_zone => 'Europe/Berlin' )
	  ->subtract( minutes => 20 );
@@ -1227,7 +1223,7 @@ sub handle_result {
			departures       => \@departures,
			ice_type         => $self->app->ice_type_map,
			station          => $station_name,
			version          => $dbf_version,
			version          => $self->config->{version},
			title            => $via ? "$station_name$via" : $station_name,
			refresh_interval => $template eq 'app' ? 0 : 120,
			hide_opts        => $hide_opts,
Loading