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