1 | package Sophie::Controller::Explorer; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | |
---|
5 | BEGIN {extends 'Catalyst::Controller'; } |
---|
6 | |
---|
7 | =head1 NAME |
---|
8 | |
---|
9 | Sophie::Controller::Explorer - Catalyst Controller |
---|
10 | |
---|
11 | =head1 DESCRIPTION |
---|
12 | |
---|
13 | Catalyst Controller. |
---|
14 | |
---|
15 | =head1 METHODS |
---|
16 | |
---|
17 | =cut |
---|
18 | |
---|
19 | |
---|
20 | =head2 index |
---|
21 | |
---|
22 | =cut |
---|
23 | |
---|
24 | sub 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 | |
---|
60 | Olivier Thauvin |
---|
61 | |
---|
62 | =head1 LICENSE |
---|
63 | |
---|
64 | This library is free software. You can redistribute it and/or modify |
---|
65 | it under the same terms as Perl itself. |
---|
66 | |
---|
67 | =cut |
---|
68 | |
---|
69 | __PACKAGE__->meta->make_immutable; |
---|
70 | |
---|
71 | 1; |
---|