line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Followme::CreateSitemap; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
558
|
use 5.008005; |
|
2
|
|
|
|
|
26
|
|
4
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
5
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
67
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use lib '../..'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
274
|
use base qw(App::Followme::Module); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
593
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
13
|
use File::Spec::Functions qw(catfile); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
103
|
|
12
|
2
|
|
|
2
|
|
12
|
use App::Followme::FIO; |
|
2
|
|
|
|
|
15
|
|
|
2
|
|
|
|
|
858
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our $VERSION = "2.03"; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
17
|
|
|
|
|
|
|
# Read the default parameter values |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub parameters { |
20
|
16
|
|
|
16
|
1
|
32
|
my ($pkg) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
return ( |
23
|
16
|
|
|
|
|
57
|
sitemap => 'sitemap.txt', |
24
|
|
|
|
|
|
|
include_index => 1, |
25
|
|
|
|
|
|
|
data_pkg => 'App::Followme::WebData', |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
30
|
|
|
|
|
|
|
# Write a list of urls in a directory tree |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub run { |
33
|
3
|
|
|
3
|
0
|
7
|
my ($self, $folder) = @_; |
34
|
|
|
|
|
|
|
|
35
|
3
|
|
|
|
|
7
|
my @urls = $self->list_urls($folder); |
36
|
3
|
|
|
|
|
14
|
my $page = join("\n", @urls) . "\n"; |
37
|
|
|
|
|
|
|
|
38
|
3
|
|
|
|
|
15
|
my $filename = catfile($folder, $self->{sitemap}); |
39
|
3
|
|
|
|
|
10
|
fio_write_page($filename, $page); |
40
|
|
|
|
|
|
|
|
41
|
3
|
|
|
|
|
44
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
45
|
|
|
|
|
|
|
# Return a list of the urls of all web pages in a directory |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub list_urls { |
48
|
7
|
|
|
7
|
0
|
30
|
my ($self, $folder) = @_; |
49
|
|
|
|
|
|
|
|
50
|
7
|
|
|
|
|
14
|
my @urls; |
51
|
7
|
|
|
|
|
31
|
my $index_file = $self->to_file($folder); |
52
|
7
|
|
|
|
|
35
|
my $files = $self->{data}->build('files_by_name', $index_file); |
53
|
|
|
|
|
|
|
|
54
|
7
|
|
|
|
|
16
|
foreach my $file (@$files) { |
55
|
|
|
|
|
|
|
# build returns a reference, so must dereference |
56
|
21
|
|
|
|
|
53
|
my $url = $self->{data}->build('remote_url', $file); |
57
|
21
|
|
|
|
|
57
|
push(@urls, $$url); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
7
|
|
|
|
|
17
|
my $folders = $self->{data}->build('folders', $index_file); |
61
|
|
|
|
|
|
|
|
62
|
7
|
|
|
|
|
32
|
foreach my $subfolder (@$folders) { |
63
|
3
|
|
|
|
|
10
|
push(@urls, $self->list_urls($subfolder)); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
7
|
|
|
|
|
32
|
return @urls; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
70
|
|
|
|
|
|
|
# Initialize the extension |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub setup { |
73
|
4
|
|
|
4
|
1
|
8
|
my ($self) = @_; |
74
|
|
|
|
|
|
|
|
75
|
4
|
|
|
|
|
11
|
$self->{extension} = $self->{web_extension}; |
76
|
4
|
|
|
|
|
10
|
return; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=encoding utf-8 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 NAME |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
App::Followme::CreateSitemap - Create a Google sitemap |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 SYNOPSIS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
use App::Followme::Sitemap; |
91
|
|
|
|
|
|
|
my $map = App::Followme::Sitemap->new(); |
92
|
|
|
|
|
|
|
$map->run($folder); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 DESCRIPTION |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This module creates a sitemap file, which is a text file containing the url of |
97
|
|
|
|
|
|
|
every page on the site, one per line. It is also intended as a simple example of |
98
|
|
|
|
|
|
|
how to write a module that can be run by followme. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 CONFIGURATION |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The following field in the configuration file are used: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over 4 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item sitemap |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
The name of the sitemap file. It is written to the directory this module is |
109
|
|
|
|
|
|
|
invoked from. Typically this is the top folder of a site. The default value is |
110
|
|
|
|
|
|
|
sitemap.txt. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item data_pkg |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
The package used to retrieve information from each file contained in the |
115
|
|
|
|
|
|
|
sitemap. The default value is 'App::Followme::WebData'. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 LICENSE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Copyright (C) Bernie Simon. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
124
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHOR |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Bernie Simon E<lt>bernie.simon@gmail.comE<gt> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |