| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::VideoHost; |
|
2
|
|
|
|
|
|
|
{ |
|
3
|
|
|
|
|
|
|
$App::VideoHost::VERSION = '0.143300'; # TRIAL |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
675
|
use Mojo::Base 'Mojolicious'; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
7
|
1
|
|
|
1
|
|
97778
|
use App::VideoHost::Video::Storage; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use File::Basename 'dirname'; |
|
10
|
|
|
|
|
|
|
use File::Spec::Functions 'catdir'; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
App::VideoHost - filesystem based personal video hosting |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# This method will run once at server start |
|
19
|
|
|
|
|
|
|
sub startup { |
|
20
|
|
|
|
|
|
|
my $self = shift; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Switch to installable home directory |
|
23
|
|
|
|
|
|
|
$self->home->parse(catdir(dirname(__FILE__), 'VideoHost')); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Switch to installable "public" directory |
|
26
|
|
|
|
|
|
|
$self->static->paths->[0] = $self->home->rel_dir('public'); |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Switch to installable "templates" directory |
|
29
|
|
|
|
|
|
|
$self->renderer->paths->[0] = $self->home->rel_dir('templates'); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Load config |
|
32
|
|
|
|
|
|
|
$self->plugin('Config'); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# configure logging |
|
35
|
|
|
|
|
|
|
if ($self->config->{log}->{path}) { |
|
36
|
|
|
|
|
|
|
$self->log(Mojo::Log->new(path => $self->config->{log}->{path}, level => $self->config->{log}->{level} || 'info')); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Router |
|
40
|
|
|
|
|
|
|
my $r = $self->routes; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Set namespace, to support older Mojolicious versions where this was |
|
43
|
|
|
|
|
|
|
# not the default |
|
44
|
|
|
|
|
|
|
$r->namespaces(['App::VideoHost::Controller']); |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# Normal route to controller |
|
47
|
|
|
|
|
|
|
$r->get('/')->to('root#index'); |
|
48
|
|
|
|
|
|
|
$r->get('/video/:short_name')->to('root#video_stream')->name('video'); |
|
49
|
|
|
|
|
|
|
$r->get('/poster/:short_name')->to('root#poster')->name('poster'); |
|
50
|
|
|
|
|
|
|
$r->get('/tracks/:short_name')->to('root#tracks')->name('tracks'); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
$self->helper(videos => sub { |
|
53
|
|
|
|
|
|
|
my $self = shift; |
|
54
|
|
|
|
|
|
|
state $videos = App::VideoHost::Video::Storage->new(directory => $self->config->{ video_directory }); |
|
55
|
|
|
|
|
|
|
return $videos; |
|
56
|
|
|
|
|
|
|
}); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |