Added WebGUI::URL::setSiteURL
This commit is contained in:
parent
c4725ce72f
commit
23f562b8ff
3 changed files with 25 additions and 8 deletions
|
|
@ -18,6 +18,8 @@ package WebGUI::Export;
|
||||||
use strict;
|
use strict;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::HTML;
|
use WebGUI::HTML;
|
||||||
|
use WebGUI::HTTP;
|
||||||
|
use WebGUI::URL;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
|
|
@ -109,12 +111,12 @@ sub generate {
|
||||||
|
|
||||||
# Set alternate Site URL
|
# Set alternate Site URL
|
||||||
if($self->get('altSiteURL')) {
|
if($self->get('altSiteURL')) {
|
||||||
$session{var}{altSiteURL} = $self->get('altSiteURL');
|
WebGUI::URL::setSiteURL($self->get('altSiteURL'));
|
||||||
} elsif ($self->get('relativeUrls')) {
|
} elsif ($self->get('relativeUrls')) {
|
||||||
$session{var}{altSiteURL} = "./";
|
WebGUI::URL::setSiteURL("./");
|
||||||
my $url = $session{page}{urlizedTitle};
|
my $url = $session{page}{urlizedTitle};
|
||||||
while ($url =~ /\//g) {
|
while ($url =~ /\//g) {
|
||||||
$session{var}{altSiteURL} .= "../";
|
WebGUI::URL::setSiteURL(WebGUI::URL::getSiteURL()."../");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# !!! At this point we make URLs absolute only if altSiteURL is not set.
|
# !!! At this point we make URLs absolute only if altSiteURL is not set.
|
||||||
|
|
@ -127,14 +129,14 @@ sub generate {
|
||||||
|
|
||||||
if($self->get('stripHTML')) {
|
if($self->get('stripHTML')) {
|
||||||
$content = WebGUI::HTML::html2text($content);
|
$content = WebGUI::HTML::html2text($content);
|
||||||
} elsif (not $session{var}{altSiteURL}) { # Implies absolute links
|
} elsif (not $session{url}{siteURL}) { # Implies absolute links
|
||||||
$content = WebGUI::HTML::makeAbsolute($content);
|
$content = WebGUI::HTML::makeAbsolute($content);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restore session
|
# Restore session
|
||||||
%session = %oldSession;
|
%session = %oldSession;
|
||||||
delete $session{page}{noHttpHeader};
|
delete $session{page}{noHttpHeader};
|
||||||
delete $session{var}{altSiteURL};
|
delete $session{url}{siteURL};
|
||||||
return $content;
|
return $content;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,8 @@ sub build {
|
||||||
foreach my $property (@interestingPageProperties) {
|
foreach my $property (@interestingPageProperties) {
|
||||||
$var->{'page.current.'.$property} = $currentPage->get($property);
|
$var->{'page.current.'.$property} = $currentPage->get($property);
|
||||||
}
|
}
|
||||||
unless (defined $cacheContent && ! $session{var}{altSiteURL}) {
|
unless (defined $cacheContent &&
|
||||||
|
! $session{url}{siteURL}) { # Never use cache if an alternate site url is specified.
|
||||||
# The loop was not cached
|
# The loop was not cached
|
||||||
my @pages = eval $method;
|
my @pages = eval $method;
|
||||||
if ($@) {
|
if ($@) {
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ This package provides URL writing functionality. It is important that all WebGUI
|
||||||
$string = WebGUI::URL::escape($string);
|
$string = WebGUI::URL::escape($string);
|
||||||
$url = WebGUI::URL::gateway($url,$pairs);
|
$url = WebGUI::URL::gateway($url,$pairs);
|
||||||
$url = WebGUI::URL::getSiteURL();
|
$url = WebGUI::URL::getSiteURL();
|
||||||
|
WebGUI::URL::setSiteURL($url);
|
||||||
$url = WebGUI::URL::makeCompliant($string);
|
$url = WebGUI::URL::makeCompliant($string);
|
||||||
$url = WebGUI::URL::makeAbsolute($url);
|
$url = WebGUI::URL::makeAbsolute($url);
|
||||||
$url = WebGUI::URL::page($url,$pairs);
|
$url = WebGUI::URL::page($url,$pairs);
|
||||||
|
|
@ -168,14 +169,27 @@ sub makeAbsolute {
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 setSiteURL ( )
|
||||||
|
|
||||||
|
Sets an alternate site url.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub setSiteURL {
|
||||||
|
$session{url}{siteURL} = shift;
|
||||||
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 getSiteURL ( )
|
=head2 getSiteURL ( )
|
||||||
|
|
||||||
Returns a constructed site url from protocol to gateway.
|
Returns a constructed site url from protocol to gateway. The returned
|
||||||
|
value can be overridden using the setSiteURL function.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub getSiteURL {
|
sub getSiteURL {
|
||||||
return $session{var}{altSiteURL} if (defined $session{var}{altSiteURL});
|
return $session{url}{siteURL} if (defined $session{url}{siteURL});
|
||||||
my $site;
|
my $site;
|
||||||
my @sitenames;
|
my @sitenames;
|
||||||
if (ref $session{config}{sitename} eq "ARRAY") {
|
if (ref $session{config}{sitename} eq "ARRAY") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue