forked from pedroborges/xml-sitemap-stylesheet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsitemap.xsl
263 lines (246 loc) Β· 11.7 KB
/
sitemap.xsl
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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
<xsl:output method="html" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<html>
<head>
<title>
Sitemap
<xsl:if test="sitemap:sitemapindex">Index</xsl:if>
</title>
</head>
<body class="ph3 pb3 mid-gray">
<header class="mw8 pv4 center">
<div class="flex items-center">
<h1 class="ma0 mr2 f2 blue">Sitemap</h1>
<xsl:if test="sitemap:sitemapindex">
<span class="dib mr2 ph3 pv1 f6 normal mid-gray bg-light-blue br-pill">Index</span>
</xsl:if>
<xsl:if test="sitemap:urlset/sitemap:url/image:image">
<span class="dib mr2 ph3 pv1 f6 normal mid-gray bg-light-blue br-pill">Images</span>
</xsl:if>
<xsl:if test="sitemap:urlset/sitemap:url/video:video">
<span class="dib mr2 ph3 pv1 f6 normal mid-gray bg-light-blue br-pill">Video</span>
</xsl:if>
<xsl:if test="sitemap:urlset/sitemap:url/xhtml:link">
<span class="dib mr2 ph3 pv1 f6 normal mid-gray bg-light-blue br-pill">Xhtml</span>
</xsl:if>
</div>
<h2 class="ma0 mt4 f4 normal">
<xsl:choose>
<xsl:when test="sitemap:sitemapindex">
This index contains
<strong class="blue"><xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"/></strong>
sitemaps.
</xsl:when>
<xsl:otherwise>
This index contains
<strong class="blue"><xsl:value-of select="count(sitemap:urlset/sitemap:url)"/></strong>
URLs.
</xsl:otherwise>
</xsl:choose>
</h2>
<p>
This is an XML sitemap, meant for consumption by search engines.<br/>
You can find more information about XML sitemaps on <a href="https://sitemaps.org" class="link blue">sitemaps.org</a>.
</p>
</header>
<xsl:apply-templates/>
<footer class="mw8 center pv4 tc">
This is an open source <a href="https://github.com/pedroborges/xml-sitemap-stylesheet" title="Go to Github" class="link blue">XML Sitemap Stylesheet</a> created by <a href="https://pedroborg.es" title="Pedro Borges" class="link blue">pedroborg.es</a>
</footer>
</body>
</html>
</xsl:template>
<xsl:template match="sitemap:sitemapindex">
<div class="mw8 center">
<div class="overflow-auto">
<table class="w-100 f6 b--silver ba bw1" cellspacing="0">
<thead class="bg-silver">
<tr>
<th class="pa3 fw6 tl dark-gray" style="width:60px"></th>
<th class="pa3 fw6 tl dark-gray">URL</th>
<th class="pa3 fw6 tr dark-gray" style="width:200px">Last Modified</th>
</tr>
</thead>
<tbody class="lh-copy bg-near-white">
<xsl:for-each select="sitemap:sitemap">
<tr class="hover-bg-white">
<xsl:variable name="loc">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<xsl:variable name="pno">
<xsl:value-of select="position()"/>
</xsl:variable>
<td class="pa3 tc b bb b--silver">
<xsl:value-of select="$pno"/>
</td>
<td class="pa3 b bb b--silver">
<a href="{$loc}" class="link blue">
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<xsl:if test="sitemap:lastmod">
<td class="pa3 tr bb b--silver">
<xsl:value-of select="concat(substring(sitemap:lastmod, 0, 11), concat(' ', substring(sitemap:lastmod, 12, 5)), concat(' ', substring(sitemap:lastmod, 20, 6)))"/>
</td>
</xsl:if>
<xsl:apply-templates/>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</div>
</xsl:template>
<xsl:template match="sitemap:urlset">
<div class="mw8 center">
<div class="overflow-auto">
<table class="w-100 f6 b--silver ba bw1" cellspacing="0">
<thead class="bg-silver">
<tr>
<th class="pa3 fw6 tl dark-gray" style="width:60px"></th>
<th class="pa3 fw6 tl dark-gray">URL</th>
<xsl:if test="sitemap:url/sitemap:changefreq">
<th class="pa3 fw6 tr dark-gray" style="width:130px">Change Freq.</th>
</xsl:if>
<xsl:if test="sitemap:url/sitemap:priority">
<th class="pa3 fw6 tr dark-gray" style="width:90px">Priority</th>
</xsl:if>
<xsl:if test="sitemap:url/sitemap:lastmod">
<th class="pa3 fw6 tr dark-gray" style="width:200px">Last Modified</th>
</xsl:if>
</tr>
</thead>
<tbody class="lh-copy bg-near-white">
<xsl:for-each select="sitemap:url">
<tr class="hover-bg-white">
<xsl:variable name="loc">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<xsl:variable name="pno">
<xsl:value-of select="position()"/>
</xsl:variable>
<td class="pa3 tc b bb b--silver">
<xsl:value-of select="$pno"/>
</td>
<td class="pa3 bb b--silver">
<p>
<a href="{$loc}" class="link blue">
<xsl:value-of select="sitemap:loc"/>
</a>
</p>
<xsl:apply-templates select="xhtml:*"/>
<xsl:apply-templates select="image:*"/>
<xsl:apply-templates select="video:*"/>
</td>
<xsl:apply-templates select="sitemap:changefreq"/>
<xsl:apply-templates select="sitemap:priority"/>
<xsl:if test="sitemap:lastmod">
<td class="pa3 tr bb b--silver">
<xsl:value-of select="concat(substring(sitemap:lastmod, 0, 11), concat(' ', substring(sitemap:lastmod, 12, 5)), concat(' ', substring(sitemap:lastmod, 20, 6)))"/>
</td>
</xsl:if>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</div>
</xsl:template>
<xsl:template match="sitemap:loc|sitemap:lastmod|image:loc|image:caption|video:*">
</xsl:template>
<xsl:template match="sitemap:changefreq|sitemap:priority">
<td class="pa3 tr bb b--silver">
<xsl:apply-templates/>
</td>
</xsl:template>
<xsl:template match="xhtml:link">
<xsl:variable name="altloc">
<xsl:value-of select="@href"/>
</xsl:variable>
<p>
<strong>Xhtml: </strong>
<a href="{$altloc}" class="mr2 link blue">
<xsl:value-of select="@href"/>
</a>
<xsl:if test="@hreflang">
<small class="dib mr2 ph1 pv1 tracked lh-solid white bg-silver br-pill">
<xsl:value-of select="@hreflang"/>
</small>
</xsl:if>
<xsl:if test="@rel">
<small class="dib mr2 ph2 pv1 tracked lh-solid white bg-silver br-pill">
<xsl:value-of select="@rel"/>
</small>
</xsl:if>
<xsl:if test="@media">
<small class="dib mr2 ph2 pv1 tracked lh-solid white bg-silver br-pill">
<xsl:value-of select="@media"/>
</small>
</xsl:if>
</p>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="image:image">
<xsl:variable name="loc">
<xsl:value-of select="image:loc"/>
</xsl:variable>
<p>
<strong>Image: </strong>
<a href="{$loc}" class="mr2 link blue">
<xsl:value-of select="image:loc"/>
</a>
<xsl:if test="image:caption">
<span class="i gray">
<xsl:value-of select="image:caption"/>
</span>
</xsl:if>
<xsl:apply-templates/>
</p>
</xsl:template>
<xsl:template match="video:video">
<xsl:variable name="loc">
<xsl:choose>
<xsl:when test="video:player_loc != ''">
<xsl:value-of select="video:player_loc"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="video:content_loc"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name="thumb_loc">
<xsl:value-of select="video:thumbnail_loc"/>
</xsl:variable>
<p>
<strong>Video: </strong>
<a href="{$loc}" class="mr2 link blue">
<xsl:choose>
<xsl:when test="video:player_loc != ''">
<xsl:value-of select="video:player_loc"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="video:content_loc"/>
</xsl:otherwise>
</xsl:choose>
</a>
<a href="{$thumb_loc}" class="dib mr2 ph2 pv1 tracked lh-solid link white bg-silver hover-bg-blue br-pill">
thumb
</a>
<xsl:if test="video:title">
<span class="i gray">
<xsl:value-of select="video:title"/>
</span>
</xsl:if>
<xsl:apply-templates/>
</p>
</xsl:template>
</xsl:stylesheet>