sub url_ex {
my $q = shift || die "suff2file needs CGI object!";
my $tpl = shift || die "url_ex needs template name!";
- return suff2file($BASE_PATH, $q->url(-path => 1),$TEMPLATE_PATH,$tpl);
+ return suff2file($BASE_PATH, $q->url(-absolute => 1,-path => 1),$TEMPLATE_PATH,$tpl);
}
sub suff2file($$$$) {
# strip everything to and including base path, leaving only
# additional (virtual) path
- if ($p =~ s,^.*?$base_path,,) {
+ if ($base_path eq "/") {
+ $p =~ s,/*,,g;
+ my ($name,$ext) = split(/\./,$tpl);
+ $p = $name . "-" . $p . "." . $ext;
+ } elsif ($p =~ s,^.*?$base_path,,) {
$p =~ s,/*,,g;
my ($name,$ext) = split(/\./,$tpl);
$p = $name . $p . "." . $ext;
die "can't parse TEMPLATE path";
}
- my $master_tpl = suff2file($BASE_PATH, $q->url(-path => 1),$dir,$tpl);
+ my $master_tpl = suff2file($BASE_PATH, $q->url(-absolute => 1, -path => 1),$dir,$tpl);
if (open(T, $master_tpl)) {
my $template_html = join("\n",<T>);
close(T);