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