line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Amuse::Compile::Devel; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
3682
|
use utf8; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
51
|
|
4
|
8
|
|
|
8
|
|
229
|
use strict; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
139
|
|
5
|
8
|
|
|
8
|
|
42
|
use warnings; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
197
|
|
6
|
8
|
|
|
8
|
|
1439
|
use Text::Amuse::Compile::Utils qw/write_file read_file/; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
452
|
|
7
|
8
|
|
|
8
|
|
810
|
use Text::Amuse::Compile::Fonts; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
197
|
|
8
|
8
|
|
|
8
|
|
814
|
use Text::Amuse::Compile::Fonts::Selected; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
196
|
|
9
|
8
|
|
|
8
|
|
593
|
use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); |
|
8
|
|
|
|
|
70158
|
|
|
8
|
|
|
|
|
3908
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw/explode_epub create_font_object/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 NAME |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Text::Amuse::Compile::Utils - Common routines used for developmetn |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 FUNCTIONS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head2 explode_epub |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Return the HTML content of an epub |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 create_font_object |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Return a valid Text::Amuse::Compile::Fonts::Selected object. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=cut |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub explode_epub { |
33
|
5
|
|
|
5
|
1
|
19736
|
my $epub = shift; |
34
|
5
|
|
|
|
|
47
|
my $zip = Archive::Zip->new; |
35
|
5
|
50
|
|
|
|
212
|
die "Couldn't read $epub" if $zip->read($epub) != AZ_OK; |
36
|
5
|
|
|
|
|
20390
|
my $tmpdir = File::Temp->newdir(CLEANUP => 1); |
37
|
5
|
50
|
|
|
|
2374
|
$zip->extractTree('OPS', $tmpdir->dirname) == AZ_OK |
38
|
|
|
|
|
|
|
or die "Cannot extract $epub OPS into $tmpdir"; |
39
|
5
|
50
|
|
|
|
112407
|
opendir (my $dh, $tmpdir->dirname) or die $!; |
40
|
5
|
|
|
|
|
352
|
my @pieces = sort grep { /\Apiece\d+\.xhtml\z/ } readdir($dh); |
|
80
|
|
|
|
|
221
|
|
41
|
5
|
|
|
|
|
62
|
closedir $dh; |
42
|
5
|
|
|
|
|
26
|
my @html; |
43
|
5
|
|
|
|
|
17
|
foreach my $piece ('toc.ncx', 'titlepage.xhtml', @pieces) { |
44
|
58
|
|
|
|
|
262
|
push @html, "", |
45
|
|
|
|
|
|
|
read_file(File::Spec->catfile($tmpdir->dirname, $piece)); |
46
|
|
|
|
|
|
|
} |
47
|
5
|
|
|
|
|
135
|
return join('', @html); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub create_font_object { |
51
|
9
|
|
|
9
|
1
|
15531
|
my $fonts = Text::Amuse::Compile::Fonts->new; |
52
|
9
|
|
|
|
|
1335
|
return Text::Amuse::Compile::Fonts::Selected->new(size => 12, |
53
|
|
|
|
|
|
|
sans => ($fonts->sans_fonts)[0], |
54
|
|
|
|
|
|
|
main => ($fonts->serif_fonts)[0], |
55
|
|
|
|
|
|
|
mono => ($fonts->mono_fonts)[0], |
56
|
|
|
|
|
|
|
all_fonts => $fonts, |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
} |