An initial prototype.
This commit is contained in:
parent
874d10ac5e
commit
af9d5ce688
11 changed files with 841 additions and 2 deletions
40
xsl/transform-filesize.xsl
Normal file
40
xsl/transform-filesize.xsl
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<!--
|
||||
Copyright (C) 2016 - 2017 Schimon Jehuda. Released under MIT license
|
||||
Feeds rendered using this XSLT stylesheet, or it's derivatives, must
|
||||
include https://schimon.i2p/ in attribute name='generator' of
|
||||
element <meta/> inside of html element </head>
|
||||
-->
|
||||
|
||||
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
||||
<!-- transform filesize from given length string -->
|
||||
<xsl:template name='transform-filesize'>
|
||||
<xsl:param name='length'/>
|
||||
<!-- TODO consider xsl:decimal-format and xsl:number -->
|
||||
<xsl:choose>
|
||||
<!-- TODO consider removal of Byte -->
|
||||
<xsl:when test='$length < 2'>
|
||||
<xsl:value-of select='$length'/>
|
||||
Byte
|
||||
</xsl:when>
|
||||
<xsl:when test='floor($length div 1024) < 1'>
|
||||
<xsl:value-of select='$length'/>
|
||||
Bytes
|
||||
</xsl:when>
|
||||
<xsl:when test='floor($length div (1024 * 1024)) < 1'>
|
||||
<xsl:value-of select='floor($length div 1024)'/>.<xsl:value-of select='substring($length mod 1024,0,2)'/>
|
||||
KiB
|
||||
</xsl:when>
|
||||
<xsl:when test='floor($length div (1024 * 1024 * 1024)) < 1'>
|
||||
<xsl:value-of select='floor($length div (1024 * 1024))'/>.<xsl:value-of select='substring($length mod (1024 * 1024),0,2)'/>
|
||||
MiB
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<!-- P2P links -->
|
||||
<xsl:value-of select='floor($length div (1024 * 1024 * 1024))'/>.<xsl:value-of select='substring($length mod (1024 * 1024 * 1024),0,2)'/>
|
||||
GiB
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
</xsl:stylesheet>
|
Loading…
Add table
Add a link
Reference in a new issue