shit works

git-svn-id: http://yolanda.mister-muffin.de/svn@249 7eef14d0-6ed0-489d-bf55-20463b2d70db
This commit is contained in:
erlehmann 2008-03-07 20:13:35 +00:00
parent d29472ed63
commit 3de6765d56
5 changed files with 71 additions and 348 deletions

View file

@ -126,7 +126,7 @@ sub fill_results
$sth->finish() or die $dbh->errstr;
}
#replace chars in url as said in this rfc: http://www.rfc-editor.org/rfc/rfc1738.txt
#replace chars in url according to RFC 1738 <http://www.rfc-editor.org/rfc/rfc1738.txt>
sub urlencode
{
my ($url) = @_[0];
@ -142,7 +142,7 @@ sub output_page
my $parser = XML::LibXML->new();
my $xslt = XML::LibXSLT->new();
#let the xslt param choose other stylesheets or default to xhtml.xsl
#let the XSLT param choose other stylesheets or default to xhtml.xsl
my $param_xslt = $query->param('xslt');
$param_xslt =~ s/[^\w]//gi;
@ -157,9 +157,10 @@ sub output_page
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: 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(
$parser->parse_string(
XMLout(
@ -170,7 +171,7 @@ sub output_page
)
)
);
if($query->param('cortado') eq 'true')
{
@cookies = [$session->cookie(-name=>$session_name, -value=>$session->id), $session->cookie(-name=>'cortado', -value=>'true')];
@ -184,10 +185,11 @@ sub output_page
@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
#send everything including http headers to the user - if XSLT chosen is XSPF set download filename
return $session->header(
-type=>'application/xhtml+xml',
# fix the MIME type so that every XSLT works again
# TODO: fix the MIME type so that every XSLT works again
# (you earned eternal hate for this, josch)
-charset=>'UTF-8',
-cookie=>@cookies
),

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB

View file

@ -156,7 +156,8 @@
<string id="language_de-de">German</string>
<!-- video page -->
<string id="download_video">download</string>
<string id="video_download">download</string>
<string id="video_playback">plackback</string>
<string id="junk_video">mark as junk</string>
<string id="edit_video">edit</string>
<string id="megabytes">MB</string>

View file

@ -19,13 +19,17 @@
<xsl:include href="./xhtml/advancedsearch.xsl"/>
<xsl:include href="./xhtml/embedded.xsl"/>
<xsl:include href="./xhtml/footer.xsl"/>
<xsl:include href="./xhtml/frontpage.xsl"/>
<xsl:include href="./xhtml/header.xsl"/>
<xsl:include href="./xhtml/loginform.xsl"/>
<xsl:include href="./xhtml/register.xsl"/>
<xsl:include href="./xhtml/results.xsl"/>
<xsl:include href="./xhtml/settings.xsl"/>
<xsl:include href="./xhtml/upload.xsl"/>
<xsl:include href="./xhtml/video.xsl"/>
<xsl:include href="./xhtml/xhtml-body.xsl"/>
<xsl:include href="./xhtml/xhtml-head.xsl"/>
<xsl:variable name="locale">
<xsl:choose>
@ -52,313 +56,13 @@
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<xsl:call-template name="xhtml-head" />
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml;charset=utf-8" />
<xsl:choose>
<xsl:when test="not(//@embed)">
<link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico" />
<link rel="stylesheet" type="text/css">
<xsl:attribute name="href">
<xsl:value-of select="//@stylesheet" />
</xsl:attribute>
</link>
</xsl:when>
<xsl:when test="//@embed='video'">
<!--
embedded stylesheet should rather be done through URL like
"http://localhost/video/4chan%20city/3/embed=true+stylesheet=embedded.css"
-->
<link rel="stylesheet" type="text/css">
<xsl:attribute name="href">
/style/embedded.css
</xsl:attribute>
</link>
</xsl:when>
</xsl:choose>
<xsl:if test="boolean(//results)">
<link rel="alternate" type="application/rss+xml">
<xsl:attribute name="title">
<xsl:value-of select="$locale_strings[@id='rss_title_results_this_page']" />
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_root']" />
<xsl:value-of select="$site_strings[@id='path_results']" />
<xsl:value-of select="//results/@query" />
&amp;pagesize=<xsl:value-of select="//results/@pagesize" />
&amp;page=<xsl:value-of select="//results/@page" />
&#38;xslt=rss
</xsl:attribute>
</link>
<link rel="alternate" type="application/rss+xml">
<xsl:attribute name="title">
<xsl:value-of select="$locale_strings[@id='rss_title_results_all_pages']" />
</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_root']" />
<xsl:value-of select="$site_strings[@id='path_results']" />
<xsl:value-of select="//results/@query" />
&amp;pagesize=99999
&amp;page=1
&#38;xslt=rss
</xsl:attribute>
</link>
</xsl:if>
<link
rel="search"
type="application/opensearchdescription+xml"
>
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_root']" />?xslt=opensearch
</xsl:attribute>
<xsl:attribute name="title">
<xsl:value-of select="$site_strings[@id='site_name']" />
</xsl:attribute>
</link>
<title>
<xsl:choose>
<xsl:when test="boolean(//frontpage)">
<xsl:value-of select="$site_strings[@id='site_name']" />
-
<xsl:value-of select="$site_strings[@id='site_motto']" />
</xsl:when>
<xsl:when test="boolean(//resultspage)">
<xsl:value-of select="$site_strings[@id='site_name']" />
-
<xsl:value-of select="$locale_strings[@id='results_for_query']" />
"<xsl:value-of select="//resultspage/@query" />"
</xsl:when>
<xsl:otherwise>
<!--
this seems to be fail
should be fixed somehow
-->
<xsl:value-of select="$site_strings[@id='site_name']" />
-
<xsl:value-of select="$site_strings[@id='site_motto']" />
</xsl:otherwise>
</xsl:choose>
</title>
</head>
<body>
<xsl:if test="not(//@embed)">
<div class="header">
<a class="header latest-additions">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_query_latestadditions']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='query_latestadditions']" />
</a>
<a class="header most-views">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_query_mostviews']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='query_mostviews']" />
</a>
<a class="header most-downloads">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_query_mostdownloads']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='query_mostdownloads']" />
</a>
<xsl:choose>
<xsl:when test="string-length(//@username)=0">
<!--
<a class="header">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_login']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='header_login-to-upload']" />
</a>
-->
<a class="header register">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_register']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='register']" />
</a>
<a class="header login">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_login']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='login']" />
</a>
<a class="header login-openid">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_login-openid']" />
</xsl:attribute>
<!--
<img class="openid-icon" src="/images/openid-icon.png" alt="open id logo" />
-->
<xsl:value-of select="$locale_strings[@id='login_openid']" />
</a>
</xsl:when>
<xsl:otherwise>
<a class="header upload-video">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_upload']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='header_upload-video']" />
</a>
<a class="header preferences">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_settings']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='settings_details']" />
</a>
<!--
<xsl:value-of select="$locale_strings[@id='logged_in_as']" />
<a class="header">
<xsl:attribute name="href">
user/<xsl:value-of select="//@username" />
</xsl:attribute>
<xsl:value-of select="//@username" />
</a>
-->
<a class="header logout">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_logout']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='logout']" />
</a>
</xsl:otherwise>
</xsl:choose>
</div>
<xsl:if test="//message">
<xsl:call-template name="message"/>
</xsl:if>
<xsl:if test="//search">
<xsl:call-template name="searchbar"/>
</xsl:if>
<xsl:if test="not(//frontpage)">
<xsl:call-template name="logo-small"/>
</xsl:if>
</xsl:if>
<xsl:choose>
<xsl:when test="//frontpage">
<xsl:call-template name="frontpage"/>
</xsl:when>
<xsl:when test="//registerform">
<xsl:call-template name="registerform"/>
</xsl:when>
<xsl:when test="//loginform">
<xsl:call-template name="loginform"/>
</xsl:when>
<xsl:when test="//uploadform">
<xsl:call-template name="uploadform"/>
</xsl:when>
<xsl:when test="//search">
<xsl:call-template name="results"/>
</xsl:when>
<xsl:when test="//advancedsearch">
<xsl:call-template name="advancedsearch"/>
</xsl:when>
<xsl:when test="//video">
<xsl:call-template name="video"/>
</xsl:when>
<xsl:when test="//settings">
<xsl:call-template name="settings"/>
</xsl:when>
</xsl:choose>
<xsl:if test="not(//@embed)">
<div class="footer">
<a class="footer view-license">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_license']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='footer_license']" />
</a>
<a class="footer view-source-code">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_source-code']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='footer_source_code']" />
</a>
<a class="footer report-bug">
<xsl:attribute name="href">
<xsl:value-of select="$site_strings[@id='path_report_bug']" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='footer_report_bug']" />
</a>
<a class="footer view-xml">
<xsl:attribute name="href">
<!--
caveat: this currently does not work on root level
apache magic wanted
-->
?xslt=null
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='footer_view_xml']" />
</a>
</div>
<!--
<br />
<xsl:value-of select="$locale_strings[@id='footer_copyright']" />
-->
<br />
<span class="protip">
<xsl:value-of select="$locale_strings[@id='footer_warranty']" />
</span>
</xsl:if>
</body>
<xsl:call-template name="xhtml-body" />
</html>
</xsl:template>
<xsl:template name="logo-small">
<!-- <a href="/">
<img class="logo-small" src="/images/logo-small.png" alt="Yolanda logo top (160x25)" />
</a>-->
</xsl:template>
<xsl:template name="searchbar">
<div class="search-small">

