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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
|
<?xml version="1.0" encoding="utf-8"?>
<!--
svn2html.xsl - xslt stylesheet for converting svn log to a normal
changelog fromatted in html
version 0.13
Usage (replace ++ with two minus signs):
svn ++verbose ++xml log | \
xsltproc ++stringparam strip-prefix `basename $(pwd)` \
++stringparam groupbyday yes \
++stringparam authorsfile FILE \
++stringparam title NAME \
++stringparam revision-link NAME \
++stringparam ticket-link NAME \
++stringparam ticket-prefix NAME \
svn2html.xsl - > ChangeLog.html
This file is partially based on (and includes) svn2cl.xsl.
Copyright (C) 2005, 2006, 2007, 2009, 2010 Arthur de Jong.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote
products derived from this software without specific prior
written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<!-- include default formatting templates from svn2cl.xsl -->
<xsl:include href="svn2cl.xsl" />
<xsl:output
method="xml"
encoding="utf-8"
media-type="text/html"
omit-xml-declaration="no"
standalone="yes"
indent="yes"
doctype-public="-//W3C//DTD XHTML 1.1//EN"
doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" />
<!-- title of the report -->
<xsl:param name="title" select="'ChangeLog'" />
<!-- link to use for linking revision numbers -->
<xsl:param name="revision-link" select="'#r'" />
<!-- link to use for linking ticket numbers -->
<xsl:param name="ticket-link" select="''" />
<!-- string to search for as prefix to ticket ID to use for linking ticket numbers -->
<xsl:param name="ticket-prefix" select="'#'" />
<!-- match toplevel element -->
<xsl:template match="log">
<html>
<head>
<title><xsl:value-of select="string($title)" /></title>
<link rel="stylesheet" href="svn2html.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<xsl:if test="$title">
<h1><xsl:value-of select="string($title)" /></h1>
</xsl:if>
<ul class="changelog_entries">
<xsl:choose>
<xsl:when test="$ignore-message-starting != ''">
<!-- only handle logentries with don't contain the string -->
<xsl:apply-templates select="logentry[not(starts-with(msg,$ignore-message-starting))]" />
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="logentry" />
</xsl:otherwise>
</xsl:choose>
</ul>
<p class="changelog_footer">
<xsl:text>Generated by </xsl:text><a href="http://arthurdejong.org/svn2cl/">svn2cl 0.13</a>
</p>
</body>
</html>
</xsl:template>
<!-- format one entry from the log -->
<xsl:template match="logentry">
<xsl:choose>
<!-- if we're grouping we should omit some headers -->
<xsl:when test="$groupbyday='yes'">
<!-- fetch previous entry's date -->
<xsl:variable name="prevdate">
<xsl:apply-templates select="preceding-sibling::logentry[position()=1]/date" />
</xsl:variable>
<!-- fetch previous entry's author -->
<xsl:variable name="prevauthor">
<xsl:value-of select="normalize-space(preceding-sibling::logentry[position()=1]/author)" />
</xsl:variable>
<!-- fetch this entry's date -->
<xsl:variable name="date">
<xsl:apply-templates select="date" />
</xsl:variable>
<!-- fetch this entry's author -->
<xsl:variable name="author">
<xsl:value-of select="normalize-space(author)" />
</xsl:variable>
<!-- check if header is changed -->
<xsl:if test="($prevdate!=$date) or ($prevauthor!=$author)">
<li class="changelog_entry">
<!-- date -->
<span class="changelog_date"><xsl:value-of select="$date" /></span>
<xsl:text> </xsl:text>
<!-- author's name -->
<span class="changelog_author"><xsl:apply-templates select="author" /></span>
</li>
</xsl:if>
</xsl:when>
<!-- write the log header -->
<xsl:otherwise>
<li class="changelog_entry">
<!-- date -->
<span class="changelog_date"><xsl:apply-templates select="date" /></span>
<xsl:text> </xsl:text>
<!-- author's name -->
<span class="changelog_author"><xsl:apply-templates select="author" /></span>
</li>
</xsl:otherwise>
</xsl:choose>
<!-- entry -->
<li class="changelog_change">
<!-- get revision number -->
<xsl:variable name="revlink">
<xsl:choose>
<xsl:when test="contains($revision-link,'##')">
<xsl:value-of select="concat(substring-before($revision-link,'##'),@revision,substring-after($revision-link,'##'))" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($revision-link,@revision)" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<span class="changelog_revision">
<a id="r{@revision}" href="{$revlink}">[r<xsl:value-of select="@revision" />]</a>
</span>
<xsl:text> </xsl:text>
<!-- get paths string -->
<span class="changelog_files"><xsl:apply-templates select="paths" /></span>
<xsl:text> </xsl:text>
<!-- get message text -->
<xsl:variable name="msg">
<xsl:call-template name="trim-newln">
<xsl:with-param name="txt" select="msg" />
</xsl:call-template>
</xsl:variable>
<span class="changelog_message">
<xsl:call-template name="formatmessage">
<xsl:with-param name="txt" select="$msg" />
</xsl:call-template>
</span>
</li>
</xsl:template>
<!-- template to do formatting of log message -->
<xsl:template name="formatmessage">
<xsl:param name="txt" />
<xsl:choose>
<!-- perform newline-to-br transformation -->
<xsl:when test="contains($txt,' ')">
<!-- text contains newlines, do the first line -->
<xsl:call-template name="formatmessage">
<xsl:with-param name="txt" select="substring-before($txt,' ')" />
</xsl:call-template>
<!-- print new line -->
<br />
<!-- do the rest of the text -->
<xsl:call-template name="formatmessage">
<xsl:with-param name="txt" select="substring-after($txt,' ')" />
</xsl:call-template>
</xsl:when>
<!-- perform url highlighting -->
<xsl:when test="contains($txt,'http://')">
<xsl:call-template name="urlstolinks">
<xsl:with-param name="txt" select="$txt" />
</xsl:call-template>
</xsl:when>
<!-- perform url highlighting -->
<xsl:when test="contains($txt,'https://')">
<xsl:call-template name="urlstolinks">
<xsl:with-param name="txt" select="$txt" />
</xsl:call-template>
</xsl:when>
<!-- perform ticket highlighting -->
<xsl:when test="string-length($ticket-link) > 0 and contains($txt,$ticket-prefix)">
<xsl:call-template name="ticketstolinks">
<xsl:with-param name="txt" select="$txt" />
</xsl:call-template>
</xsl:when>
<!-- there does not seem to be anything parseable left -->
<xsl:otherwise>
<xsl:value-of select="$txt" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- template to replace url-like strings with links -->
<xsl:template name="urlstolinks">
<xsl:param name="txt" />
<!-- see if the string contains something url-like -->
<xsl:variable name="before">
<xsl:choose>
<xsl:when test="contains($txt,'http://')">
<xsl:value-of select="substring-before($txt,'http://')" />
</xsl:when>
<xsl:when test="contains($txt,'https://')">
<xsl:value-of select="substring-before($txt,'https://')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$txt" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- output the first part -->
<xsl:call-template name="formatmessage">
<xsl:with-param name="txt" select="$before" />
</xsl:call-template>
<!-- get the rest of the text -->
<xsl:variable name="rest" select="substring($txt,string-length($before)+1)" />
<!-- if there is a rest it's beginning is a URL -->
<xsl:if test="string-length($rest) > 0">
<!-- get the url part -->
<xsl:variable name="url">
<xsl:choose>
<xsl:when test="contains($rest,' ')">
<xsl:value-of select="substring-before($rest,' ')" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$rest" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- output the link -->
<a href="{$url}"><xsl:value-of select="$url" /></a>
<!-- parse the part after -->
<xsl:call-template name="formatmessage">
<xsl:with-param name="txt" select="substring($rest,string-length($url)+1)" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- template to replace ticket references with links -->
<xsl:template name="ticketstolinks">
<xsl:param name="txt" />
<!-- see if the string contains that looks like a ticket reference -->
<xsl:variable name="before">
<xsl:choose>
<xsl:when test="contains($txt,$ticket-prefix)">
<xsl:value-of select="substring-before($txt,$ticket-prefix)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$txt" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- output the first part -->
<xsl:call-template name="formatmessage">
<xsl:with-param name="txt" select="$before" />
</xsl:call-template>
<!-- get the rest of the text -->
<xsl:variable name="rest" select="substring($txt,string-length($before)+1)" />
<!-- if there is a rest it's beginning is a ticket reference -->
<xsl:if test="string-length($rest) > 0">
<!-- get the ticket part -->
<xsl:variable name="ticket">
<xsl:choose>
<xsl:when test="contains($rest,' ')">
<xsl:value-of select="substring-after(substring-before($rest,' '),$ticket-prefix)" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="substring-after($rest,$ticket-prefix)" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- output the link -->
<a href="{$ticket-link}{$ticket}"><xsl:value-of select="$ticket-prefix" /><xsl:value-of select="$ticket" /></a>
<!-- parse the part after -->
<xsl:call-template name="formatmessage">
<xsl:with-param name="txt" select="substring($rest,string-length($ticket-prefix)+string-length($ticket)+1)" />
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
|