the Slash_gatewayUrl and PageUrl macros now accept optional URL arguments
This commit is contained in:
parent
dfb19389a7
commit
66b59adde8
7 changed files with 121 additions and 15 deletions
|
|
@ -11,6 +11,7 @@ package WebGUI::Macro::PageUrl;
|
|||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use URI;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
|
@ -20,16 +21,33 @@ Package WebGUI::Macro::Page
|
|||
|
||||
Macro for displaying the url for the current asset.
|
||||
|
||||
=head2 process ( )
|
||||
=head2 process ( $session, $url )
|
||||
|
||||
process is really a wrapper around $session->url->page();
|
||||
|
||||
=head3 $session
|
||||
|
||||
The current WebGUI session variable.
|
||||
|
||||
=head3 $url
|
||||
|
||||
A URL to safely append to the end of the page URL.
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
return $session->url->page();
|
||||
my $url = shift;
|
||||
my $pageUrl = $session->url->page();
|
||||
if ($url) {
|
||||
my $uri = URI->new($pageUrl);
|
||||
##Append the requested URL to the path part of the URL
|
||||
$uri->path(join "/", $uri->path, $url);
|
||||
$pageUrl = $uri->as_string;
|
||||
}
|
||||
$pageUrl =~ tr{/}{/}s; ##Remove duplicate slashes.
|
||||
return $pageUrl;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,16 +20,25 @@ Package WebGUI::Macro::Slash_gatewayUrl
|
|||
|
||||
Macro for returning the gateway URL (defined in the WebGUI config file) to the site.
|
||||
|
||||
=head2 process ( )
|
||||
=head2 process ( $session, $url )
|
||||
|
||||
process is really a wrapper around $session->url->gateway();
|
||||
|
||||
=head3 $session
|
||||
|
||||
A WebGUI session variable.
|
||||
|
||||
=head3 $url
|
||||
|
||||
A url which will be passed to $session->url->gateway().
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub process {
|
||||
my $session = shift;
|
||||
return $session->url->gateway();
|
||||
my $url = shift;
|
||||
return $session->url->gateway($url);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,17 @@ our $I18N = {
|
|||
'page url body' => {
|
||||
message => q|
|
||||
<p><b>^PageUrl;</b><br />
|
||||
<b>^PageUrl(/sub/page);</b><br />
|
||||
The URL to the current page (example: <i>/index.pl/pagename</i>).
|
||||
</p>
|
||||
|
||||
<p>The macro takes a single, optional argument; a URL. The URL will be appended to
|
||||
the end of the page's URL. This is mainly useful when you enable Prevent Proxy Caching
|
||||
in the WebGUI settings.</p>
|
||||
|
||||
<p>This Macro may be nested inside other Macros.</p>
|
||||
|,
|
||||
lastUpdated => 1168622829,
|
||||
lastUpdated => 1169588703,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,11 +15,21 @@ our $I18N = {
|
|||
'gateway url body' => {
|
||||
message => q|
|
||||
<p><b>^/; - System URL</b><br />
|
||||
The URL to the gateway script (example: <i>/index.pl/</i>).
|
||||
</p>
|
||||
<b>^/(/home/page); - System URL</b><br />
|
||||
The URL to the gateway script (example: <i>/</i>).</p>
|
||||
|
||||
<p>The macro takes a single, optional argument; a URL. The URL will be appended to
|
||||
the end of the gateway URL. This is mainly useful when you enable Prevent Proxy Caching
|
||||
in the WebGUI settings.</p>
|
||||
|
||||
<p>^/;home/page will break with Prevent Proxy Caching set because the URL that is made
|
||||
will look like this: /?noCache=37,1127808995home/page. By passing the URL directly to the
|
||||
macro, ^/(home/page);, the special param for disabling caching will be placed on the
|
||||
end, /home/page?noCache=37,1127808995.
|
||||
|
||||
<p>This Macro may be nested inside other Macros.</p>
|
||||
|,
|
||||
lastUpdated => 1168623028,
|
||||
lastUpdated => 1169584181,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue