aboutsummaryrefslogtreecommitdiffstats
path: root/lib/MGA/Mirrors/Controller
diff options
context:
space:
mode:
authorOlivier Thauvin <nanardon@mageia.org>2010-10-02 13:31:35 +0000
committerOlivier Thauvin <nanardon@mageia.org>2010-10-02 13:31:35 +0000
commita9ade04230fc99e5d12e7bd1af1e2dd31907d15a (patch)
tree32f25d1699e483eb219400e44e2e96d782feb7ea /lib/MGA/Mirrors/Controller
parent6f42c4ffb976cdffa257a09e4dcb33119750abfc (diff)
downloadmgamirrors-a9ade04230fc99e5d12e7bd1af1e2dd31907d15a.tar
mgamirrors-a9ade04230fc99e5d12e7bd1af1e2dd31907d15a.tar.gz
mgamirrors-a9ade04230fc99e5d12e7bd1af1e2dd31907d15a.tar.bz2
mgamirrors-a9ade04230fc99e5d12e7bd1af1e2dd31907d15a.tar.xz
mgamirrors-a9ade04230fc99e5d12e7bd1af1e2dd31907d15a.zip
- handle distributions, protocol andothers things
Diffstat (limited to 'lib/MGA/Mirrors/Controller')
-rw-r--r--lib/MGA/Mirrors/Controller/Distrib.pm48
-rw-r--r--lib/MGA/Mirrors/Controller/Mirrors.pm66
-rw-r--r--lib/MGA/Mirrors/Controller/New.pm13
3 files changed, 123 insertions, 4 deletions
diff --git a/lib/MGA/Mirrors/Controller/Distrib.pm b/lib/MGA/Mirrors/Controller/Distrib.pm
new file mode 100644
index 0000000..0d49e55
--- /dev/null
+++ b/lib/MGA/Mirrors/Controller/Distrib.pm
@@ -0,0 +1,48 @@
+package MGA::Mirrors::Controller::Distrib;
+use Moose;
+use namespace::autoclean;
+
+BEGIN {extends 'Catalyst::Controller'; }
+
+=head1 NAME
+
+MGA::Mirrors::Controller::Distrib - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+=cut
+
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
+
+}
+
+sub list :Path :Args(1) {
+ my ( $self, $c ) = @_;
+ $c->stash->{current_view} = 'TTBlock';
+ $c->stash->{template} = 'distrib/distrib.tt';
+}
+
+=head1 AUTHOR
+
+Olivier Thauvin
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+1;
diff --git a/lib/MGA/Mirrors/Controller/Mirrors.pm b/lib/MGA/Mirrors/Controller/Mirrors.pm
new file mode 100644
index 0000000..5d07ca5
--- /dev/null
+++ b/lib/MGA/Mirrors/Controller/Mirrors.pm
@@ -0,0 +1,66 @@
+package MGA::Mirrors::Controller::Mirrors;
+use Moose;
+use namespace::autoclean;
+
+BEGIN {extends 'Catalyst::Controller'; }
+
+=head1 NAME
+
+MGA::Mirrors::Controller::Mirrors - Catalyst Controller
+
+=head1 DESCRIPTION
+
+Catalyst Controller.
+
+=head1 METHODS
+
+=cut
+
+
+=head2 index
+
+=cut
+
+sub index :Path :Args(0) {
+ my ( $self, $c ) = @_;
+
+ $c->response->body('Matched MGA::Mirrors::Controller::Mirrors in Mirrors.');
+}
+
+sub mirror :Path :Args(1) {
+ my ( $self, $c, $host ) = @_;
+ $c->stash->{hostname} = $host;
+
+ if ($c->req->param('hostinfo')) {
+ my $hinfo = $c->model('Mirrors')->find_mirrors({
+ hostname => $host,
+ })->[0];
+ if (! $hinfo->{readonly}) {
+ $c->model('Mirrors')->add_or_update_host($host,
+ bandwidth => $c->req->param('bandwidth'),
+ city => $c->req->param('city'),
+ country => $c->req->param('country'),
+ syncfrom=> $c->req->param('syncfrom'),
+ );
+ }
+ }
+
+ $c->stash->{host} = $c->model('Mirrors')->find_mirrors({
+ hostname => $host,
+ })->[0];
+}
+
+=head1 AUTHOR
+
+Olivier Thauvin
+
+=head1 LICENSE
+
+This library is free software. You can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=cut
+
+__PACKAGE__->meta->make_immutable;
+
+1;
diff --git a/lib/MGA/Mirrors/Controller/New.pm b/lib/MGA/Mirrors/Controller/New.pm
index fbb1fbe..d3ec38c 100644
--- a/lib/MGA/Mirrors/Controller/New.pm
+++ b/lib/MGA/Mirrors/Controller/New.pm
@@ -44,8 +44,10 @@ sub index :Path :Args(0) {
hostname => $uri->host, });
if (@{$urls || []}) {
$c->stash->{exists_url} = $urls;
- $c->stash->{subtemplate} = 'new/mirror_exists.tt';
- return;
+ if ($urls->[0]->{valid}) {
+ $c->stash->{subtemplate} = 'new/mirror_exists.tt';
+ return;
+ }
}
if (!$c->model('Mirrors')->mirror_validity($uri)) {
@@ -62,17 +64,18 @@ sub index :Path :Args(0) {
my @ips = $c->model('Mirrors')->host_ips($uri->host);
$c->stash->{location} = $c->model('Mirrors')->locate_ips(@ips);
+ $c->stash->{host}{country} = $c->stash->{location}{code};
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)) {
+ foreach (qw(city country syncfrom bandwidth)) {
$c->session->{hostinfo}{$_} = $c->req->param($_);
}
} else {
- $c->stash->{subtemplate} = 'new/host_information.tt';
+ $c->stash->{subtemplate} = 'new/new_host.tt';
return;
}
@@ -94,6 +97,8 @@ sub confirm :Path :Args(1) {
$uri->host,
city => $c->session->{hostinfo}{city},
country => $c->session->{hostinfo}{country},
+ bandwidth => $c->session->{hostinfo}{bandwidth},
+ syncfrom => $c->session->{hostinfo}{syncfrom},
);
} else {
return;