43 |
sub url_ex { |
sub url_ex { |
44 |
my $q = shift || die "suff2file needs CGI object!"; |
my $q = shift || die "suff2file needs CGI object!"; |
45 |
my $tpl = shift || die "url_ex needs template name!"; |
my $tpl = shift || die "url_ex needs template name!"; |
46 |
return suff2file($BASE_PATH, $q->url(-path => 1),$TEMPLATE_PATH,$tpl); |
return suff2file($BASE_PATH, $q->url(-absolute => 1,-path => 1),$TEMPLATE_PATH,$tpl); |
47 |
} |
} |
48 |
|
|
49 |
sub suff2file($$$$) { |
sub suff2file($$$$) { |
53 |
|
|
54 |
# strip everything to and including base path, leaving only |
# strip everything to and including base path, leaving only |
55 |
# additional (virtual) path |
# additional (virtual) path |
56 |
if ($p =~ s,^.*?$base_path,,) { |
if ($base_path eq "/") { |
57 |
|
$p =~ s,/*,,g; |
58 |
|
my ($name,$ext) = split(/\./,$tpl); |
59 |
|
$p = $name . "-" . $p . "." . $ext; |
60 |
|
} elsif ($p =~ s,^.*?$base_path,,) { |
61 |
$p =~ s,/*,,g; |
$p =~ s,/*,,g; |
62 |
my ($name,$ext) = split(/\./,$tpl); |
my ($name,$ext) = split(/\./,$tpl); |
63 |
$p = $name . $p . "." . $ext; |
$p = $name . $p . "." . $ext; |
101 |
die "can't parse TEMPLATE path"; |
die "can't parse TEMPLATE path"; |
102 |
} |
} |
103 |
|
|
104 |
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); |
105 |
if (open(T, $master_tpl)) { |
if (open(T, $master_tpl)) { |
106 |
my $template_html = join("\n",<T>); |
my $template_html = join("\n",<T>); |
107 |
close(T); |
close(T); |