line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: pack novel/bbs content to html / txt / raw , etc |
2
|
|
|
|
|
|
|
package Novel::Robot::Packer; |
3
|
2
|
|
|
2
|
|
15
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
58
|
|
4
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
52
|
|
5
|
2
|
|
|
2
|
|
396
|
use Encode::Locale; |
|
2
|
|
|
|
|
2824
|
|
|
2
|
|
|
|
|
65
|
|
6
|
2
|
|
|
2
|
|
10
|
use Encode; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
801
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#our $VERSION = 0.21; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
11
|
2
|
|
|
2
|
1
|
7
|
my ( $self, %opt ) = @_; |
12
|
2
|
|
50
|
|
|
7
|
$opt{type} ||= 'html'; |
13
|
2
|
|
|
|
|
7
|
my $module = "Novel::Robot::Packer::$opt{type}"; |
14
|
2
|
|
|
|
|
132
|
eval "require $module;"; |
15
|
2
|
|
|
|
|
23
|
bless {%opt}, $module; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub suffix { |
19
|
0
|
|
|
0
|
0
|
0
|
return ''; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub main { |
23
|
0
|
|
|
0
|
1
|
0
|
my ($self, $bk, %opt) = @_; |
24
|
0
|
|
|
|
|
0
|
return $opt{output}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub format_item_output { |
28
|
1
|
|
|
1
|
0
|
3
|
my ( $self, $bk, $o ) = @_; |
29
|
1
|
50
|
|
|
|
3
|
if ( ! $o->{output} ) { |
30
|
0
|
|
|
|
|
0
|
my $html = ''; |
31
|
|
|
|
|
|
|
$o->{output} = |
32
|
|
|
|
|
|
|
exists $o->{output_scalar} |
33
|
0
|
0
|
|
|
|
0
|
? \$html |
34
|
|
|
|
|
|
|
: $self->format_default_filename($bk, $o); |
35
|
|
|
|
|
|
|
} |
36
|
1
|
|
|
|
|
2
|
return $o->{output}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub format_default_filename { |
40
|
0
|
|
|
0
|
0
|
|
my ( $self, $r, $o) = @_; |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $item_info=''; |
43
|
0
|
0
|
0
|
|
|
|
if(exists $o->{min_item_num} and $o->{min_item_num}>1){ |
|
|
0
|
0
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$item_info="-$o->{min_item_num}"; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif(exists $o->{min_page_num} and $o->{min_page_num}>1){ |
47
|
0
|
|
|
|
|
|
$item_info="-$o->{min_page_num}"; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
my $f = "$r->{writer}-$r->{book}$item_info." . $self->suffix(); |
50
|
0
|
|
|
|
|
|
$f =~ s{[\[\]/><\\`;'\$^*\(\)\%#@!"&:\?|\s^,~]}{}g; |
51
|
0
|
|
|
|
|
|
return encode( locale => $f ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Novel::Robot::Packer - Pack novel/bbs content to html / txt / raw, etc |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |