summaryrefslogtreecommitdiffhomepage
path: root/nginx/layout/simple.xslt
blob: 9cc5ad6c1c0f65333ac052a2fc96a431a8001a2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html>
      <body style="margin: 0 auto; max-width: 900px; width: fit-content;">

        <h3><xsl:value-of select="name(//directory)"/></h3>

        <table border="0">
          <tr bgcolor="#7DAFFF">
            <th>Name</th>
            <th style="padding-inline: 2em;">Size</th>
            <th>Date</th>
          </tr>
          <xsl:for-each select="list/*">
            <xsl:sort select="mtime" />

            <xsl:variable name="name">
              <xsl:value-of select="."/>
            </xsl:variable>

            <xsl:variable name="size">
              <xsl:if test="string-length(@size) &gt; 0">
                <xsl:if test="number(@size) &gt; 0">
                  <xsl:choose>
                    <xsl:when test="round(@size div 1024) &lt; 1"><xsl:value-of select="@size" /></xsl:when>
                    <xsl:when test="round(@size div 1048576) &lt; 1"><xsl:value-of select="format-number((@size div 1024), '0.0')" />K</xsl:when>
                    <xsl:otherwise><xsl:value-of select="format-number((@size div 1048576), '0.00')" /> MB</xsl:otherwise>
                  </xsl:choose>
                </xsl:if>
              </xsl:if>
            </xsl:variable>

            <xsl:variable name="date">
              <xsl:value-of select="substring(@mtime,6,2)"/>/<xsl:value-of select="substring(@mtime,9,2)"/><xsl:text> </xsl:text>
              <xsl:value-of select="substring(@mtime,12,2)"/>:<xsl:value-of select="substring(@mtime,15,2)"/>:<xsl:value-of select="substring(@mtime,18,2)"/><xsl:text> </xsl:text>
              <xsl:value-of select="substring(@mtime,1,4)"/>
            </xsl:variable>

            <tr>
              <td><a href="{$name}"><xsl:value-of select="."/></a></td>
              <td align="right" style="padding-right: 2em;"><xsl:value-of select="$size"/></td>
              <td><xsl:value-of select="$date"/></td>
            </tr>

          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>