-
Notifications
You must be signed in to change notification settings - Fork 0
/
default-sitemap.xsl
446 lines (417 loc) · 12.6 KB
/
default-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
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet
version="2.0"
xmlns:html="http://www.w3.org/TR/html40"
xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="fileType">
<xsl:choose>
<xsl:when test="//channel">RSS</xsl:when>
<xsl:when test="//sitemap:url">Sitemap</xsl:when>
<xsl:otherwise>SitemapIndex</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>
<xsl:choose>
<xsl:when test="$fileType='Sitemap' or $fileType='RSS'">Sitemap</xsl:when>
<xsl:otherwise>Sitemap Index</xsl:otherwise>
</xsl:choose>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
margin: 0;
font-family: Helvetica, Arial, sans-serif;
font-size: 68.5%;
}
#content-head {
background-color: #141B38;
padding: 20px 40px;
}
#content-head h1,
#content-head p,
#content-head a {
color: #fff;
font-size: 1.2em;
}
#content-head h1 {
font-size: 2em;
}
table {
margin: 20px 40px;
border: none;
border-collapse: collapse;
font-size: 1em;
width: 75%;
}
th {
border-bottom: 1px solid #ccc;
text-align: left;
padding: 15px 5px;
font-size: 14px;
}
td {
padding: 10px 5px;
border-left: 3px solid #fff;
}
tr.stripe {
background-color: #f7f7f7;
}
table td a:not(.localized) {
display: block;
}
table td a img {
max-height: 30px;
margin: 6px 3px;
}
.empty-sitemap {
margin: 20px 40px;
width: 75%;
}
.empty-sitemap__title {
font-size: 18px;
line-height: 125%;
margin: 12px 0;
}
.empty-sitemap svg {
width: 140px;
height: 140px;
}
.empty-sitemap__buttons {
margin-bottom: 30px;
}
.empty-sitemap__buttons .button {
margin-right: 5px;
}
.breadcrumb {
margin: 20px 40px;
width: 75%;
display: flex;
align-items: center;
font-size: 12px;
font-weight: 600;
}
.breadcrumb a {
color: #141B38;
text-decoration: none;
}
.breadcrumb svg {
margin: 0 10px;
}
@media (max-width: 1023px) {
.breadcrumb svg:not(.back),
.breadcrumb a:not(:last-of-type),
.breadcrumb span {
display: none;
}
.breadcrumb a:last-of-type::before {
content: 'Back'
}
}
@media (min-width: 1024px) {
.breadcrumb {
font-size: 14px;
}
.breadcrumb a {
font-weight: 400;
}
.breadcrumb svg.back {
display: none;
}
}
</style>
</head>
<body>
<xsl:variable name="amountOfURLs">
<xsl:choose>
<xsl:when test="$fileType='RSS'">
<xsl:value-of select="count(//channel/item)"></xsl:value-of>
</xsl:when>
<xsl:when test="$fileType='Sitemap'">
<xsl:value-of select="count(sitemap:urlset/sitemap:url)"></xsl:value-of>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="count(sitemap:sitemapindex/sitemap:sitemap)"></xsl:value-of>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="Header">
<xsl:with-param name="title">Sitemap</xsl:with-param>
<xsl:with-param name="amountOfURLs" select="$amountOfURLs"/>
<xsl:with-param name="fileType" select="$fileType"/>
</xsl:call-template>
<div class="content">
<div class="container">
<xsl:choose>
<xsl:when test="$amountOfURLs = 0"><xsl:call-template name="emptySitemap"/></xsl:when>
<xsl:when test="$fileType='Sitemap'"><xsl:call-template name="sitemapTable"/></xsl:when>
<xsl:when test="$fileType='RSS'"><xsl:call-template name="sitemapRSS"/></xsl:when>
<xsl:otherwise><xsl:call-template name="siteindexTable"/></xsl:otherwise>
</xsl:choose>
</div>
</div>
</body>
</html>
</xsl:template>
<xsl:template name="siteindexTable">
<div class="breadcrumb">
<svg class="back" width="6" height="9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.274 7.56L2.22 4.5l3.054-3.06-.94-.94-4 4 4 4 .94-.94z" fill="#141B38"/></svg>
<a href="/"><span>Home</span></a>
<svg width="6" height="8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.727 7.06L3.78 4 .727.94l.94-.94 4 4-4 4-.94-.94z" fill="#141B38"/></svg>
<span>Sitemap Index</span>
</div> <div class="table-wrapper">
<table cellpadding="3">
<thead>
<tr>
<th class="left">
URL </th>
<th>URL Count</th>
<th>
Last Updated </th>
</tr>
</thead>
<tbody>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:for-each select="sitemap:sitemapindex/sitemap:sitemap">
<tr>
<xsl:if test="position() mod 2 != 0">
<xsl:attribute name="class">stripe</xsl:attribute>
</xsl:if>
<td class="left">
<a>
<xsl:attribute name="href">
<xsl:value-of select="sitemap:loc" />
</xsl:attribute>
<xsl:value-of select="sitemap:loc"/>
</a>
</td>
<td>
</td>
<td class="datetime">
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</xsl:template>
<xsl:template name="sitemapRSS">
<div class="breadcrumb">
<svg class="back" width="6" height="9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.274 7.56L2.22 4.5l3.054-3.06-.94-.94-4 4 4 4 .94-.94z" fill="#141B38"/></svg>
<a href="/"><span>Home</span></a>
<svg width="6" height="8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.727 7.06L3.78 4 .727.94l.94-.94 4 4-4 4-.94-.94z" fill="#141B38"/></svg>
<span>Sitemap</span>
</div> <div class="table-wrapper">
<table cellpadding="3">
<thead>
<tr>
<th class="left">URL</th>
<th>
Publication Date </th>
</tr>
</thead>
<tbody>
<xsl:for-each select="//channel/item">
<tr>
<xsl:if test="position() mod 2 != 0">
<xsl:attribute name="class">stripe</xsl:attribute>
</xsl:if>
<td class="left">
<a>
<xsl:attribute name="href">
<xsl:value-of select="link" />
</xsl:attribute>
<xsl:value-of select="link"/>
</a>
</td>
<td class="datetime">
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</xsl:template>
<xsl:template name="sitemapTable">
<div class="breadcrumb">
<svg class="back" width="6" height="9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.274 7.56L2.22 4.5l3.054-3.06-.94-.94-4 4 4 4 .94-.94z" fill="#141B38"/></svg>
<a href="/"><span>Home</span></a>
<svg width="6" height="8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.727 7.06L3.78 4 .727.94l.94-.94 4 4-4 4-.94-.94z" fill="#141B38"/></svg>
<a href="/sitemap.xml"><span>Sitemap Index</span></a>
<svg width="6" height="8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.727 7.06L3.78 4 .727.94l.94-.94 4 4-4 4-.94-.94z" fill="#141B38"/></svg>
<span>Sitemap</span>
</div> <div class="table-wrapper">
<table cellpadding="3">
<thead>
<tr>
<th class="left">
URL </th>
<th>
Images </th>
<th>
Change Frequency </th>
<th>
Priority </th>
<th>
Last Updated </th>
</tr>
</thead>
<tbody>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:for-each select="sitemap:urlset/sitemap:url">
<tr>
<xsl:if test="position() mod 2 != 0">
<xsl:attribute name="class">stripe</xsl:attribute>
</xsl:if>
<td class="left">
<xsl:variable name="itemURL">
<xsl:value-of select="sitemap:loc"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="count(./*[@rel='alternate']) > 0">
<xsl:for-each select="./*[@rel='alternate']">
<xsl:if test="position() = last()">
<a href="{current()/@href}" class="localized">
<xsl:value-of select="@href"/>
</a>  → <xsl:value-of select="@hreflang"/>
</xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<a href="{$itemURL}">
<xsl:value-of select="sitemap:loc"/>
</a>
</xsl:otherwise>
</xsl:choose>
<xsl:for-each select="./*[@rel='alternate']">
<br />
<xsl:if test="position() != last()">
<a href="{current()/@href}" class="localized">
<xsl:value-of select="@href"/>
</a>  → <xsl:value-of select="@hreflang"/>
</xsl:if>
</xsl:for-each>
</td>
<td>
<div class="item-count">
<xsl:value-of select="count(image:image)"/>
</div>
</td>
<td>
<xsl:value-of select="concat(translate(substring(sitemap:changefreq, 1, 1),concat($lower, $upper),concat($upper, $lower)),substring(sitemap:changefreq, 2))"/>
</td>
<td>
<xsl:if test="string(number(sitemap:priority))!='NaN'">
<xsl:call-template name="formatPriority">
<xsl:with-param name="priority" select="sitemap:priority"/>
</xsl:call-template>
</xsl:if>
</td>
<td class="datetime">
</td>
</tr>
</xsl:for-each>
</tbody>
</table>
</div>
</xsl:template>
<xsl:template name="Header">
<xsl:param name="title"/>
<xsl:param name="amountOfURLs"/>
<xsl:param name="fileType"/>
<div id="content-head">
<h1><xsl:value-of select="$title"/></h1>
<p>Generated by <a href="https://aioseo.com/?utm_source=WordPress&utm_campaign=liteplugin&utm_medium=xml-sitemap" target="_blank">All in One SEO</a>, this is an XML Sitemap, meant to be consumed by search engines like Google or Bing.</p>
<p>
You can find more information about XML Sitemaps at <a href="https://www.sitemaps.org/" target="_blank" rel="noreferrer noopener">sitemaps.org</a>. </p>
<xsl:if test="$amountOfURLs > 0">
<p>
<xsl:choose>
<xsl:when test="$fileType='Sitemap' or $fileType='RSS'">
This sitemap contains <xsl:value-of select="$amountOfURLs"/>
<xsl:choose>
<xsl:when test="$amountOfURLs = 1">
URL </xsl:when>
<xsl:otherwise>
URLs </xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
This sitemap index contains <xsl:value-of select="$amountOfURLs"/>
<xsl:choose>
<xsl:when test="$amountOfURLs = 1">
sitemap </xsl:when>
<xsl:otherwise>
sitemaps </xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
and was generated on February 19, 2024 at 12:50 pm </p>
</xsl:if>
</div>
</xsl:template>
<xsl:template name="formatPriority">
<xsl:param name="priority"/>
<xsl:variable name="priorityLevel">
<xsl:choose>
<xsl:when test="$priority <= 0.5">low</xsl:when>
<xsl:when test="$priority >= 0.6 and $priority <= 0.8">medium</xsl:when>
<xsl:when test="$priority >= 0.9">high</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="priorityLabel">
<xsl:choose>
<xsl:when test="$priorityLevel = 'low'">Low</xsl:when>
<xsl:when test="$priorityLevel = 'medium'">Medium</xsl:when>
<xsl:when test="$priorityLevel = 'high'">High</xsl:when>
</xsl:choose>
</xsl:variable>
<div>
<xsl:attribute name="class">
<xsl:value-of select="concat('priority priority--', $priorityLevel)" />
</xsl:attribute>
<xsl:value-of select="$priorityLabel" />
</div>
</xsl:template>
<xsl:template name="emptySitemap">
<div class="breadcrumb">
<svg class="back" width="6" height="9" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.274 7.56L2.22 4.5l3.054-3.06-.94-.94-4 4 4 4 .94-.94z" fill="#141B38"/></svg>
<a href="/"><span>Home</span></a>
<svg width="6" height="8" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M.727 7.06L3.78 4 .727.94l.94-.94 4 4-4 4-.94-.94z" fill="#141B38"/></svg>
<span>Sitemap Index</span>
</div> <div class="empty-sitemap">
<h2 class="empty-sitemap__title">
Whoops! <br />
There are no posts here </h2>
<div class="empty-sitemap__buttons">
<a href="/" class="button">Back to Homepage</a>
</div>
</div>
<style>
.hand-magnifier{
animation: hand-magnifier .8s infinite ease-in-out;
transform-origin: center 90%;
transform-box: fill-box;
}
@keyframes hand-magnifier {
0% {
transform: rotate(0deg);
}
50% {
transform: rotate(-12deg);
}
100% {
transform: rotate(0deg);
}
}
</style>
</xsl:template>
</xsl:stylesheet>