|
|
|
@ -142,26 +142,57 @@ sub output_page
|
|
|
|
|
my $parser = XML::LibXML->new();
|
|
|
|
|
my $xslt = XML::LibXSLT->new();
|
|
|
|
|
|
|
|
|
|
if($query->param('cortado') eq 'true')
|
|
|
|
|
{
|
|
|
|
|
@cookies = [$session->cookie(-name=>$session_name, -value=>$session->id), $session->cookie(-name=>'cortado', -value=>'true')];
|
|
|
|
|
}
|
|
|
|
|
elsif($query->param('cortado') eq 'false')
|
|
|
|
|
{
|
|
|
|
|
@cookies = [$session->cookie(-name=>$session_name, -value=>$session->id), $session->cookie(-name=>'cortado', -value=>'false')];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@cookies = [$session->cookie(-name=>$session_name, -value=>$session->id)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#let the XSLT param choose other stylesheets or default to xhtml.xsl
|
|
|
|
|
my $param_xslt = $query->param('xslt');
|
|
|
|
|
$param_xslt =~ s/[^\w]//gi;
|
|
|
|
|
|
|
|
|
|
if( -f "$root/xsl/$param_xslt.xsl")
|
|
|
|
|
{
|
|
|
|
|
$xsltpath = "$root/xsl/$param_xslt.xsl"
|
|
|
|
|
if($param_xslt eq "null")
|
|
|
|
|
{
|
|
|
|
|
$output = $parser->parse_string(
|
|
|
|
|
XMLout(
|
|
|
|
|
$page,
|
|
|
|
|
KeyAttr => {},
|
|
|
|
|
RootName => 'page',
|
|
|
|
|
AttrIndent => '1'
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
return $session->header(
|
|
|
|
|
-type=>'application/xml',
|
|
|
|
|
-charset=>'UTF-8',
|
|
|
|
|
-cookie=>@cookies
|
|
|
|
|
),
|
|
|
|
|
$output->toString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$xsltpath = "$root/xsl/xhtml.xsl";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file($xsltpath));
|
|
|
|
|
if( -f "$root/xsl/$param_xslt.xsl")
|
|
|
|
|
{
|
|
|
|
|
$xsltpath = "$root/xsl/$param_xslt.xsl"
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$xsltpath = "$root/xsl/xhtml.xsl";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my $stylesheet = $xslt->parse_stylesheet($parser->parse_file($xsltpath));
|
|
|
|
|
|
|
|
|
|
# TODO: this usage of libxsl omits the xsl:output definition (no ident of html) but outputs in UTF8
|
|
|
|
|
# TODO: later versions of XML::LibXSLT (>= 1.62) define output_as_bytes - this is what we want to use
|
|
|
|
|
# TODO: wait for debian packagers to update to 1.62 or later
|
|
|
|
|
# TODO: "foo" is not a meaningful variable name
|
|
|
|
|
$foo = $stylesheet->transform(
|
|
|
|
|
# TODO: this usage of libxsl omits the xsl:output definition (no ident of html) but outputs in UTF8
|
|
|
|
|
# TODO: later versions of XML::LibXSLT (>= 1.62) define output_as_bytes - this is what we want to use
|
|
|
|
|
# TODO: wait for debian packagers to update to 1.62 or later
|
|
|
|
|
$output = $stylesheet->transform(
|
|
|
|
|
$parser->parse_string(
|
|
|
|
|
XMLout(
|
|
|
|
|
$page,
|
|
|
|
@ -171,27 +202,34 @@ sub output_page
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if($query->param('cortado') eq 'true')
|
|
|
|
|
{
|
|
|
|
|
@cookies = [$session->cookie(-name=>$session_name, -value=>$session->id), $session->cookie(-name=>'cortado', -value=>'true')];
|
|
|
|
|
}
|
|
|
|
|
elsif($query->param('cortado') eq 'false')
|
|
|
|
|
{
|
|
|
|
|
@cookies = [$session->cookie(-name=>$session_name, -value=>$session->id), $session->cookie(-name=>'cortado', -value=>'false')];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@cookies = [$session->cookie(-name=>$session_name, -value=>$session->id)];
|
|
|
|
|
|
|
|
|
|
if($param_xslt eq "xspf")
|
|
|
|
|
{
|
|
|
|
|
return $session->header(
|
|
|
|
|
-type=>'application/xspf+xml',
|
|
|
|
|
-charset=>'UTF-8',
|
|
|
|
|
-attachment=>$query->param('query').".xspf",
|
|
|
|
|
-cookie=>@cookies
|
|
|
|
|
),
|
|
|
|
|
$output->toString;
|
|
|
|
|
}
|
|
|
|
|
elsif($param_xslt eq "rss")
|
|
|
|
|
{
|
|
|
|
|
return $session->header(
|
|
|
|
|
-type=>'application/rss+xml',
|
|
|
|
|
-charset=>'UTF-8',
|
|
|
|
|
-cookie=>@cookies
|
|
|
|
|
),
|
|
|
|
|
$output->toString;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return $session->header(
|
|
|
|
|
-type=>'application/xhtml+xml',
|
|
|
|
|
-charset=>'UTF-8',
|
|
|
|
|
-cookie=>@cookies
|
|
|
|
|
),
|
|
|
|
|
$output->toString;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#send everything including http headers to the user - if XSLT chosen is XSPF set download filename
|
|
|
|
|
return $session->header(
|
|
|
|
|
-type=>'application/xhtml+xml',
|
|
|
|
|
# TODO: fix the MIME type so that every XSLT works again
|
|
|
|
|
# (you earned eternal hate for this, josch)
|
|
|
|
|
-charset=>'UTF-8',
|
|
|
|
|
-cookie=>@cookies
|
|
|
|
|
),
|
|
|
|
|
$foo->toString;
|
|
|
|
|
}
|
|
|
|
|