line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dancer2::Plugin::Showterm; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:YANICK'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Replay terminal typescript captures |
4
|
|
|
|
|
|
|
$Dancer2::Plugin::Showterm::VERSION = '0.0.2'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
539
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
7
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
410
|
use File::ShareDir::Tarball; |
|
1
|
|
|
|
|
103387
|
|
|
1
|
|
|
|
|
38
|
|
10
|
1
|
|
|
1
|
|
556
|
use Path::Tiny; |
|
1
|
|
|
|
|
8086
|
|
|
1
|
|
|
|
|
40
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
398
|
use Dancer2::Plugin; |
|
1
|
|
|
|
|
166533
|
|
|
1
|
|
|
|
|
8
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
51632
|
use Moo; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has assets_dir => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
lazy => 1, |
19
|
|
|
|
|
|
|
default => sub { |
20
|
|
|
|
|
|
|
path( |
21
|
|
|
|
|
|
|
$_->config->{assets_dir} |
22
|
|
|
|
|
|
|
|| File::ShareDir::Tarball::dist_dir('Dancer-Plugin-Showterm') |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has stylesheet => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
default => sub { |
30
|
|
|
|
|
|
|
$_[0]->config->{stylesheet}; |
31
|
|
|
|
|
|
|
}, |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub BUILD { |
35
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$self->app->add_route( |
38
|
|
|
|
|
|
|
method => 'get', |
39
|
|
|
|
|
|
|
regexp => qr/.*\.showterm/, |
40
|
|
|
|
|
|
|
code => sub { |
41
|
0
|
|
|
0
|
|
|
my $app = shift; |
42
|
0
|
|
|
|
|
|
( my $file = $app->request->path ) =~ s/\.showterm$/\.typescript/; |
43
|
0
|
|
|
|
|
|
my $template = $self->assets_dir->child('showterm.html')->slurp; |
44
|
0
|
|
|
|
|
|
$template =~ s/__FILE__/$file/g; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$template =~ s[(?=)][ |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
] for grep { $_ } $self->stylesheet; |
|
0
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$template; |
51
|
|
|
|
|
|
|
} |
52
|
0
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
$self->app->add_route( |
54
|
|
|
|
|
|
|
method => 'get', |
55
|
|
|
|
|
|
|
regexp => qr/\/showterm\/(.*)/, |
56
|
|
|
|
|
|
|
code => sub { |
57
|
0
|
|
|
0
|
|
|
my $app = shift; |
58
|
0
|
|
|
|
|
|
my( $path ) = $app->request->splat; |
59
|
0
|
|
|
|
|
|
$app->send_file( |
60
|
|
|
|
|
|
|
$self->assets_dir->child($path), system_path => 1 |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |