line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Text::Amuse::Compile::Devel; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
3949
|
use utf8; |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
52
|
|
4
|
8
|
|
|
8
|
|
246
|
use strict; |
|
8
|
|
|
|
|
18
|
|
|
8
|
|
|
|
|
162
|
|
5
|
8
|
|
|
8
|
|
39
|
use warnings; |
|
8
|
|
|
|
|
20
|
|
|
8
|
|
|
|
|
222
|
|
6
|
8
|
|
|
8
|
|
1593
|
use Text::Amuse::Compile::Utils qw/write_file read_file/; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
555
|
|
7
|
8
|
|
|
8
|
|
949
|
use Text::Amuse::Compile::Fonts; |
|
8
|
|
|
|
|
28
|
|
|
8
|
|
|
|
|
219
|
|
8
|
8
|
|
|
8
|
|
1018
|
use Text::Amuse::Compile::Fonts::Selected; |
|
8
|
|
|
|
|
19
|
|
|
8
|
|
|
|
|
219
|
|
9
|
8
|
|
|
8
|
|
1086
|
use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); |
|
8
|
|
|
|
|
82768
|
|
|
8
|
|
|
|
|
4702
|
|
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
|
22345
|
my $epub = shift; |
34
|
5
|
|
|
|
|
45
|
my $zip = Archive::Zip->new; |
35
|
5
|
50
|
|
|
|
238
|
die "Couldn't read $epub" if $zip->read($epub) != AZ_OK; |
36
|
5
|
|
|
|
|
23208
|
my $tmpdir = File::Temp->newdir(CLEANUP => 1); |
37
|
5
|
50
|
|
|
|
2582
|
$zip->extractTree('OPS', $tmpdir->dirname) == AZ_OK |
38
|
|
|
|
|
|
|
or die "Cannot extract $epub OPS into $tmpdir"; |
39
|
5
|
50
|
|
|
|
128967
|
opendir (my $dh, $tmpdir->dirname) or die $!; |
40
|
5
|
|
|
|
|
389
|
my @pieces = sort grep { /\Apiece\d+\.xhtml\z/ } readdir($dh); |
|
80
|
|
|
|
|
244
|
|
41
|
5
|
|
|
|
|
72
|
closedir $dh; |
42
|
5
|
|
|
|
|
20
|
my @html; |
43
|
5
|
|
|
|
|
26
|
foreach my $piece ('toc.ncx', 'titlepage.xhtml', @pieces) { |
44
|
58
|
|
|
|
|
300
|
push @html, "", |
45
|
|
|
|
|
|
|
read_file(File::Spec->catfile($tmpdir->dirname, $piece)); |
46
|
|
|
|
|
|
|
} |
47
|
5
|
|
|
|
|
160
|
return join('', @html); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub create_font_object { |
51
|
9
|
|
|
9
|
1
|
18674
|
my $fonts = Text::Amuse::Compile::Fonts->new; |
52
|
9
|
|
|
|
|
1499
|
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
|
|
|
|
|
|
|
} |