added proper mime type handling
git-svn-id: http://yolanda.mister-muffin.de/svn@252 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
parent
feb46a4574
commit
eaeffc6fa2
2 changed files with 75 additions and 36 deletions
|
@ -50,6 +50,7 @@ if($query->param('id'))
|
|||
}
|
||||
|
||||
#in both cases - do some slurp-eaze to the browser
|
||||
#TODO: lol insecure!
|
||||
open(FILE, "<$root/videos/".$query->param('id'));
|
||||
|
||||
$filesize = -s "$root/videos/".$query->param('id');
|
||||
|
|
|
@ -142,10 +142,42 @@ 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($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
|
||||
{
|
||||
if( -f "$root/xsl/$param_xslt.xsl")
|
||||
{
|
||||
$xsltpath = "$root/xsl/$param_xslt.xsl"
|
||||
|
@ -160,8 +192,7 @@ sub output_page
|
|||
# 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(
|
||||
$output = $stylesheet->transform(
|
||||
$parser->parse_string(
|
||||
XMLout(
|
||||
$page,
|
||||
|
@ -172,26 +203,33 @@ sub output_page
|
|||
)
|
||||
);
|
||||
|
||||
if($query->param('cortado') eq 'true')
|
||||
if($param_xslt eq "xspf")
|
||||
{
|
||||
@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)];
|
||||
}
|
||||
|
||||
#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)
|
||||
-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
|
||||
),
|
||||
$foo->toString;
|
||||
$output->toString;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $session->header(
|
||||
-type=>'application/xhtml+xml',
|
||||
-charset=>'UTF-8',
|
||||
-cookie=>@cookies
|
||||
),
|
||||
$output->toString;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue