line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
1
|
|
|
1
|
|
1000
|
use Mojolicious::Lite; |
|
1
|
|
|
|
|
64184
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
22593
|
use if -e 'lib/App/remarkpl', qw(lib lib); |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
2172
|
use App::remarkpl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
6
|
1
|
|
|
1
|
|
7
|
use Mojo::File qw(path); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
517
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# Read in the presentation when running the script from command line, |
9
|
|
|
|
|
|
|
# show the manual or an error message in case of an invalid file. |
10
|
|
|
|
|
|
|
my $presentation = shift @ARGV || $ENV{REMARK_PRESENTATION} || 'example.markdown'; |
11
|
|
|
|
|
|
|
unless ($ENV{MOJO_APP_LOADER}) { |
12
|
|
|
|
|
|
|
exec perldoc => -tT => $INC{'App/remarkpl.pm'} unless $presentation; |
13
|
|
|
|
|
|
|
die qq(Cannot read presentation file "$presentation".\n) |
14
|
|
|
|
|
|
|
unless $presentation eq 'example.markdown' or -r $presentation; |
15
|
|
|
|
|
|
|
unshift @ARGV, 'daemon'; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Include static assets and templates |
19
|
|
|
|
|
|
|
app->renderer->paths([split /:/, ($ENV{REMARK_TEMPLATES} // path('templates')->to_abs)]); |
20
|
|
|
|
|
|
|
app->static->paths([split /:/, ($ENV{REMARK_STATIC} // path)]); |
21
|
|
|
|
|
|
|
push @{app->static->paths}, |
22
|
|
|
|
|
|
|
path(path($INC{'App/remarkpl.pm'})->dirname, qw(remarkpl public))->to_abs; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Custom switch to show example presentation file |
25
|
|
|
|
|
|
|
exit(print(read_presentation()) ? 0 : $!) if grep {/^--print/} @ARGV; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
app->log->info(qq(Looking for static files in ) . join ', ', @{app->static->paths}); |
28
|
|
|
|
|
|
|
app->log->info(qq(Looking for templates in ) . join ', ', @{app->renderer->paths}); |
29
|
|
|
|
|
|
|
app->log->info(qq(Serving presentation "$presentation")); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
get '/' => sub { shift->render(template => 'remarkpl', presentation => read_presentation()) }; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
app->defaults(remarkjs => $ENV{REMARK_JS} || '/remark.min.js'); |
34
|
|
|
|
|
|
|
app->defaults(title => $presentation); |
35
|
|
|
|
|
|
|
app->start; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub read_presentation { |
38
|
1
|
50
|
|
1
|
|
35
|
Mojo::Util::decode('UTF-8', |
39
|
|
|
|
|
|
|
-e $presentation |
40
|
|
|
|
|
|
|
? path($presentation)->slurp |
41
|
|
|
|
|
|
|
: Mojo::Loader::data_section(__PACKAGE__, $presentation)); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
__DATA__ |