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