line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::MojoSlides; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2474
|
use Mojo::Base 'Mojolicious'; |
|
4
|
|
|
|
|
6890
|
|
|
4
|
|
|
|
|
20
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
6
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
7
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
386050
|
use App::MojoSlides::Slides; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
26
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
91
|
use Mojo::File; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
3166
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has slides => sub { |
13
|
|
|
|
|
|
|
my $self = shift; |
14
|
|
|
|
|
|
|
return App::MojoSlides::Slides->new( |
15
|
|
|
|
|
|
|
$self->config->{slides} || () |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub startup { |
20
|
3
|
|
|
3
|
1
|
27443
|
my $self = shift; |
21
|
|
|
|
|
|
|
|
22
|
3
|
|
|
|
|
9
|
$self->plugin( 'InstallablePaths' ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$self->helper( presentation_file => sub { |
25
|
6
|
|
|
6
|
|
577
|
require File::Spec; |
26
|
6
|
|
|
|
|
23
|
require File::Basename; |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
50
|
|
|
30
|
my $file = $ENV{MOJO_SLIDES_PRESENTATION} || 'presentation.pl'; |
29
|
6
|
50
|
|
|
|
91
|
return $file unless -e $file; # return early if not found |
30
|
|
|
|
|
|
|
|
31
|
6
|
|
|
|
|
125
|
my $abs = File::Spec->rel2abs($file); |
32
|
6
|
50
|
|
|
|
22
|
return File::Basename::fileparse($abs) if wantarray; |
33
|
6
|
|
|
|
|
57
|
return $abs; |
34
|
3
|
|
|
|
|
17586
|
}); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$self->plugin( Config => { |
37
|
|
|
|
|
|
|
file => scalar $self->presentation_file, |
38
|
|
|
|
|
|
|
default => { |
39
|
|
|
|
|
|
|
slides => undef, |
40
|
|
|
|
|
|
|
ppi => undef, |
41
|
|
|
|
|
|
|
templates => undef, |
42
|
|
|
|
|
|
|
static => undef, |
43
|
|
|
|
|
|
|
bootstrap_theme => undef, |
44
|
|
|
|
|
|
|
more_tag_helpers => 1, |
45
|
|
|
|
|
|
|
extra_css => undef, |
46
|
|
|
|
|
|
|
extra_js => undef, |
47
|
|
|
|
|
|
|
header_template => 'ms_header', |
48
|
|
|
|
|
|
|
footer_template => 'ms_footer', |
49
|
|
|
|
2
|
|
|
finally => sub {}, |
50
|
|
|
|
|
|
|
}, |
51
|
3
|
|
|
|
|
70
|
}); |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# should this be optional? |
54
|
3
|
|
|
|
|
5339
|
$self->include_data_handle_from_file(scalar $self->presentation_file); |
55
|
|
|
|
|
|
|
|
56
|
3
|
50
|
|
|
|
72
|
$self->plugin('App::MojoSlides::MoreTagHelpers') if $self->config->{more_tag_helpers}; |
57
|
|
|
|
|
|
|
|
58
|
3
|
50
|
|
|
|
37
|
if (my $path = $self->config->{templates}) { |
59
|
0
|
0
|
|
|
|
0
|
unshift @{ $self->renderer->paths }, ref $path ? @$path : $path; |
|
0
|
|
|
|
|
0
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
3
|
50
|
|
|
|
28
|
if (my $path = $self->config->{static}) { |
63
|
0
|
0
|
|
|
|
0
|
unshift @{ $self->static->paths }, ref $path ? @$path : $path; |
|
0
|
|
|
|
|
0
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
3
|
50
|
|
|
|
21
|
if (my $ppi = $self->config->{ppi}) { |
67
|
0
|
|
|
|
|
0
|
my $args = {}; |
68
|
0
|
0
|
|
|
|
0
|
$args->{src_folder} = $ppi if -d $ppi; |
69
|
0
|
|
|
|
|
0
|
$self->plugin(PPI => $args); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$self->helper( prev_slide => sub { |
73
|
7
|
|
|
7
|
|
26651
|
my $c = shift; |
74
|
7
|
|
|
|
|
26
|
return $c->app->slides->prev($c->stash('slide')); |
75
|
3
|
|
|
|
|
31
|
}); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$self->helper( next_slide => sub { |
78
|
7
|
|
|
7
|
|
1981
|
my $c = shift; |
79
|
7
|
|
|
|
|
17
|
return $c->app->slides->next($c->stash('slide')); |
80
|
3
|
|
|
|
|
36
|
}); |
81
|
|
|
|
|
|
|
|
82
|
3
|
|
|
0
|
|
31
|
$self->helper( first_slide => sub { shift->app->slides->first } ); |
|
0
|
|
|
|
|
0
|
|
83
|
3
|
|
|
3
|
|
27
|
$self->helper( last_slide => sub { shift->app->slides->last } ); |
|
3
|
|
|
|
|
1781
|
|
84
|
|
|
|
|
|
|
|
85
|
3
|
|
|
1
|
|
34
|
$self->helper( row => sub { shift->tag( 'div', class => 'row', @_ ) } ); |
|
1
|
|
|
|
|
5048
|
|
86
|
3
|
|
|
|
|
27
|
$self->helper( column => \&_column ); |
87
|
3
|
|
|
0
|
|
28
|
$self->helper( overlay => sub { shift->tag( 'div', ms_overlay => shift, @_ ) } ); |
|
0
|
|
|
|
|
0
|
|
88
|
3
|
|
|
0
|
|
29
|
$self->helper( vspace => sub { shift->tag( 'div', style => "min-height: @{[shift]};" => '') } ); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
89
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
35
|
my $r = $self->routes; |
91
|
3
|
|
|
|
|
17
|
$r->any( |
92
|
|
|
|
|
|
|
'/:slide', |
93
|
|
|
|
|
|
|
{ slide => $self->slides->first }, |
94
|
|
|
|
|
|
|
[ slide => qr/\b\d+\b/ ], |
95
|
|
|
|
|
|
|
\&_action, |
96
|
|
|
|
|
|
|
); |
97
|
|
|
|
|
|
|
|
98
|
3
|
|
|
|
|
876
|
my $finally = $self->config->{finally}; |
99
|
3
|
|
|
|
|
45
|
$self->$finally(); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _action { |
103
|
4
|
|
|
4
|
|
36434
|
my $c = shift; |
104
|
4
|
|
|
|
|
12
|
my $slides = $c->app->slides; |
105
|
4
|
50
|
|
|
|
31
|
my $slide = $slides->template_for($c->stash('slide')) |
106
|
|
|
|
|
|
|
or return $c->render_not_found; |
107
|
4
|
50
|
|
|
|
51
|
$c->render($slide, layout => 'basic') || $c->render_not_found; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _column { |
111
|
2
|
|
|
2
|
|
265
|
my $c = shift; |
112
|
2
|
100
|
|
|
|
5
|
my $cols = ref $_[0] ? shift : [ shift ]; |
113
|
2
|
|
|
|
|
4
|
my $class = join ' ', map { "col-md-$_" } @$cols; |
|
3
|
|
|
|
|
7
|
|
114
|
2
|
|
|
|
|
25
|
return $c->tag( div => class => $class, @_ ); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# hic sunt dracones |
118
|
|
|
|
|
|
|
sub include_data_handle_from_file { |
119
|
3
|
|
|
3
|
0
|
8
|
my ($self, $file) = @_; |
120
|
3
|
|
|
|
|
10
|
require Mojo::Util; |
121
|
3
|
|
|
|
|
15
|
my $string = Mojo::File->new($file)->slurp; |
122
|
3
|
|
|
3
|
|
231
|
open my $handle, '<', \$string; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
21
|
|
123
|
3
|
|
|
|
|
1968
|
while (<$handle>) { |
124
|
21
|
100
|
|
|
|
52
|
last if /^__DATA__/; # seek to __DATA__ |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
|
127
|
3
|
|
|
|
|
6
|
state $i = 0; |
128
|
3
|
|
|
|
|
10
|
my $class = 'App::MojoSlides::TextOfFile' . $i++; |
129
|
|
|
|
|
|
|
{ |
130
|
4
|
|
|
4
|
|
20
|
no strict 'refs'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
307
|
|
|
3
|
|
|
|
|
3
|
|
131
|
3
|
|
|
|
|
6
|
*{$class.'::DATA'} = $handle; |
|
3
|
|
|
|
|
29
|
|
132
|
|
|
|
|
|
|
} |
133
|
3
|
|
|
|
|
4
|
unshift @{ $self->renderer->classes }, $class; |
|
3
|
|
|
|
|
17
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
1; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
__END__ |