-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
116 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var table = document.querySelector("#sitemapTable"); | ||
var headers = Array.from(table.querySelectorAll("th")); | ||
|
||
headers.forEach(function (header, index) { | ||
header.classList.add('sortable'); | ||
header.sortDirection = 'asc'; | ||
header.addEventListener("click", function () { | ||
sortTable(index); | ||
}); | ||
}); | ||
|
||
headers[0].innerText += ' ▲'; | ||
headers[0].sortDirection = 'desc'; | ||
|
||
function sortTable(index) { | ||
var header = headers[index]; | ||
var direction = header.sortDirection; | ||
var arrow = direction === 'asc' ? '▲' : '▼'; | ||
var existingArrow = header.innerText.match(/▲|▼/); | ||
if (existingArrow) { | ||
header.innerText = header.innerText.replace(existingArrow, ''); | ||
} | ||
header.innerText = header.innerText + ' ' + arrow; | ||
|
||
var rows = Array.from(table.querySelectorAll("tbody tr")); | ||
rows.sort(function (rowA, rowB) { | ||
var cellA = rowA.querySelectorAll("td")[index].innerText; | ||
var cellB = rowB.querySelectorAll("td")[index].innerText; | ||
var comparison = cellA.localeCompare(cellB); | ||
return direction === 'asc' ? comparison : -comparison; | ||
}); | ||
|
||
var fragment = new DocumentFragment(); | ||
rows.forEach(function (row) { | ||
fragment.appendChild(row); | ||
}); | ||
table.querySelector("tbody").appendChild(fragment); | ||
|
||
// Hide arrows on other columns. | ||
headers.forEach(function (header, i) { | ||
if (i !== index) { | ||
var existingArrow = header.innerText.match(/▲|▼/); | ||
if (existingArrow) { | ||
header.innerText = header.innerText.replace(existingArrow, ''); | ||
} | ||
} | ||
}); | ||
|
||
header.sortDirection = direction === 'asc' ? 'desc' : 'asc'; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?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:atom="http://www.w3.org/2005/Atom"> | ||
<xsl:output method="html" encoding="UTF-8" indent="yes" /> | ||
|
||
<xsl:template match="/sitemap:urlset"> | ||
<html> | ||
<head> | ||
<title>Sitemap</title> | ||
<link rel="stylesheet" href="/main.css"/> | ||
<script src="/js/sortTable.min.js" defer="defer"></script> | ||
</head> | ||
<body> | ||
<div class="full-width"> | ||
<h1>Sitemap</h1> | ||
<p>Number of URLs: <xsl:value-of select="count(sitemap:url)"/></p> | ||
<table id="sitemapTable" class="sitemap-table"> | ||
<thead> | ||
<tr> | ||
<th>URL</th> | ||
<th>Last modification</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<xsl:for-each select="sitemap:url"> | ||
<tr> | ||
<td> | ||
<a href="{sitemap:loc}"> | ||
<xsl:value-of select="sitemap:loc"/> | ||
</a> | ||
</td> | ||
<td> | ||
<xsl:value-of select="sitemap:lastmod"/> | ||
</td> | ||
</tr> | ||
</xsl:for-each> | ||
</tbody> | ||
</table> | ||
</div> | ||
</body> | ||
</html> | ||
</xsl:template> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-stylesheet href="{{ get_url(path='/sitemap_style.xsl', trailing_slash=false) | safe }}" type="text/xsl"?> | ||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> | ||
{%- for sitemap_entry in entries %} | ||
<url> | ||
<loc>{{ sitemap_entry.permalink | escape_xml | safe }}</loc> | ||
{%- if sitemap_entry.updated %} | ||
<lastmod>{{ sitemap_entry.updated }}</lastmod> | ||
{%- endif %} | ||
</url> | ||
{%- endfor %} | ||
</urlset> |