line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# $Id: MainCommon.pm,v 1.8 2004/10/26 11:38:44 eserte Exp $ |
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright (C) 2002 Online Office Berlin. All rights reserved. |
8
|
|
|
|
|
|
|
# Copyright (C) 2002 Slaven Rezic. |
9
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the |
10
|
|
|
|
|
|
|
# terms of the GNU General Public License, see the file COPYING. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
14
|
|
|
|
|
|
|
# WWW: http://we-framework.sourceforge.net |
15
|
|
|
|
|
|
|
# |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package WE_Frontend::MainCommon; |
18
|
|
|
|
|
|
|
|
19
|
8
|
|
|
8
|
|
49
|
use strict; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
284
|
|
20
|
8
|
|
|
8
|
|
38
|
use vars qw($VERSION); |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
9152
|
|
21
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package WE_Frontend::Main; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
WE_Frontend::MainCommon - common methods for all WE_Frontend::Main* modules |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Do not use this module at its own!!! Just consult the methods. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 DESCRIPTION |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Note that all methods are loaded into the C namespace. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 METHODS |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=over 4 |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=item publish |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Use the appropriate publish method according to the |
44
|
|
|
|
|
|
|
WEsiteinfo::Staging config member C. May return a hash |
45
|
|
|
|
|
|
|
reference with following members: |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over 4 |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item Directories |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
List reference of published directories. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item Files |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
List reference of published files. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Options to publish: |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=over 4 |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=item -verbose |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Be verbose if set to true. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item -adddirectories |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Reference to an array with additional directories to be published. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item -addfiles |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Reference to an array with additional files to be published. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
C may be any of the standard ones: C, C, |
78
|
|
|
|
|
|
|
C, C, or C. For custom methods, use |
79
|
|
|
|
|
|
|
either of the following: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=over |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item C> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Where I has to be a method in the C |
86
|
|
|
|
|
|
|
namespace and already loaded in |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=item A base class name I |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This will cause to load a module with the name |
91
|
|
|
|
|
|
|
C> (with uppercase basename) and |
92
|
|
|
|
|
|
|
call a method C> (lowercase). |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item A fully qualified method |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
This will case to require the module (based on the package name of the |
97
|
|
|
|
|
|
|
method) and call this method. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=back |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub publish { |
104
|
2
|
|
|
2
|
|
2880
|
my $self = shift; |
105
|
|
|
|
|
|
|
|
106
|
2
|
|
|
|
|
18
|
my $livetransport = $self->Config->staging->transport; |
107
|
|
|
|
|
|
|
|
108
|
2
|
50
|
33
|
|
|
41
|
if (!defined $livetransport || $livetransport eq '') { |
109
|
0
|
|
|
|
|
0
|
die "Transport protocol WEsiteinfo->staging->transport for publish not defined"; |
110
|
|
|
|
|
|
|
} |
111
|
2
|
50
|
|
|
|
11
|
if ($livetransport eq 'rsync') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
112
|
2
|
|
|
|
|
753
|
require WE_Frontend::Publish::Rsync; |
113
|
2
|
|
|
|
|
20
|
$self->publish_rsync(@_); |
114
|
|
|
|
|
|
|
} elsif ($livetransport eq 'ftp') { |
115
|
0
|
|
|
|
|
|
require WE_Frontend::Publish::FTP; |
116
|
0
|
|
|
|
|
|
$self->publish_ftp(@_); |
117
|
|
|
|
|
|
|
} elsif ($livetransport eq 'ftp-md5sync') { |
118
|
0
|
|
|
|
|
|
require WE_Frontend::Publish::FTP_MD5Sync; |
119
|
0
|
|
|
|
|
|
$self->publish_ftp_md5sync(@_); |
120
|
|
|
|
|
|
|
} elsif ($livetransport eq 'rdist') { |
121
|
0
|
|
|
|
|
|
require WE_Frontend::Publish::Rdist; |
122
|
0
|
|
|
|
|
|
$self->publish_rdist(@_); |
123
|
|
|
|
|
|
|
} elsif ($livetransport eq 'rdist-ssh') { |
124
|
0
|
|
|
|
|
|
require WE_Frontend::Publish::Rdist; |
125
|
0
|
|
|
|
|
|
$self->publish_rdist(@_, -transport => 'ssh'); |
126
|
|
|
|
|
|
|
} elsif ($livetransport eq 'tgz') { |
127
|
0
|
|
|
|
|
|
require WE_Frontend::Publish::Tgz; |
128
|
0
|
|
|
|
|
|
$self->publish_tgz(@_); |
129
|
|
|
|
|
|
|
} elsif ($livetransport =~ /^custom:(.*)/) { |
130
|
0
|
|
|
|
|
|
my $method = $1; |
131
|
0
|
|
|
|
|
|
$self->$method(@_); |
132
|
|
|
|
|
|
|
} else { |
133
|
0
|
|
|
|
|
|
my $meth; |
134
|
0
|
|
|
|
|
|
my $cmd = "require WE_Frontend::Publish::" . ucfirst($livetransport) . "; 1"; |
135
|
|
|
|
|
|
|
#warn "eval $cmd"; |
136
|
0
|
|
|
|
|
|
eval $cmd; |
137
|
0
|
0
|
|
|
|
|
if ($@) { |
138
|
0
|
|
|
|
|
|
my($mod, $method) = $livetransport =~ /^(.*)::(.*)$/; |
139
|
0
|
0
|
0
|
|
|
|
if (defined $mod && defined $method) { |
140
|
0
|
|
|
|
|
|
my $cmd = "require $mod; 1"; |
141
|
|
|
|
|
|
|
#warn "eval $cmd"; |
142
|
0
|
|
|
|
|
|
eval $cmd; |
143
|
0
|
0
|
|
|
|
|
if ($@) { |
144
|
0
|
|
|
|
|
|
die "Transport protocol WEsiteinfo->staging->transport `$livetransport' can't be handled: $@"; |
145
|
|
|
|
|
|
|
} |
146
|
0
|
|
|
|
|
|
$meth = $method; |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
} |
149
|
0
|
0
|
|
|
|
|
if (!$meth) { |
150
|
0
|
|
|
|
|
|
$meth = $self->can('publish_' . $livetransport); |
151
|
|
|
|
|
|
|
} |
152
|
0
|
0
|
|
|
|
|
if (!$meth) { |
153
|
0
|
|
|
|
|
|
die "Publish method for `$livetransport' not defined"; |
154
|
|
|
|
|
|
|
} |
155
|
0
|
|
|
|
|
|
$self->$meth(@_); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item searchindexer |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
XXX This method is not used XXX. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Use the appropriate search indexer method according to the |
164
|
|
|
|
|
|
|
WEsiteinfo::SearchEngine config member C. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
C may take any of the following standard values: |
167
|
|
|
|
|
|
|
C or C. |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=cut |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
sub searchindexer { |
172
|
0
|
|
|
0
|
|
|
my $self = shift; |
173
|
|
|
|
|
|
|
|
174
|
0
|
|
|
|
|
|
my $searchindexer = $self->Config->searchengine->searchindexer; |
175
|
|
|
|
|
|
|
|
176
|
0
|
0
|
0
|
|
|
|
if (!defined $searchindexer || $searchindexer eq '') { |
177
|
0
|
|
|
|
|
|
die "Search indexer WEsiteinfo->searchengine->searchindexer not defined"; |
178
|
|
|
|
|
|
|
} |
179
|
0
|
0
|
|
|
|
|
if ($searchindexer eq 'htdig') { |
|
|
0
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
require WE_Frontend::SearchIndexer::Htdig; |
181
|
0
|
|
|
|
|
|
$self->searchindexer_htdig(@_); |
182
|
|
|
|
|
|
|
} elsif ($searchindexer eq 'oosearch') { |
183
|
0
|
|
|
|
|
|
require WE_Frontend::SearchIndexer::OOSearch; |
184
|
0
|
|
|
|
|
|
$self->searchindexer_oosearch(@_); |
185
|
|
|
|
|
|
|
} else { |
186
|
0
|
|
|
|
|
|
my $meth; |
187
|
0
|
|
|
|
|
|
my $cmd = "require WE_Frontend::SearchIndexer::" . ucfirst($searchindexer) . "; 1"; |
188
|
|
|
|
|
|
|
#warn "eval $cmd"; |
189
|
0
|
|
|
|
|
|
eval $cmd; |
190
|
0
|
0
|
|
|
|
|
if ($@) { |
191
|
0
|
|
|
|
|
|
my($mod, $method) = $searchindexer =~ /^(.*)::(.*)$/; |
192
|
0
|
|
|
|
|
|
my $cmd = "require $mod; 1"; |
193
|
|
|
|
|
|
|
#warn "eval $cmd"; |
194
|
0
|
|
|
|
|
|
eval $cmd; |
195
|
0
|
0
|
|
|
|
|
if ($@) { |
196
|
0
|
|
|
|
|
|
die "Transport protocol WEsiteinfo->searchengine->searchindexer is unknown: $@"; |
197
|
|
|
|
|
|
|
} |
198
|
0
|
|
|
|
|
|
$meth = $method; |
199
|
|
|
|
|
|
|
} else { |
200
|
0
|
|
|
|
|
|
$meth = $self->can('searchindexer_' . $searchindexer); |
201
|
|
|
|
|
|
|
} |
202
|
0
|
0
|
|
|
|
|
if (!$meth) { |
203
|
0
|
|
|
|
|
|
die "Search indexer for $searchindexer not defined"; |
204
|
|
|
|
|
|
|
} |
205
|
0
|
|
|
|
|
|
$self->$meth(@_); |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=item linkchecker |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Checks recursively all links from C<-url> (which may be a scalar or an |
212
|
|
|
|
|
|
|
array reference), or for all languages homepages. By default, the |
213
|
|
|
|
|
|
|
language homepages should be in |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
$c->paths->rooturl . "/html/" . $lang . "/" . "home.html" |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
but the last part ("home.html") can be changed by the C<-indexhtml> |
218
|
|
|
|
|
|
|
argument. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=cut |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub linkchecker { |
223
|
0
|
|
|
0
|
|
|
my $self = shift; |
224
|
0
|
|
|
|
|
|
my(%args) = @_; |
225
|
|
|
|
|
|
|
|
226
|
0
|
|
|
|
|
|
require WE_Frontend::LinkChecker; |
227
|
0
|
|
|
|
|
|
my $url = delete $args{-url}; |
228
|
0
|
0
|
|
|
|
|
if (!$url) { |
229
|
0
|
|
0
|
|
|
|
my $indexhtml = delete $args{-indexhtml} || "home.html"; |
230
|
0
|
|
|
|
|
|
foreach my $lang (@{ $self->Config->project->sitelanguages }) { |
|
0
|
|
|
|
|
|
|
231
|
0
|
|
|
|
|
|
push @$url, $self->Config->paths->rooturl . "/html/" . $lang . "/$indexhtml"; |
232
|
|
|
|
|
|
|
} |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
my $lc = WE_Frontend::LinkChecker->new(-url => $url, %args); |
236
|
0
|
|
|
|
|
|
$lc->check_html; |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=back |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 AUTHOR |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Slaven Rezic - slaven@rezic.de |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 SEE ALSO |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
L, L. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
1; |