line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
1
|
|
|
1
|
|
773
|
use Mojolicious::Lite; |
|
1
|
|
|
|
|
34779
|
|
|
1
|
|
|
|
|
6
|
|
3
|
1
|
|
|
1
|
|
10695
|
use App::remarkpl; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
4
|
|
|
|
|
|
|
my $presentation = shift @ARGV || $ENV{REMARK_PRESENTATION} || ''; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
unless ($ENV{MOJO_APP_LOADER}) { |
7
|
|
|
|
|
|
|
exec perldoc => -tT => $INC{'App/remarkpl.pm'} unless $presentation; |
8
|
|
|
|
|
|
|
die qq(Cannot read presentation file "$presentation".\n) unless $presentation eq 'example.markdown' or -r $presentation; |
9
|
|
|
|
|
|
|
unshift @ARGV, 'daemon'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
require Cwd; |
13
|
|
|
|
|
|
|
app->renderer->paths([split /:/, ($ENV{REMARK_PUBLIC} // File::Spec->catdir(Cwd::getcwd(), 'templates'))]); |
14
|
|
|
|
|
|
|
app->static->paths([split /:/, ($ENV{REMARK_STATIC} // Cwd::getcwd())]); |
15
|
|
|
|
|
|
|
push @{app->static->paths}, |
16
|
|
|
|
|
|
|
Cwd::abs_path(File::Spec->catdir(File::Basename::dirname($INC{'App/remarkpl.pm'}), qw( remarkpl public ))); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$presentation ||= 'example.markdown'; |
19
|
|
|
|
|
|
|
app->defaults(title => $presentation); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
if (grep {/^--print/} @ARGV) { |
22
|
|
|
|
|
|
|
print read_presentation(); |
23
|
|
|
|
|
|
|
exit 0; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
app->log->info(qq(Looking for static files in ) . join ', ', @{app->static->paths}); |
27
|
|
|
|
|
|
|
app->log->info(qq(Looking for templates in ) . join ', ', @{app->renderer->paths}); |
28
|
|
|
|
|
|
|
app->log->info(qq(Serving presentation "$presentation")); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
get '/' => sub { |
31
|
|
|
|
|
|
|
shift->render(template => 'index', presentation => read_presentation()); |
32
|
|
|
|
|
|
|
}; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
app->start; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub read_presentation { |
37
|
1
|
50
|
|
1
|
|
24
|
Mojo::Util::decode( |
38
|
|
|
|
|
|
|
'UTF-8', |
39
|
|
|
|
|
|
|
-e $presentation ? Mojo::File->new($presentation)->slurp : Mojo::Loader::data_section(__PACKAGE__, $presentation) |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__DATA__ |