View file

@ -42,12 +42,14 @@
{
document.getElementById('video').style.display = 'none';
document.getElementById('thumbnail').style.display = 'block';
document.getElementById('buttons').style.display = 'block';
}
function show_movie()
{
document.getElementById('video').style.display = 'block';
document.getElementById('thumbnail').style.display = 'none';
document.getElementById('buttons').style.display = 'none';
}
]]]]></xsl:text>
@ -69,43 +71,57 @@
<img src="/images/mplayer.png"/>
</object>
<div id="thumbnail" style="display: none;">
<img id="thumbnail" style="display: none;">
<xsl:attribute name="src">
<xsl:value-of select="//video/@thumbnail" />
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="//video/rdf:RDF/cc:Work/dc:title" />
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="//video/@height" />
</xsl:attribute>
<xsl:attribute name="widht">
<xsl:value-of select="//video/@width" />
</xsl:attribute>
</img>
<img>
<xsl:attribute name="src">
<xsl:value-of select="//video/@thumbnail" />
</xsl:attribute>
<xsl:attribute name="alt">
<xsl:value-of select="//video/rdf:RDF/cc:Work/dc:title" />
</xsl:attribute>
<xsl:attribute name="height">
<xsl:value-of select="//video/@height" />
</xsl:attribute>
<xsl:attribute name="widht">
<xsl:value-of select="//video/@width" />
</xsl:attribute>
</img>
<form method="get">
<xsl:attribute name="action">
<xsl:value-of select="//video/rdf:RDF/cc:Work/@rdf:about" />
</xsl:attribute>
<button
name="playback"
type="button"
value="playback"
onclick="show_movie()">
<img src="/images/tango/media-playback-start.png" alt="playback" />
</button>
<button
name="download"
type="submit"
value="download">
<img src="/images/tango/document-save.png" alt="download" />
</button>
</form>
</div>
<form id="buttons" method="get">
<xsl:attribute name="action">
<xsl:value-of select="//video/rdf:RDF/cc:Work/@rdf:about" />
</xsl:attribute>
<button
name="playback"
type="button"
value="playback"
onclick="show_movie()">
<img src="/images/tango/media-playback-start.png" alt="playback" />
<br />
<xsl:value-of select="$locale_strings[@id='video_playback']" />
<br />
<xsl:variable name="hours" select="floor(//video/@duration div 3600)" />
<xsl:variable name="minutes" select="floor((//video/@duration - $hours*3600) div 60)" />
<xsl:variable name="seconds" select="//video/@duration - $minutes*60 - $hours*3600" />
<xsl:choose>
<xsl:when test="$hours=0">
(<xsl:value-of select="concat(format-number($minutes, '00'), ':', format-number($seconds, '00'))" />)
</xsl:when>
<xsl:otherwise>
(<xsl:value-of select="concat($hours, ':', format-number($minutes, '00'), ':', format-number($seconds, '00'))" />)
</xsl:otherwise>
</xsl:choose>
</button>
<button
name="download"
type="submit"
value="download">
<img src="/images/tango/document-save.png" alt="download" />
<br />
<xsl:value-of select="$locale_strings[@id='video_download']" />
<br />
(<xsl:value-of select="format-number(number(round(//video/@filesize) div 1048576), '0.0#')" />&#160;<xsl:value-of select="$locale_strings[@id='megabytes']" />)
</button>
</form>
<xsl:if test="not(//@embed='true')">
@ -135,7 +151,7 @@
<xsl:attribute name="href">
<xsl:value-of select="//video/rdf:RDF/cc:Work/@rdf:about" />
</xsl:attribute>
<xsl:value-of select="$locale_strings[@id='download_video']" />
<xsl:value-of select="$locale_strings[@id='video_download']" />
</a>
<br />
(<xsl:value-of select="format-number(number(round(//video/@filesize) div 1048576), '0.0#')" />&#160;<xsl:value-of select="$locale_strings[@id='megabytes']" />)