summaryrefslogtreecommitdiff
path: root/lib/DBInfoscreen/Controller/Static.pm
blob: c25c6c5f3d364da0a62dad77b357f3c171e612ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package DBInfoscreen::Controller::Static;

# Copyright (C) 2011-2020 Daniel Friesel
#
# SPDX-License-Identifier: AGPL-3.0-or-later

use Mojo::Base 'Mojolicious::Controller';

my %default = (
	mode   => 'app',
	admode => 'deparr',
);

sub redirect {
	my ($self) = @_;
	my $input  = $self->param('input');
	my $params = $self->req->params;

	$params->remove('input');

	for my $param (qw(platforms mode admode via)) {
		if (
			not $params->param($param)
			or ( exists $default{$param}
				and $params->param($param) eq $default{$param} )
		  )
		{
			$params->remove($param);
		}
	}

	$params = $params->to_string;

	if ( $input =~ m{ ^ [a-zA-Z]{1,5} \s+ \d+ $ }x ) {
		$self->redirect_to("/z/${input}?${params}");
	}
	else {
		$self->redirect_to("/${input}?${params}");
	}
}

sub geolocation {
	my ($self) = @_;

	$self->render(
		'geolocation',
		with_geolocation => 1,
		hide_opts        => 1
	);
}

sub about {
	my ($self) = @_;

	$self->render(
		'about',
		hide_opts => 1,
		version   => $self->config->{version}
	);
}

sub privacy {
	my ($self) = @_;

	$self->render( 'privacy', hide_opts => 1 );
}

sub imprint {
	my ($self) = @_;

	$self->render( 'imprint', hide_opts => 1 );
}

1;