getUrlPermutations, and a stub for Content::Asset::dispatch so the test doesn't die.
This commit is contained in:
parent
32a75ebe38
commit
35284c0753
2 changed files with 56 additions and 5 deletions
|
|
@ -19,6 +19,7 @@ use LWP::MediaTypes qw(guess_media_type);
|
|||
use Time::HiRes;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::PassiveAnalytics::Logging;
|
||||
use URI;
|
||||
|
||||
use Apache2::Const -compile => qw(OK);
|
||||
|
||||
|
|
@ -43,6 +44,20 @@ These subroutines are available from this package:
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 dispatch ( $session, $assetUrl )
|
||||
|
||||
Returns the output from an asset.
|
||||
|
||||
=cut
|
||||
|
||||
sub dispatch {
|
||||
my $session = shift;
|
||||
my $assetUrl = shift;
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getAsset ( session [, assetUrl ] )
|
||||
|
||||
Returns an asset based upon the requested asset URL, or optionally pass one in.
|
||||
|
|
@ -75,6 +90,37 @@ sub getRequestedAssetUrl {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getUrlPermutations ( $url )
|
||||
|
||||
Returns an array reference of permutations for the URL.
|
||||
|
||||
=head3 $url
|
||||
|
||||
The URL to permute.
|
||||
|
||||
=cut
|
||||
|
||||
sub getUrlPermutations {
|
||||
my $url = shift;
|
||||
my @permutations = ();
|
||||
return \@permutations if !$url;
|
||||
push @permutations, $url;
|
||||
if ($url =~ /\.\w+$/) {
|
||||
$url =~ s/\.\w+$//;
|
||||
push @permutations, $url;
|
||||
}
|
||||
my $uri = URI->new($url);
|
||||
my @fragments = $uri->path_segments();
|
||||
pop @fragments;
|
||||
while (@fragments > 1) {
|
||||
push @permutations, join "/", @fragments;
|
||||
pop @fragments;
|
||||
}
|
||||
return \@permutations;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 handler ( session )
|
||||
|
||||
The content handler for this package.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue