| 1 | package Mojolicious::Plugin::QooxdooJsonrpc; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Mojo::Base 'Mojolicious::Plugin'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use File::Spec::Functions qw(splitdir updir catdir file_name_is_absolute); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Cwd qw(abs_path); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | warn "Mojolicious::Plugin::QooxdooJsonrpc is DEPRECATED. Please switch to using Mojolicious::Plugin::Qooxdoo.\n" unless $ENV{DISABLE_DEPRECATION_WARNING_MPQ}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 9 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.96'; | |||||||||||||||||||||||||||||||||||||||||||||
| 12 | # the dispatcher module gets autoloaded, we list it here to | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # make sure it is available and compiles at startup time and not | ||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # only on demand. | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use MojoX::Dispatcher::Qooxdoo::Jsonrpc; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
register: called CC=8 SCAR=38.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | my ($self, $app, $conf) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # Config | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | $conf ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf ||= {}
MC/DC0%0/1
$conf ||= {}
$conf
Truth table50%1/2
A
A= $conf
| |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | my $root = ($conf->{prefix} || '') . '/'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{'prefix'} || ''
MC/DC0%0/1
$conf->{'prefix'} || ''
$conf->{'prefix'}
Truth table50%1/2
A
A= $conf->{'prefix'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | my $services = $conf->{services}; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | my $path = $conf->{path} || 'jsonrpc'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$conf->{'path'} || 'jsonrpc'
MC/DC0%0/1
$conf->{'path'} || 'jsonrpc'
$conf->{'path'}
Truth table50%1/2
A
A= $conf->{'path'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | my $r = $app->routes; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | $r->route($root.$path)->to( | |||||||||||||||||||||||||||||||||||||||||||||
| 28 | controller => 'Jsonrpc', | ||||||||||||||||||||||||||||||||||||||||||||||
| 29 | action => 'dispatch', | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | namespace => 'MojoX::Dispatcher::Qooxdoo', | ||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # our own properties | ||||||||||||||||||||||||||||||||||||||||||||||
| 32 | services => $services | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ($ENV{QX_SRC_MODE}){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | my $qx_app_src = abs_path( | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | $ENV{QX_SRC_PATH} && file_name_is_absolute($ENV{QX_SRC_PATH}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 38 | ? $ENV{QX_SRC_PATH} | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | : $app->home->rel_dir($ENV{QX_SRC_PATH} || catdir(updir,'frontend','source')) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$ENV{"QX_SRC_PATH"} and file_name_is_absolute($ENV{"QX_SRC_PATH"})
$ENV{'QX_SRC_PATH'} || catdir('..', 'frontend', 'source')
MC/DC0%0/2
$ENV{"QX_SRC_PATH"} and file_name_is_absolute($ENV{"QX_SRC_PATH"})
$ENV{"QX_SRC_PATH"}
file_name_is_absolute($ENV{"QX_SRC_PATH"})
MC/DC0%0/2
$ENV{'QX_SRC_PATH'} || catdir('..', 'frontend', 'source')
$ENV{'QX_SRC_PATH'}
catdir('..', 'frontend', 'source')
Truth table0%0/3
A and B
A= $ENV{"QX_SRC_PATH"}B= file_name_is_absolute($ENV{"QX_SRC_PATH"})
Truth table0%0/3
A || B
A= $ENV{'QX_SRC_PATH'}B= catdir('..', 'frontend', 'source')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | $app->log->info("Runnning in QX_SRC_MODE with files from $qx_app_src"); | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | $app->static->paths([$qx_app_src]); | |||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my %prefixCache; | |||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my $static = Mojolicious::Static->new(); | |||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my $static_cb = sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | my $prefix = $self->param('prefix'); | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if ($self->param('file')){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | $self->req->url->path('/'.$prefix.'/'.$self->param('file')); | |||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if (not defined $prefixCache{$prefix}){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my $prefix_local = catdir(split /\//, $prefix); | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | my $path = $qx_app_src; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | my $last_path = ''; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | while ($path ne $last_path and not -d catdir($path,$prefix_local)){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$path ne $last_path and not -d catdir($path, $prefix_local)
MC/DC0%0/2
$path ne $last_path and not -d catdir($path, $prefix_local)
$path ne $last_path
not -d catdir($path, $prefix_local)
Truth table0%0/3
A and not(B)
A= $path ne $last_pathB= not -d catdir($path, $prefix_local)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $last_path = $path; | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $path = abs_path(catdir($last_path,updir)); | |||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $app->log->info("Auto register static path mapping from '$prefix' to '$path'"); | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $prefixCache{$prefix} = $path; | |||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $static->paths([$prefixCache{$prefix}]); | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | unless ($static->dispatch($self)){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->render(text=>$self->req->url->path.' not found', status => 404); | |||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $r->get('/(*prefix)/framework/source/(*a)' => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | $r->get('/(*prefix)/source/class/(*a)' => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $r->get('/(*prefix)/source/resource/(*a)' => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | $r->get('/(*prefix)/source/script/(*a)' => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | $r->get('/(*prefix)/downloads/(*a)/source/(*b)' => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $r->get('/source/index.html' => {prefix=>'source'} => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | $r->get('/source/class/(*b)' => {prefix=>'source'} => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | $r->get('/source/resource/(*b)' => {prefix=>'source'} => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | $r->get('/source/script/(*b)' => {prefix=>'source'} => $static_cb ); | |||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $r->get($root.'(*file)' => {prefix => 'source', file => 'index.html' } => $static_cb); | |||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $r->get($root.'(*file)' => {file => 'index.html' } => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $file = $self->param('file'); | |||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | $self->req->url->path('/'.$file); | |||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | return $app->static->dispatch($self); | |||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | }); | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||
| 92 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||