Follow upstream changes -- Bytestring updates
[git-darcs-import.git] / tools / cgi / xslt / patches.xslt
blob617e23fad61602548875ad69a5e92c9921fb5167
1 <?xml version="1.0" encoding="utf-8"?>
3 <!--
4 template for converting darcs' `changes` output from XML to XHTML. This
5 template expects the following external variables:
7 cgi-program - path to the CGI executable, to place in links
8 sort-by - field to sort by
9 stylesheet - path to the CSS stylesheet
11 the input XML must have the following structure, aside from what common.xslt
12 expects:
14 <changelog>
15 <patch author="" date="" localdate="" inverted="" hash="">
16 <name></name>
17 </patch>
18 </changelog>
19 -->
20 <xsl:stylesheet version="1.0"
21 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
22 xmlns:str="http://exslt.org/strings">
24 <xsl:include href="common.xslt"/>
26 <xsl:template match="path">
27 <h1 class="target">
28 patches applied to <span class="path"><a href="{$cgi-program}">projects</a></span> / <span class="path"><xsl:apply-templates/></span>
29 </h1>
30 </xsl:template>
33 <xsl:template match="changelog">
34 <table>
35 <tr class="patches">
36 <th>
37 <a class="sort" href="{$command}?c=patches&amp;s=name">name</a>
38 <a class="revsort" href="{$command}?c=patches&amp;s=revname"> (rev)</a>
39 </th>
40 <th>
41 <a class="sort" href="{$command}?c=patches&amp;s=date">date</a>
42 <a class="revsort" href="{$command}?c=patches&amp;s=revdate"> (rev)</a>
43 </th>
44 <th>
45 <a class="sort" href="{$command}?c=patches&amp;s=author">author</a>
46 <a class="revsort" href="{$command}?c=patches&amp;s=revauthor"> (rev)</a>
47 </th>
48 <th>
49 </th>
50 </tr>
52 <xsl:choose>
53 <xsl:when test="$sort-by = 'name'">
54 <xsl:apply-templates>
55 <xsl:sort select="name"/>
56 </xsl:apply-templates>
57 </xsl:when>
58 <xsl:when test="$sort-by = 'revname'">
59 <xsl:apply-templates>
60 <xsl:sort select="name" order="descending"/>
61 </xsl:apply-templates>
62 </xsl:when>
63 <xsl:when test="$sort-by = 'date'">
64 <xsl:apply-templates>
65 <xsl:sort select="@date"/>
66 </xsl:apply-templates>
67 </xsl:when>
68 <xsl:when test="$sort-by = 'revdate'">
69 <xsl:apply-templates>
70 <xsl:sort select="@date" order="descending"/>
71 </xsl:apply-templates>
72 </xsl:when>
73 <xsl:when test="$sort-by = 'author'">
74 <xsl:apply-templates>
75 <xsl:sort select="@author"/>
76 </xsl:apply-templates>
77 </xsl:when>
78 <xsl:when test="$sort-by = 'revauthor'">
79 <xsl:apply-templates>
80 <xsl:sort select="@author" order="descending"/>
81 </xsl:apply-templates>
82 </xsl:when>
83 <xsl:otherwise>
84 <!-- use the repository's natural order -->
85 <xsl:apply-templates/>
86 </xsl:otherwise>
87 </xsl:choose>
88 </table>
89 </xsl:template>
91 <xsl:template match="patch">
92 <xsl:variable name="author" select="@author"/>
93 <xsl:variable name="hash" select="@hash"/>
94 <xsl:variable name="name" select="name"/>
95 <xsl:variable name="repo" select="/darcs/@repository"/>
97 <xsl:variable name="created-as" select="/darcs/changelog/created_as"/>
98 <xsl:variable name="creator-hash" select="$created-as/patch/@hash"/>
99 <xsl:variable name="original-name" select="$created-as/@original_name"/>
101 <xsl:variable name="annotate-href">
102 <xsl:value-of select="$command"/>?c=annotate&amp;p=<xsl:value-of select="$hash"/>
104 <xsl:if test="$creator-hash">&amp;ch=<xsl:value-of select="$creator-hash"/></xsl:if>
105 <xsl:if test="$original-name">&amp;o=<xsl:value-of select="$original-name"/></xsl:if>
106 </xsl:variable>
108 <tr class="patch">
109 <td><a href="{$annotate-href}"><xsl:value-of select="name"/></a></td>
110 <td><xsl:value-of select="@local_date"/></td>
111 <td>
112 <a href="mailto:{$author}"><xsl:value-of select="$author"/></a>
113 </td>
114 <td>
115 <a href="{$cgi-program}/{$repo}/?c=annotate&amp;p={$hash}">detail</a>
116 </td>
117 </tr>
118 <xsl:apply-templates/>
119 </xsl:template>
121 <!-- ignore <created_as>, <name> and <comment> children of <patch> -->
122 <xsl:template match="created_as"/>
123 <xsl:template match="name"/>
124 <xsl:template match="comment"/>
125 </xsl:stylesheet>