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