-
Notifications
You must be signed in to change notification settings - Fork 28
/
Photos.pm
58 lines (37 loc) · 937 Bytes
/
Photos.pm
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
package MojoFull::Photos;
use Mojo::Base 'Mojolicious::Controller';
sub index {
my $self = shift;
$self->render(
'photos/index',
sets => [$self->db->resultset('Photoset')->search],
photo_count => $self->db->resultset('Photo')->count
);
}
sub show {
my $self = shift;
my $id = $self->param('id');
my $photo = $self->db->resultset('Photo')->find($id)
or $self->redirect_to('photos'), return;
$self->render(template => 'photos/show', photo => $photo);
}
sub show_set {
my $self = shift;
my $id = $self->param('id');
my $set = $self->db->resultset('Photoset')->by_id_or_name($id)
or $self->redirect_to('photos'), return;
$self->render(template => 'photos/show_set', set => $set);
}
1;
=head1 NAME
MojoFull::Photos
=head1 DESCRIPTION
/photos controller
=head1 ACTIONS
=head2 index
GET /photos
=head2 show
GET /photos/:photo_id
=head2 show_set
GET /photos/:set_id
=cut