| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Bookmarks::Netscape; |
|
4
|
5
|
|
|
5
|
|
18
|
use Bookmarks::Parser; |
|
|
5
|
|
|
|
|
5
|
|
|
|
5
|
|
|
|
|
119
|
|
|
5
|
5
|
|
|
5
|
|
16
|
use base 'Bookmarks::Parser'; |
|
|
5
|
|
|
|
|
5
|
|
|
|
5
|
|
|
|
|
370
|
|
|
6
|
5
|
|
|
5
|
|
18
|
use warnings; |
|
|
5
|
|
|
|
|
4
|
|
|
|
5
|
|
|
|
|
87
|
|
|
7
|
5
|
|
|
5
|
|
2925
|
use HTML::TreeBuilder; |
|
|
5
|
|
|
|
|
109490
|
|
|
|
5
|
|
|
|
|
43
|
|
|
8
|
5
|
|
|
5
|
|
227
|
use 5.008; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
2827
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my %bookmark_fields = ( |
|
11
|
|
|
|
|
|
|
'created' => 'add_date', |
|
12
|
|
|
|
|
|
|
'modified' => 'last_modified', |
|
13
|
|
|
|
|
|
|
'visited' => 'last_visit', |
|
14
|
|
|
|
|
|
|
'charset' => 'last_charset', |
|
15
|
|
|
|
|
|
|
'url' => 'href', |
|
16
|
|
|
|
|
|
|
'name' => 'content', |
|
17
|
|
|
|
|
|
|
'id' => 'id', |
|
18
|
|
|
|
|
|
|
'personal' => 'personal_toolbar_folder', |
|
19
|
|
|
|
|
|
|
'icon' => 'icon', |
|
20
|
|
|
|
|
|
|
'description' => undef, |
|
21
|
|
|
|
|
|
|
'expanded' => undef, |
|
22
|
|
|
|
|
|
|
'panel' => 'web_panel', |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub _parse_file { |
|
26
|
0
|
|
|
0
|
|
|
my ($self, $filename) = @_; |
|
27
|
|
|
|
|
|
|
|
|
28
|
0
|
0
|
|
|
|
|
return undef if (!-e $filename); |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $bookmarks = HTML::TreeBuilder->new(); |
|
31
|
0
|
|
|
|
|
|
$bookmarks->parse_file($filename); |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $title = $bookmarks->look_down(_tag => 'title')->as_text(); |
|
34
|
0
|
|
|
|
|
|
$self->set_title($title); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my @items = $bookmarks->look_down( |
|
37
|
|
|
|
|
|
|
sub { |
|
38
|
0
|
0
|
|
0
|
|
|
$_[0]->tag =~ /^(h3|a)$/ |
|
39
|
|
|
|
|
|
|
&& $_[0]->depth == 4; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
0
|
|
|
|
|
|
); |
|
42
|
0
|
|
|
|
|
|
foreach my $item (@items) { |
|
43
|
0
|
|
|
|
|
|
_parse_item($self, $item); |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
$bookmarks->delete(); |
|
47
|
0
|
|
|
|
|
|
return $self; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _parse_item { |
|
52
|
0
|
|
|
0
|
|
|
my ($self, $item, $parent) = @_; |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my %item_info; |
|
55
|
0
|
|
|
|
|
|
@item_info{ keys %bookmark_fields } |
|
56
|
0
|
|
|
|
|
|
= (map { $item->attr($_) } values %bookmark_fields); |
|
57
|
0
|
|
|
|
|
|
$item_info{name} = $item->content()->[0]; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# $item_info{parent} = $parent; |
|
60
|
0
|
0
|
|
|
|
|
if (!$item_info{id}) { |
|
61
|
0
|
|
|
|
|
|
$item_info{id} = $self->{_nextid}++; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
0
|
0
|
|
|
|
|
if ($item->attr('href')) { |
|
64
|
0
|
|
|
|
|
|
$item_info{type} = 'url'; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
else { |
|
67
|
0
|
|
|
|
|
|
$item_info{type} = 'folder'; |
|
68
|
0
|
|
|
|
|
|
my $sibling = $item->parent->right(); |
|
69
|
0
|
0
|
0
|
|
|
|
if (defined $sibling && lc $sibling && $sibling->tag() eq 'dd') { |
|
|
|
|
0
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
$item_info{description} = $sibling->as_text(); |
|
71
|
0
|
|
|
|
|
|
$item = $sibling; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
} |
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
$self->add_bookmark(\%item_info, $parent); |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
0
|
|
|
|
|
if ($item_info{type} eq 'folder') { |
|
78
|
0
|
0
|
|
|
|
|
my @subitems = map { $_->tag() eq 'dt' ? ($_->content_list)[0] : () } |
|
|
0
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$item->right->content_list(); |
|
80
|
0
|
|
|
|
|
|
foreach my $subitem (@subitems) { |
|
81
|
0
|
|
|
|
|
|
_parse_item($self, $subitem, $item_info{id}); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub get_header_as_string { |
|
87
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $header = << "HTML"; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$self->{_title} |
|
96
|
|
|
|
|
|
|
$self->{_title} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
HTML |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return $header; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub get_item_as_string { |
|
105
|
0
|
|
|
0
|
1
|
|
my ($self, $item) = @_; |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
0
|
0
|
|
|
|
if (!defined $item->{id} || !$self->{_items}{ $item->{id} }) { |
|
108
|
0
|
|
|
|
|
|
warn "No such item in get_item_as_string"; |
|
109
|
0
|
|
|
|
|
|
return; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
my $string = ''; |
|
113
|
0
|
|
0
|
|
|
|
my ($url, $name, $visited, $created, $modified, $id, $icon, $charset, |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
114
|
|
|
|
|
|
|
$panel) = ( |
|
115
|
|
|
|
|
|
|
$item->{url} || '', |
|
116
|
|
|
|
|
|
|
$item->{name} || '', |
|
117
|
|
|
|
|
|
|
$item->{visited} || 0, |
|
118
|
|
|
|
|
|
|
$item->{created} || 0, |
|
119
|
|
|
|
|
|
|
$item->{modified} || 0, |
|
120
|
|
|
|
|
|
|
$item->{id} || 0, |
|
121
|
|
|
|
|
|
|
$item->{icon} || '', |
|
122
|
|
|
|
|
|
|
$item->{charset} || '', |
|
123
|
|
|
|
|
|
|
$item->{panel} || '' |
|
124
|
|
|
|
|
|
|
); |
|
125
|
0
|
0
|
|
|
|
|
if ($item->{type} eq 'folder') { |
|
|
|
0
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
$string .= << "HTML"; |
|
127
|
|
|
|
|
|
|
$name |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
HTML |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
$string .= $self->get_item_as_string($self->{_items}{$_}) |
|
132
|
0
|
|
|
|
|
|
foreach (@{ $item->{children} }); |
|
133
|
0
|
|
|
|
|
|
$string .= << "HTML"; |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
HTML |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
elsif ($item->{type} eq 'url') { |
|
139
|
0
|
|
|
|
|
|
$string .= << "HTML"; |
|
140
|
|
|
|
|
|
|
$name |
|
141
|
|
|
|
|
|
|
HTML |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
return $string; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub get_footer_as_string { |
|
148
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
my $footer = << "HTML"; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
HTML |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
return $footer; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
1; |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
__END__ |