-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild_images.pl
More file actions
executable file
·42 lines (38 loc) · 927 Bytes
/
build_images.pl
File metadata and controls
executable file
·42 lines (38 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!perl
use strict;
use warnings;
use File::Slurp;
use MIME::Base64;
use Perl::Tidy;
use Template;
my $template = q{package CPAN::Mini::Webserver::Templates::Images;
use strict;
use warnings;
use MIME::Base64;
use Template::Declare::Tags;
use base 'Template::Declare';
[% FOREACH file IN files %]
[% name = file.0 %]
[% encoded = file.1 %]
template 'images_[% name %]' => sub {
my $self = shift;
my $encoded = <<'END';
[% encoded %]
END
outs_raw decode_base64($encoded);
};
[% END %]
1;
};
my $tt = Template->new;
$tt->process(
\$template,
{ files => [
[ 'logo' => encode_base64( read_file('images/logo.png') ) ],
[ 'favicon' => encode_base64( read_file('images/favicon.png') ) ],
],
},
\my $perl,
) || die $template->error();
Perl::Tidy::perltidy( source => \$perl, destination => \my $tidied );
write_file( 'lib/CPAN/Mini/Webserver/Templates/Images.pm', $tidied );