source: server/trunk/web/lib/Sophie/Controller/Explorer.pm @ 422

Last change on this file since 422 was 77, checked in by nanardon, 13 years ago
  • add distrib selection to explorer
File size: 1.5 KB
Line 
1package Sophie::Controller::Explorer;
2use Moose;
3use namespace::autoclean;
4
5BEGIN {extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9Sophie::Controller::Explorer - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub index :Path {
25    my ( $self, $c, @args ) = @_;
26
27    if (grep { exists($c->req->params->{$_}) } qw(distribution release arch)) {
28        $c->session->{explorer} = {
29            distribution => $c->req->param('distribution') || undef,
30            release => $c->req->param('release') || undef,
31            arch => $c->req->param('arch') || undef,
32        };
33    } else {
34        foreach (qw(distribution release arch)) {
35            $c->req->params->{$_} = $c->session->{explorer}{$_}
36        }
37    }
38
39    $c->session->{__explorer} = $c->session->{explorer};
40
41    $c->stash->{path} = join('/', grep { $_  } @args);
42    for(my $i=0; $i < @args; $i++) {
43        push(@{$c->stash->{eachpath}}, { dir=>$args[$i], path =>join('/',
44                    @args[0 .. $i] ) });
45    }
46    $c->stash->{dirurl} = $c->uri_for('/0explorer/dir',
47        $c->stash->{path} ?
48            ($c->stash->{path})
49        : ()
50    );
51    $c->stash->{fileurl} = $c->uri_for('/0explorer/file',
52        $c->stash->{path} ?
53            ($c->stash->{path})
54        : ()
55    );
56}
57
58=head1 AUTHOR
59
60Olivier Thauvin
61
62=head1 LICENSE
63
64This library is free software. You can redistribute it and/or modify
65it under the same terms as Perl itself.
66
67=cut
68
69__PACKAGE__->meta->make_immutable;
70
711;
Note: See TracBrowser for help on using the repository browser.