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