line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Images; |
2
|
7
|
|
|
7
|
|
141254
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
7
|
|
|
|
|
14
|
|
|
7
|
|
|
|
|
59
|
|
3
|
7
|
|
|
7
|
|
973
|
use 5.20.0; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
286
|
|
4
|
7
|
|
|
7
|
|
29
|
use experimental 'signatures'; |
|
7
|
|
|
|
|
8
|
|
|
7
|
|
|
|
|
52
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
733
|
use Mojo::Path; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
66
|
|
7
|
7
|
|
|
7
|
|
3167
|
use Mojolicious::Plugin::Images::Service::Dest; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
80
|
|
8
|
7
|
|
|
7
|
|
3264
|
use Mojolicious::Plugin::Images::Service::Origin; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
79
|
|
9
|
7
|
|
|
7
|
|
220
|
use Mojolicious::Plugin::Images::Util ':all'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
3557
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.006'; # VERSION |
12
|
|
|
|
|
|
|
|
13
|
21
|
50
|
|
21
|
|
210
|
sub _class($from) { |
|
21
|
50
|
|
|
|
40
|
|
|
21
|
|
|
|
|
39
|
|
|
21
|
|
|
|
|
20
|
|
14
|
21
|
|
|
|
|
23
|
my $ns = "Mojolicious::Plugin::Images::Service"; |
15
|
21
|
100
|
|
|
|
68
|
return $from ? "${ns}::Dest" : "${ns}::Origin"; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _defaults { |
19
|
21
|
|
|
21
|
|
44
|
return (ext => 'jpg', dir => 'public/images', url_prefix => '/images'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
11
|
50
|
|
11
|
1
|
23716
|
sub register($self, $app, $options) { |
|
11
|
50
|
|
|
|
36
|
|
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
17
|
|
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
15
|
|
23
|
11
|
100
|
|
|
|
52
|
$options = {%{$app->config('plugin_images') || {}}} unless keys %$options; |
|
2
|
100
|
|
|
|
8
|
|
24
|
11
|
100
|
|
|
|
63
|
plugin_log($app, "Plugin is loaded but neither options no config provided") |
25
|
|
|
|
|
|
|
unless keys %$options; |
26
|
|
|
|
|
|
|
|
27
|
11
|
|
|
|
|
82
|
foreach my $moniker (keys %$options) { |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# helper |
30
|
21
|
|
|
|
|
350
|
my %opts = (_defaults(), %{$options->{$moniker}}); |
|
21
|
|
|
|
|
112
|
|
31
|
21
|
|
66
|
|
|
108
|
$opts{suffix} //= "-$moniker"; |
32
|
21
|
100
|
66
|
|
|
193
|
$opts{namespace} //= ref $app unless $app->isa('Mojolicious::Lite'); |
33
|
21
|
|
|
|
|
94
|
my $class = _class($opts{from}); |
34
|
|
|
|
|
|
|
|
35
|
116
|
|
|
|
|
102
|
my $msg_attr = join(', ', |
36
|
21
|
|
100
|
|
|
127
|
map {"$_ => '${\( $opts{$_} // 'undef' ) }'"} sort keys %opts); |
|
116
|
|
|
|
|
297
|
|
37
|
|
|
|
|
|
|
|
38
|
21
|
|
|
|
|
92
|
plugin_log($app, "Creating helper images.%s(%s): {%s};", |
39
|
|
|
|
|
|
|
$moniker, $class, $msg_attr); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$app->helper( |
42
|
|
|
|
|
|
|
"images.$moniker" => sub { |
43
|
15
|
|
|
15
|
|
6463
|
$class->new(%opts, controller => shift); |
44
|
|
|
|
|
|
|
} |
45
|
21
|
|
|
|
|
1086
|
); |
46
|
|
|
|
|
|
|
|
47
|
21
|
100
|
|
|
|
1429
|
if (defined $opts{url_prefix}) { |
48
|
19
|
|
|
|
|
61
|
install_route($app, $moniker, \%opts); |
49
|
19
|
|
|
|
|
12561
|
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__ |