line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Images; |
2
|
7
|
|
|
7
|
|
141202
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
58
|
|
3
|
7
|
|
|
7
|
|
1043
|
use 5.20.0; |
|
7
|
|
|
|
|
26
|
|
|
7
|
|
|
|
|
282
|
|
4
|
7
|
|
|
7
|
|
28
|
use experimental 'signatures'; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
48
|
|
5
|
|
|
|
|
|
|
|
6
|
7
|
|
|
7
|
|
637
|
use Mojo::Path; |
|
7
|
|
|
|
|
11
|
|
|
7
|
|
|
|
|
57
|
|
7
|
7
|
|
|
7
|
|
3157
|
use Mojolicious::Plugin::Images::Service::Dest; |
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
83
|
|
8
|
7
|
|
|
7
|
|
3270
|
use Mojolicious::Plugin::Images::Service::Origin; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
76
|
|
9
|
7
|
|
|
7
|
|
205
|
use Mojolicious::Plugin::Images::Util ':all'; |
|
7
|
|
|
|
|
10
|
|
|
7
|
|
|
|
|
3524
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.007'; # TRIAL VERSION |
12
|
|
|
|
|
|
|
|
13
|
23
|
50
|
|
23
|
|
55
|
sub _class($from) { |
|
23
|
50
|
|
|
|
46
|
|
|
23
|
|
|
|
|
42
|
|
|
23
|
|
|
|
|
26
|
|
14
|
23
|
|
|
|
|
29
|
my $ns = "Mojolicious::Plugin::Images::Service"; |
15
|
23
|
100
|
|
|
|
74
|
return $from ? "${ns}::Dest" : "${ns}::Origin"; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub _defaults { |
19
|
23
|
|
|
23
|
|
52
|
return (ext => 'jpg', dir => 'public/images', url_prefix => '/images'); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
12
|
50
|
|
12
|
1
|
35027
|
sub register($self, $app, $options) { |
|
12
|
50
|
|
|
|
36
|
|
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
16
|
|
|
12
|
|
|
|
|
17
|
|
23
|
12
|
100
|
|
|
|
59
|
$options = {%{$app->config('plugin_images') || {}}} unless keys %$options; |
|
3
|
100
|
|
|
|
13
|
|
24
|
12
|
100
|
|
|
|
87
|
plugin_log($app, "Plugin is loaded but neither options no config provided") |
25
|
|
|
|
|
|
|
unless keys %$options; |
26
|
|
|
|
|
|
|
|
27
|
12
|
|
|
|
|
98
|
foreach my $moniker (keys %$options) { |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# helper |
30
|
23
|
|
|
|
|
392
|
my %opts = (_defaults(), %{$options->{$moniker}}); |
|
23
|
|
|
|
|
126
|
|
31
|
23
|
|
66
|
|
|
121
|
$opts{suffix} //= "-$moniker"; |
32
|
23
|
100
|
66
|
|
|
213
|
$opts{namespace} //= ref $app unless $app->isa('Mojolicious::Lite'); |
33
|
23
|
|
|
|
|
56
|
my $class = _class($opts{from}); |
34
|
|
|
|
|
|
|
|
35
|
126
|
|
|
|
|
115
|
my $msg_attr = join(', ', |
36
|
23
|
|
100
|
|
|
139
|
map {"$_ => '${\( $opts{$_} // 'undef' ) }'"} sort keys %opts); |
|
126
|
|
|
|
|
345
|
|
37
|
|
|
|
|
|
|
|
38
|
23
|
|
|
|
|
89
|
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
|
|
8594
|
$class->new(%opts, controller => shift); |
44
|
|
|
|
|
|
|
} |
45
|
23
|
|
|
|
|
1286
|
); |
46
|
|
|
|
|
|
|
|
47
|
23
|
100
|
|
|
|
1845
|
if (defined $opts{url_prefix}) { |
48
|
21
|
|
|
|
|
77
|
install_route($app, $moniker, \%opts); |
49
|
21
|
|
|
|
|
15042
|
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__ |