line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dash::Backend::Mojolicious::Setup; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
45
|
use Mojo::Base -base; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
46
|
|
4
|
6
|
|
|
6
|
|
1004
|
use Try::Tiny; |
|
6
|
|
|
|
|
15
|
|
|
6
|
|
|
|
|
416
|
|
5
|
6
|
|
|
6
|
|
42
|
use File::ShareDir 1.116; |
|
6
|
|
|
|
|
182
|
|
|
6
|
|
|
|
|
252
|
|
6
|
6
|
|
|
6
|
|
40
|
use Path::Tiny; |
|
6
|
|
|
|
|
21
|
|
|
6
|
|
|
|
|
291
|
|
7
|
6
|
|
|
6
|
|
38
|
use Scalar::Util; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
4024
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
has 'dash_app'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub register_app { |
12
|
11
|
|
|
11
|
0
|
148
|
my $self = shift; |
13
|
11
|
|
|
|
|
21
|
my $renderer = shift; |
14
|
11
|
|
|
|
|
22
|
my $routes = shift; |
15
|
11
|
|
|
|
|
85
|
my $dash_app = shift; |
16
|
|
|
|
|
|
|
$dash_app //= sub { |
17
|
0
|
|
|
0
|
|
0
|
return $self->dash_app; |
18
|
11
|
|
50
|
|
|
37
|
}; |
19
|
|
|
|
|
|
|
|
20
|
11
|
|
|
|
|
23
|
push @{ $renderer->classes }, __PACKAGE__; |
|
11
|
|
|
|
|
41
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$routes->get( |
23
|
|
|
|
|
|
|
'/' => sub { |
24
|
1
|
|
|
1
|
|
15757
|
my $c = shift; |
25
|
1
|
|
|
|
|
38
|
$c->stash( stylesheets => $dash_app->()->_rendered_stylesheets, |
26
|
|
|
|
|
|
|
external_stylesheets => $dash_app->()->_rendered_external_stylesheets, |
27
|
|
|
|
|
|
|
scripts => $dash_app->()->_rendered_scripts, |
28
|
|
|
|
|
|
|
title => $dash_app->()->app_name |
29
|
|
|
|
|
|
|
); |
30
|
1
|
|
|
|
|
34
|
$c->render( template => 'index' ); |
31
|
|
|
|
|
|
|
} |
32
|
11
|
|
|
|
|
207
|
); |
33
|
|
|
|
|
|
|
|
34
|
11
|
|
|
|
|
3158
|
my $dist_name = 'Dash'; |
35
|
|
|
|
|
|
|
$routes->get( |
36
|
|
|
|
|
|
|
'/_dash-component-suites/:namespace/*asset' => sub { |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# TODO Component registry to find assets file in other dists |
39
|
1
|
|
|
1
|
|
18859
|
my $c = shift; |
40
|
1
|
|
|
|
|
5
|
my $file = $dash_app->()->_filename_from_file_with_fingerprint( $c->stash('asset') ); |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
|
|
11
|
$c->reply->file( |
43
|
|
|
|
|
|
|
File::ShareDir::dist_file( $dist_name, |
44
|
|
|
|
|
|
|
Path::Tiny::path( 'assets', $c->stash('namespace'), $file )->canonpath |
45
|
|
|
|
|
|
|
) |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
} |
48
|
11
|
|
|
|
|
90
|
); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
$routes->get( |
51
|
|
|
|
|
|
|
'/_favicon.ico' => sub { |
52
|
1
|
|
|
1
|
|
10985
|
my $c = shift; |
53
|
1
|
|
|
|
|
6
|
$c->reply->file( File::ShareDir::dist_file( $dist_name, 'favicon.ico' ) ); |
54
|
|
|
|
|
|
|
} |
55
|
11
|
|
|
|
|
5105
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$routes->get( |
58
|
|
|
|
|
|
|
'/_dash-layout' => sub { |
59
|
1
|
|
|
1
|
|
13082
|
my $c = shift; |
60
|
1
|
|
|
|
|
6
|
$c->render( json => $dash_app->()->layout() ); |
61
|
|
|
|
|
|
|
} |
62
|
11
|
|
|
|
|
3093
|
); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
$routes->get( |
65
|
|
|
|
|
|
|
'/_dash-dependencies' => sub { |
66
|
1
|
|
|
1
|
|
10490
|
my $c = shift; |
67
|
1
|
|
|
|
|
5
|
my $dependencies = $dash_app->()->_dependencies(); |
68
|
1
|
|
|
|
|
8
|
$c->render( json => $dependencies ); |
69
|
|
|
|
|
|
|
} |
70
|
11
|
|
|
|
|
3134
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
$routes->post( |
73
|
|
|
|
|
|
|
'/_dash-update-component' => sub { |
74
|
2
|
|
|
2
|
|
27812
|
my $c = shift; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
8
|
my $request = $c->req->json; |
77
|
|
|
|
|
|
|
try { |
78
|
2
|
|
|
|
|
136
|
my $content = $dash_app->()->_update_component($request); |
79
|
1
|
|
|
|
|
6
|
$c->render( json => $content ); |
80
|
|
|
|
|
|
|
} catch { |
81
|
1
|
50
|
33
|
|
|
1430
|
if ( Scalar::Util::blessed $_ && $_->isa('Dash::Exceptions::PreventUpdate') ) { |
82
|
1
|
|
|
|
|
8
|
$c->render( status => 204, json => '' ); |
83
|
|
|
|
|
|
|
} else { |
84
|
0
|
|
|
|
|
0
|
die $_; |
85
|
|
|
|
|
|
|
} |
86
|
2
|
|
|
|
|
1650
|
}; |
87
|
|
|
|
|
|
|
} |
88
|
11
|
|
|
|
|
3542
|
); |
89
|
|
|
|
|
|
|
|
90
|
11
|
|
|
|
|
3700
|
return; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=pod |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=encoding UTF-8 |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 NAME |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Dash::Backend::Mojolicious::Setup |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 VERSION |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
version 0.10 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 AUTHOR |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Pablo Rodríguez González |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
This software is Copyright (c) 2020 by Pablo Rodríguez González. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This is free software, licensed under: |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The MIT (X11) License |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
__DATA__ |