line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::VideoHost; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$App::VideoHost::VERSION = '0.143310'; # TRIAL |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
828
|
use Mojo::Base 'Mojolicious'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
7
|
1
|
|
|
1
|
|
127493
|
use App::VideoHost::Video::Storage; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use File::Basename 'dirname'; |
10
|
|
|
|
|
|
|
use File::Spec::Functions 'catdir'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Filesystem based personal video hosting |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# This method will run once at server start |
16
|
|
|
|
|
|
|
sub startup { |
17
|
|
|
|
|
|
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Switch to installable home directory |
20
|
|
|
|
|
|
|
$self->home->parse(catdir(dirname(__FILE__), 'VideoHost')); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# Switch to installable "public" directory |
23
|
|
|
|
|
|
|
$self->static->paths->[0] = $self->home->rel_dir('public'); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Switch to installable "templates" directory |
26
|
|
|
|
|
|
|
$self->renderer->paths->[0] = $self->home->rel_dir('templates'); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Load config |
29
|
|
|
|
|
|
|
$self->plugin('Config'); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# configure logging |
32
|
|
|
|
|
|
|
if ($self->config->{log}->{path}) { |
33
|
|
|
|
|
|
|
$self->log(Mojo::Log->new(path => $self->config->{log}->{path}, level => $self->config->{log}->{level} || 'info')); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# Router |
37
|
|
|
|
|
|
|
my $r = $self->routes; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# Set namespace, to support older Mojolicious versions where this was |
40
|
|
|
|
|
|
|
# not the default |
41
|
|
|
|
|
|
|
$r->namespaces(['App::VideoHost::Controller']); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Normal route to controller |
44
|
|
|
|
|
|
|
$r->get('/')->to('root#index'); |
45
|
|
|
|
|
|
|
$r->get('/video/:short_name')->to('root#video_stream')->name('video'); |
46
|
|
|
|
|
|
|
$r->get('/poster/:short_name')->to('root#poster')->name('poster'); |
47
|
|
|
|
|
|
|
$r->get('/tracks/:short_name')->to('root#tracks')->name('tracks'); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
$self->helper(videos => sub { |
50
|
|
|
|
|
|
|
my $self = shift; |
51
|
|
|
|
|
|
|
state $videos = App::VideoHost::Video::Storage->new(directory => $self->config->{ video_directory }); |
52
|
|
|
|
|
|
|
return $videos; |
53
|
|
|
|
|
|
|
}); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=pod |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=encoding UTF-8 |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 NAME |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
App::VideoHost - Filesystem based personal video hosting |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 VERSION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
version 0.143310 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 SYNOPSIS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Just drop videos and text files containing the metadata into a directory of |
77
|
|
|
|
|
|
|
your choice, then: |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
cp lib/VideoHost/video_host.conf $SOMEDIR/video_host.conf |
80
|
|
|
|
|
|
|
edit $SOMEDIR/video_host.conf |
81
|
|
|
|
|
|
|
MOJO_CONFIG=$SOMEDIR/video_host.conf hypnotoad `which video_host` |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Justin Hawkins <justin@eatmorecode.com> |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Justin Hawkins. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
92
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |