| 1 | #!/usr/bin/env perl | ||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Mojolicious::Lite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use if -e 'lib/App/remarkpl', qw(lib lib); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use App::remarkpl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Mojo::File qw(path); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 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 | 1 | ▶ | my $presentation = shift @ARGV || $ENV{REMARK_PRESENTATION} || 'example.markdown'; | ||||||||||||||||||||||||||
|
Condition40%2/5
shift @ARGV || $ENV{'REMARK_PRESENTATION'} || 'example.markdown'
shift @ARGV or $ENV{"REMARK_PRESENTATION"}
MC/DC0%0/2
shift @ARGV || $ENV{'REMARK_PRESENTATION'} || 'example.markdown'
shift @ARGV
$ENV{"REMARK_PRESENTATION"}
Truth table33%1/3
A or B
A= shift @ARGVB= $ENV{"REMARK_PRESENTATION"}
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | unless ($ENV{MOJO_APP_LOADER}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | exec perldoc => -tT => $INC{'App/remarkpl.pm'} if $presentation =~ m!^-*(h|help|man)$!; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | die qq(Cannot read presentation file "$presentation".\n) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$presentation eq "example.markdown" or -r $presentation
MC/DC0%0/2
$presentation eq "example.markdown" or -r $presentation
$presentation eq "example.markdown"
-r $presentation
Truth table0%0/3
A or B
A= $presentation eq "example.markdown"B= -r $presentation
| |||||||||||||||||||||||||||||
| 14 | unless $presentation eq 'example.markdown' or -r $presentation; | ||||||||||||||||||||||||||||
| 15 | 0 | unshift @ARGV, 'daemon'; | |||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | $presentation = path $presentation; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # Include static assets and templates | ||||||||||||||||||||||||||||
| 21 | app->renderer->paths( | ||||||||||||||||||||||||||||
| 22 | 1 | ▶ | [split /:/, ($ENV{REMARK_TEMPLATES} // $presentation->sibling('templates')->to_abs)]); | ||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{"REMARK_TEMPLATES"} // $presentation->sibling("templates")->to_abs
MC/DC0%0/2
$ENV{"REMARK_TEMPLATES"} // $presentation->sibling("templates")->to_abs
$ENV{"REMARK_TEMPLATES"}
$presentation->sibling("templates")->to_abs
Truth table33%1/3
A // B
A= $ENV{"REMARK_TEMPLATES"}B= $presentation->sibling("templates")->to_abs
| |||||||||||||||||||||||||||||
| 23 | 1 | ▶ | app->static->paths([split /:/, ($ENV{REMARK_STATIC} // $presentation->dirname)]); | ||||||||||||||||||||||||||
|
Condition33%1/3
$ENV{"REMARK_STATIC"} // $presentation->dirname
MC/DC0%0/2
$ENV{"REMARK_STATIC"} // $presentation->dirname
$ENV{"REMARK_STATIC"}
$presentation->dirname
Truth table33%1/3
A // B
A= $ENV{"REMARK_STATIC"}B= $presentation->dirname
| |||||||||||||||||||||||||||||
| 24 | 1 | push @{app->static->paths}, | |||||||||||||||||||||||||||
| 25 | 1 | path(path($INC{'App/remarkpl.pm'})->dirname, qw(remarkpl public))->to_abs; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # Custom switch to show example presentation file | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | exit(print(read_presentation()) ? 0 : $!) if grep {/^--print/} @ARGV; | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | app->log->info(qq(Looking for static files in ) . join ', ', @{app->static->paths}); | |||||||||||||||||||||||||||
| 31 | 1 | app->log->info(qq(Looking for templates in ) . join ', ', @{app->renderer->paths}); | |||||||||||||||||||||||||||
| 32 | 1 | app->log->info(qq(Serving presentation "$presentation")); | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | ▶ | get '/' => sub { shift->render(template => 'remarkpl', presentation => read_presentation()) }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | ▶ | app->defaults(remarkjs => $ENV{REMARK_JS} || '/remark.min.js'); | ||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'REMARK_JS'} || '/remark.min.js'
MC/DC0%0/1
$ENV{'REMARK_JS'} || '/remark.min.js'
$ENV{'REMARK_JS'}
Truth table50%1/2
A
A= $ENV{'REMARK_JS'}
| |||||||||||||||||||||||||||||
| 37 | 1 | app->defaults(title => $presentation->basename); | |||||||||||||||||||||||||||
| 38 | 1 | app->start; | |||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | sub read_presentation { | ||||||||||||||||||||||||||
|
Subroutine
read_presentation: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 41 | 1 | ▶ | Mojo::Util::decode('UTF-8', | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | -e $presentation | ||||||||||||||||||||||||||||
| 43 | ? $presentation->slurp | ||||||||||||||||||||||||||||
| 44 | : Mojo::Loader::data_section(__PACKAGE__, $presentation)); | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | __DATA__ | ||||||||||||||||||||||||||||