| 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 | ▶ | use strict; | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||
| 21 | 8 | $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<WE_Frontend::Main> 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<livetransport>. 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<livetransport> may be any of the standard ones: C<rsync>, C<ftp>, | ||||||||||||||||||||||||||||||||||
| 78 | C<ftp-md5sync>, C<rdist>, or C<rdist-ssh>. For custom methods, use | ||||||||||||||||||||||||||||||||||
| 79 | either of the following: | ||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||
| 81 | =over | ||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||
| 83 | =item C<custom:I<method_name>> | ||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||
| 85 | Where I<method_name> has to be a method in the C<WE_Frontend::Main> | ||||||||||||||||||||||||||||||||||
| 86 | namespace and already loaded in | ||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||
| 88 | =item A base class name I<basename> | ||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||
| 90 | This will cause to load a module with the name | ||||||||||||||||||||||||||||||||||
| 91 | C<WE_Frontend::Publish::I<basename>> (with uppercase basename) and | ||||||||||||||||||||||||||||||||||
| 92 | call a method C<publish_I<basename>> (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 | 0 | ▶ | sub publish { | ||||||||||||||||||||||||||||||||
|
Subroutine
publish: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||
| 104 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||
| 106 | 0 | my $livetransport = $self->Config->staging->transport; | |||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if (!defined $livetransport || $livetransport eq '') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $livetransport or $livetransport eq ""
MC/DC0%0/2
not defined $livetransport or $livetransport eq ""
not defined $livetransport
$livetransport eq ""
Truth table0%0/3
not(A) or B
A= not defined $livetransportB= $livetransport eq ""
| |||||||||||||||||||||||||||||||||||
| 109 | 0 | die "Transport protocol WEsiteinfo->staging->transport for publish not defined"; | |||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||
| 111 | 0 | ▶ | if ($livetransport eq 'rsync') { | ||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||
| 112 | 0 | require WE_Frontend::Publish::Rsync; | |||||||||||||||||||||||||||||||||
| 113 | 0 | $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 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 138 | 0 | my($mod, $method) = $livetransport =~ /^(.*)::(.*)$/; | |||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | if (defined $mod && defined $method) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $mod and defined $method
MC/DC0%0/2
defined $mod and defined $method
defined $mod
defined $method
Truth table0%0/3
A and B
A= defined $modB= defined $method
| |||||||||||||||||||||||||||||||||||
| 140 | 0 | my $cmd = "require $mod; 1"; | |||||||||||||||||||||||||||||||||
| 141 | #warn "eval $cmd"; | ||||||||||||||||||||||||||||||||||
| 142 | 0 | eval $cmd; | |||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 144 | 0 | die "Transport protocol WEsiteinfo->staging->transport `$livetransport' can't be handled: $@"; | |||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||
| 146 | 0 | $meth = $method; | |||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if (!$meth) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 150 | 0 | $meth = $self->can('publish_' . $livetransport); | |||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if (!$meth) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 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<searchindexer>. | ||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||
| 166 | C<searchindexer> may take any of the following standard values: | ||||||||||||||||||||||||||||||||||
| 167 | C<htdig> or C<oosearch>. | ||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||
| 169 | =cut | ||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub searchindexer { | ||||||||||||||||||||||||||||||||
|
Subroutine
searchindexer: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||
| 172 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||
| 174 | 0 | my $searchindexer = $self->Config->searchengine->searchindexer; | |||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | if (!defined $searchindexer || $searchindexer eq '') { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not defined $searchindexer or $searchindexer eq ""
MC/DC0%0/2
not defined $searchindexer or $searchindexer eq ""
not defined $searchindexer
$searchindexer eq ""
Truth table0%0/3
not(A) or B
A= not defined $searchindexerB= $searchindexer eq ""
| |||||||||||||||||||||||||||||||||||
| 177 | 0 | die "Search indexer WEsiteinfo->searchengine->searchindexer not defined"; | |||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||
| 179 | 0 | ▶ | if ($searchindexer eq 'htdig') { | ||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||
| 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 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 191 | 0 | my($mod, $method) = $searchindexer =~ /^(.*)::(.*)$/; | |||||||||||||||||||||||||||||||||
| 192 | 0 | my $cmd = "require $mod; 1"; | |||||||||||||||||||||||||||||||||
| 193 | #warn "eval $cmd"; | ||||||||||||||||||||||||||||||||||
| 194 | 0 | eval $cmd; | |||||||||||||||||||||||||||||||||
| 195 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 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 | ▶ | if (!$meth) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 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 | 0 | ▶ | sub linkchecker { | ||||||||||||||||||||||||||||||||
|
Subroutine
linkchecker: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||
| 223 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||
| 224 | 0 | my(%args) = @_; | |||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||
| 226 | 0 | require WE_Frontend::LinkChecker; | |||||||||||||||||||||||||||||||||
| 227 | 0 | my $url = delete $args{-url}; | |||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | if (!$url) { | ||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my $indexhtml = delete $args{-indexhtml} || "home.html"; | ||||||||||||||||||||||||||||||||
|
Condition0%0/2
delete $args{'-indexhtml'} || 'home.html'
MC/DC0%0/1
delete $args{'-indexhtml'} || 'home.html'
delete $args{'-indexhtml'}
Truth table0%0/2
A
A= delete $args{'-indexhtml'}
| |||||||||||||||||||||||||||||||||||
| 230 | 0 | foreach my $lang (@{ $self->Config->project->sitelanguages }) { | |||||||||||||||||||||||||||||||||
| 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<WE_Frontend::Main>, L<WE_Frontend::Main2>. | ||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||
| 249 | =cut | ||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||
| 251 | 8 | 1; | |||||||||||||||||||||||||||||||||