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); |
225 |
return $html; |
return $html; |
226 |
} |
} |
227 |
|
|
228 |
|
my $sort = 'swishrank'; |
229 |
|
if ($q->param("sort")) { |
230 |
|
$sort = 'headline'; |
231 |
|
push @persist_vars, "sort"; |
232 |
|
} |
233 |
|
|
234 |
# call swish |
# call swish |
235 |
my $sh = SWISH->connect('Fork', |
my $sh = SWISH->connect('Fork', |
236 |
prog => $SWISH, |
prog => $SWISH, |
248 |
|
|
249 |
}, |
}, |
250 |
#startnum => 0, |
#startnum => 0, |
251 |
maxhits => $MAX_HITS |
maxhits => $MAX_HITS, |
252 |
|
sortorder => $sort, |
253 |
); |
); |
254 |
|
|
255 |
die $SWISH::errstr unless $sh; |
die $SWISH::errstr unless $sh; |