line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::StaticImageGallery::Style::Source::FromPackage; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
38
|
$App::StaticImageGallery::Style::Source::FromPackage::VERSION = '0.002'; |
4
|
|
|
|
|
|
|
} |
5
|
2
|
|
|
2
|
|
1800
|
use MIME::Base64; |
|
2
|
|
|
|
|
1710
|
|
|
2
|
|
|
|
|
142
|
|
6
|
2
|
|
|
2
|
|
2764
|
use Class::MOP (); |
|
2
|
|
|
|
|
235616
|
|
|
2
|
|
|
|
|
113
|
|
7
|
2
|
|
|
2
|
|
1934
|
use Template::Provider::FromDATA; |
|
2
|
|
|
|
|
74402
|
|
|
2
|
|
|
|
|
26
|
|
8
|
2
|
|
|
2
|
|
95
|
use parent 'App::StaticImageGallery::Base::Source'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
20
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub init { |
11
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
12
|
0
|
|
|
|
|
|
my %args = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# if ( defined $args{style_name} ) { |
15
|
0
|
|
|
|
|
|
$self->{_style_name} = $self->opt->get_style(); |
16
|
0
|
|
|
|
|
|
$self->{_style_class} = 'App::StaticImageGallery::Style::' . $self->{_style_name}; |
17
|
0
|
|
|
|
|
|
Class::MOP::load_class( $self->{_style_class} ); |
18
|
0
|
|
|
|
|
|
$self->{_TT} = $self->_build_tt({ |
19
|
|
|
|
|
|
|
LOAD_TEMPLATES => [ |
20
|
|
|
|
|
|
|
Template::Provider::FromDATA->new( { CLASSES => $self->{_style_class} } ), |
21
|
|
|
|
|
|
|
] |
22
|
|
|
|
|
|
|
}); |
23
|
|
|
|
|
|
|
# } |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$self->{init_args} = \%args; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
return $self; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
0
|
1
|
|
sub style_class { return shift->{_style_class}; } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Default config |
33
|
|
|
|
|
|
|
sub template_config { |
34
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
35
|
0
|
|
|
|
|
|
my $key = shift; |
36
|
0
|
|
|
|
|
|
my $config = { write_image_html => 1 }; |
37
|
0
|
0
|
|
|
|
|
if ( $self->style_class->can('_build_config') ){ |
38
|
0
|
|
|
|
|
|
$config = $self->style_class->_build_config(); |
39
|
|
|
|
|
|
|
} |
40
|
0
|
|
|
|
|
|
return $config->{$key}; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub write_style_files { |
44
|
0
|
|
|
0
|
1
|
|
my ($self ) = @_; |
45
|
0
|
0
|
|
|
|
|
if ( $self->style_class->can('files') ){ |
46
|
0
|
|
|
|
|
|
my @files = $self->style_class->files(); |
47
|
0
|
|
|
|
|
|
foreach my $file ( @files ){ |
48
|
0
|
|
|
|
|
|
my $filename = join '/',$self->data_dir,$file->{filename}; |
49
|
0
|
|
|
|
|
|
$self->msg_verbose(2,"Write file %s",$filename); |
50
|
0
|
0
|
|
|
|
|
open(my $fh,'>', $filename) or die "Can't write $filename: $!\n"; |
51
|
0
|
|
|
|
|
|
CORE::binmode($fh); |
52
|
0
|
0
|
|
|
|
|
if ( defined $file->{base64} ){ |
|
|
0
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
print $fh MIME::Base64::decode_base64($file->{base64}); |
54
|
|
|
|
|
|
|
}elsif ( defined $file->{content}){ |
55
|
0
|
|
|
|
|
|
print $fh $file->{content}; |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
close $fh; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
0
|
1
|
|
sub image_page_template_name { return 'image'; } |
63
|
0
|
|
|
0
|
1
|
|
sub index_page_template_name { return 'index'; } |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
__END__ |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
App::StaticImageGallery::Style::Source::FromPackage |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 VERSION |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
version 0.002 |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 DESCRIPTION |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SYNOPSIS |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 METHODS |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 image_page_template_name |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 index_page_template_name |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 init |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 style_class |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 template_config |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 write_style_files |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHOR |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
See L<App::StaticImageGallery/AUTHOR> and L<App::StaticImageGallery/CONTRIBUTORS>. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=cut |