infrastructure/deployments/mirror/xslt_template.xslt

98 lines
4.2 KiB
HTML
Raw Normal View History

2023-04-12 12:47:22 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="$text = '' or $replace = ''or not($replace)" >
<!-- Prevent this routine from hanging -->
<xsl:value-of select="$text" />
</xsl:when>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<html>
<head>
<link href="/private/asset/icons.css" rel="stylesheet" />
<link href="/private/asset/style.css" rel="stylesheet" />
</head>
<body>
<header>
<h3>Lewd.wtf Mirror Service</h3>
<p>Welcome to the mirror service of lewd.wtf! I provide this service free of charge to projects that could benefit from it.</p>
<p>Want to get your files hosted here? Please contact me at <b>mirror_request@lewd.wtf</b> and provide details regarding your projects.</p>
<h1>Proud Sineater and Sin's Cove Hater!</h1>
<p>If you come here from Sin's Cove, please close this page. This site is hosted by Ecchibitionist, the person you constantly harass.</p>
<p>You claim I bullied the original developer of EmuSAK, even though that's a blatant lie (and you know it).</p>
</header>
<main>
<h4>
<xsl:value-of select="$dirname"/>
</h4>
<table>
<tr>
<th>Name</th>
<th>Size</th>
</tr>
<tr>
<td><a href=".."><span class="material-icons back_folder_icon">drive_file_move_rtl</span>../</a></td>
<td align="right"></td>
</tr>
<xsl:for-each select="list/*">
<xsl:sort select="@name"/>
<xsl:variable name="name">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="." />
<xsl:with-param name="replace" select="'%'" />
<xsl:with-param name="by" select="'%25'" />
</xsl:call-template>
</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" />B</xsl:when>
<xsl:when test="round(@size div 1048576) &lt; 1"><xsl:value-of select="format-number((@size div 1024), '0.0')" />KiB</xsl:when>
<xsl:otherwise><xsl:value-of select="format-number((@size div 1048576), '0.00')" />MiB</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:if>
</xsl:variable>
<tr>
<td>
<a href="{$name}">
<xsl:choose>
<xsl:when test="string-length(@size)=0"><span class="material-icons folder">folder</span></xsl:when>
<xsl:when test="'.zip' = substring($name, string-length($name) - 3)"><span class="material-icons folder_zip"> folder_zip </span></xsl:when>
<xsl:when test="'.rar' = substring($name, string-length($name) - 3)"><span class="material-icons folder_zip"> folder_zip </span></xsl:when>
<xsl:otherwise><span class="material-icons file"> insert_drive_file </span></xsl:otherwise>
</xsl:choose>
<xsl:value-of select="."/>
</a>
</td>
<td align="right"><xsl:value-of select="$size"/></td>
</tr>
</xsl:for-each>
</table>
</main>
<footer>
<p>In case this mirror is hosting files that you believe shouldn't be here, please send a message to <a href="mailto:abuse@lewd.wtf">abuse@lewd.wtf</a> and we'll remove it as soon as possible.</p>
</footer>
</body>
</html>
</xsl:template>
</xsl:stylesheet>