diff options
Diffstat (limited to 'lib/MGA/Mirrors/Controller/New.pm')
-rw-r--r-- | lib/MGA/Mirrors/Controller/New.pm | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/MGA/Mirrors/Controller/New.pm b/lib/MGA/Mirrors/Controller/New.pm index d3ec38c..bf4fa59 100644 --- a/lib/MGA/Mirrors/Controller/New.pm +++ b/lib/MGA/Mirrors/Controller/New.pm @@ -43,7 +43,7 @@ sub index :Path :Args(0) { { protocol => $uri->scheme, hostname => $uri->host, }); if (@{$urls || []}) { - $c->stash->{exists_url} = $urls; + $c->stash->{exists_url} = $urls->[0]; if ($urls->[0]->{valid}) { $c->stash->{subtemplate} = 'new/mirror_exists.tt'; return; @@ -57,6 +57,18 @@ sub index :Path :Args(0) { if (my @overlap_hosts = $c->model('Mirrors')->find_host_ip_overlap($uri->host)) { $c->stash->{overlap_hosts} = \@overlap_hosts; + if (@overlap_hosts == 1) { + my $maybeurl = $c->model('Mirrors')->find_urls({ + protocol => $uri->scheme, + hostname => $overlap_hosts[0] + }); + if (!@{$maybeurl || []}) { + my $totryurl = $uri->clone; + $totryurl->host($overlap_hosts[0]); + $c->stash->{urlmaybe} = $totryurl; + $c->req->params->{url} = $totryurl; + } + } $c->stash->{subtemplate} = 'new/overlap_hosts.tt'; return; } @@ -65,17 +77,19 @@ sub index :Path :Args(0) { $c->stash->{location} = $c->model('Mirrors')->locate_ips(@ips); $c->stash->{host}{country} = $c->stash->{location}{code}; + $c->stash->{host}{latitude} = $c->stash->{location}{latitude}; + $c->stash->{host}{longitude} = $c->stash->{location}{longitude}; my $mirror = $c->model('Mirrors')->find_mirrors( { hostname => $uri->host, }); if (@{ $mirror || []}) { $c->stash->{mirror} = $mirror->[0]; } elsif ($c->req->param('hostinfo')) { - foreach (qw(city country syncfrom bandwidth)) { + foreach (qw(city country syncfrom bandwidth latitude longitude)) { $c->session->{hostinfo}{$_} = $c->req->param($_); } } else { - $c->stash->{subtemplate} = 'new/new_host.tt'; + $c->stash->{template} = 'new/new_host.tt'; return; } @@ -99,6 +113,8 @@ sub confirm :Path :Args(1) { country => $c->session->{hostinfo}{country}, bandwidth => $c->session->{hostinfo}{bandwidth}, syncfrom => $c->session->{hostinfo}{syncfrom}, + latitude => $c->session->{hostinfo}{latitude}, + longitude => $c->session->{hostinfo}{longitude}, ); } else { return; |