Skip to content

Instantly share code, notes, and snippets.

@dkrnl
Created August 9, 2016 03:36
Show Gist options
  • Save dkrnl/d4e82f4c3953660692e336c0c5a3371c to your computer and use it in GitHub Desktop.
Save dkrnl/d4e82f4c3953660692e336c0c5a3371c to your computer and use it in GitHub Desktop.
SVN XSL template via Bootstrap
<?xml version="1.0"?>
<!-- A sample XML transformation style sheet for displaying the Subversion
directory listing that is generated by mod_dav_svn when the "SVNIndexXSLT"
directive is used. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" omit-xml-declaration="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd" />
<xsl:template match="*"/>
<xsl:template match="svn">
<html>
<head>
<meta charset="utf-8" />
<meta name="robots" content="noindex, follow, noarchive" />
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<title>
<xsl:if test="string-length(index/@base) != 0">
<xsl:value-of select="index/@base"/>
<xsl:text>: </xsl:text>
</xsl:if>
<xsl:value-of select="index/@path"/>
- SVN Server
</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<xsl:apply-templates/>
<footer>
<hr />
<div class="pull-right">
<xsl:text> powered by </xsl:text>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>
<xsl:text>Subversion </xsl:text>
<xsl:value-of select="@version"/>
</xsl:element>
</div>
</footer>
</div>
</body>
</html>
</xsl:template>
<xsl:template match="index">
<div class="page-header">
<h1>
<xsl:value-of select="@name"/>
<xsl:if test="@base">
<xsl:if test="@name">
<xsl:text>:&#xA0; </xsl:text>
</xsl:if>
<xsl:value-of select="@base" />
</xsl:if>
<xsl:if test="@rev">
<xsl:if test="@base | @name">
<xsl:text> &#x2014; </xsl:text>
</xsl:if>
<xsl:text>Revision </xsl:text>
<xsl:value-of select="@rev"/>
</xsl:if>
<xsl:text>: </xsl:text>
<xsl:value-of select="@path"/>
</h1>
</div>
<table class="table table-striped table-hover table-condensed">
<xsl:apply-templates select="updir"/>
<xsl:apply-templates select="dir"/>
<xsl:apply-templates select="file"/>
</table>
</xsl:template>
<xsl:template match="updir">
<tr>
<td>
<i class="glyphicon glyphicon-folder-open"></i>
<xsl:text>&#160;&#160;</xsl:text>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>
<strong>..</strong>
</xsl:element>
</td>
</tr>
</xsl:template>
<xsl:template match="dir">
<tr>
<td>
<i class="glyphicon glyphicon-folder-open"></i>
<xsl:text>&#160;&#160;</xsl:text>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>
<strong>
<xsl:value-of select="@name"/>
</strong>
</xsl:element>
</td>
</tr>
</xsl:template>
<xsl:template match="file">
<tr>
<td>
<i class="glyphicon glyphicon-file"></i>
<xsl:text>&#160;&#160;</xsl:text>
<xsl:element name="a">
<xsl:attribute name="href">
<xsl:value-of select="@href"/>
</xsl:attribute>
<xsl:attribute name="download">
<xsl:text></xsl:text>
</xsl:attribute>
<xsl:value-of select="@name"/>
</xsl:element>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment