line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Images; |
2
|
7
|
|
|
7
|
|
138719
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
56
|
|
3
|
7
|
|
|
7
|
|
915
|
use 5.20.0; |
|
7
|
|
|
|
|
21
|
|
|
7
|
|
|
|
|
276
|
|
4
|
7
|
|
|
7
|
|
27
|
use experimental 'signatures'; |
|
7
|
|
|
|
|
6
|
|
|
7
|
|
|
|
|
47
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
618
|
use Mojo::Path; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
59
|
|
7
|
7
|
|
|
7
|
|
2932
|
use Mojolicious::Plugin::Images::Service::Dest; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
83
|
|
8
|
7
|
|
|
7
|
|
3220
|
use Mojolicious::Plugin::Images::Service::Origin; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
69
|
|
9
|
7
|
|
|
7
|
|
180
|
use Mojolicious::Plugin::Images::Util ':all'; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
3350
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.008'; # TRIAL VERSION |
12
|
|
|
|
|
|
|
|
13
|
23
|
50
|
|
23
|
|
52
|
sub _class($from) { |
|
23
|
50
|
|
|
|
47
|
|
|
23
|
|
|
|
|
43
|
|
|
23
|
|
|
|
|
22
|
|
14
|
23
|
|
|
|
|
21
|
my $ns = "Mojolicious::Plugin::Images::Service"; |
15
|
23
|
100
|
|
|
|
121
|
return $from ? "${ns}::Dest" : "${ns}::Origin"; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _defaults { |
19
|
23
|
|
|
23
|
|
61
|
return (ext => 'jpg', dir => 'public/images', url_prefix => '/images'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
12
|
50
|
|
12
|
1
|
26591
|
sub register($self, $app, $options) { |
|
12
|
50
|
|
|
|
40
|
|
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
19
|
|
|
12
|
|
|
|
|
14
|
|
|
12
|
|
|
|
|
15
|
|
23
|
12
|
100
|
|
|
|
57
|
$options = {%{$app->config('plugin_images') || {}}} unless keys %$options; |
|
3
|
100
|
|
|
|
9
|
|
24
|
12
|
100
|
|
|
|
72
|
plugin_log($app, "Plugin is loaded but neither options no config provided") |
25
|
|
|
|
|
|
|
unless keys %$options; |
26
|
|
|
|
|
|
|
|
27
|
12
|
|
|
|
|
80
|
foreach my $moniker (keys %$options) { |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# helper |
30
|
23
|
|
|
|
|
587
|
my %opts = (_defaults(), %{$options->{$moniker}}); |
|
23
|
|
|
|
|
149
|
|
31
|
23
|
|
66
|
|
|
120
|
$opts{suffix} //= "-$moniker"; |
32
|
23
|
100
|
66
|
|
|
209
|
$opts{namespace} //= ref $app unless $app->isa('Mojolicious::Lite'); |
33
|
23
|
|
|
|
|
57
|
my $class = _class($opts{from}); |
34
|
|
|
|
|
|
|
|
35
|
126
|
|
|
|
|
102
|
my $msg_attr = join(', ', |
36
|
23
|
|
100
|
|
|
134
|
map {"$_ => '${\( $opts{$_} // 'undef' ) }'"} sort keys %opts); |
|
126
|
|
|
|
|
313
|
|
37
|
|
|
|
|
|
|
|
38
|
23
|
|
|
|
|
90
|
plugin_log($app, "Creating helper images.%s(%s): {%s};", |
39
|
|
|
|
|
|
|
$moniker, $class, $msg_attr); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$app->helper( |
42
|
|
|
|
|
|
|
"images.$moniker" => sub { |
43
|
17
|
|
|
17
|
|
7716
|
$class->new(%opts, controller => shift); |
44
|
|
|
|
|
|
|
} |
45
|
23
|
|
|
|
|
1257
|
); |
46
|
|
|
|
|
|
|
|
47
|
23
|
100
|
|
|
|
1518
|
if (defined $opts{url_prefix}) { |
48
|
21
|
|
|
|
|
71
|
install_route($app, $moniker, \%opts); |
49
|
21
|
|
|
|
|
13653
|
expand_static($opts{dir}, $opts{url_prefix}, $app); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# ABSTRACT: easy and powerful image manipulation for Mojolicious |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |