forked from VHP4Safety/cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateSitemap.groovy
38 lines (31 loc) · 1.01 KB
/
createSitemap.groovy
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
// Copyright (C) 2023 Egon Willighagen
// License: MIT
// groovy createMarkdown.groovy *.json
import groovy.json.JsonSlurper
import groovy.io.FileType
println """<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<urlset
xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9
http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">
"""
def list = []
def dir = new File("docs/service")
dir.eachFileRecurse (FileType.FILES) { file ->
if (file.name.endsWith(".json") && file.name != "template.json") {
list << file
}
}
list = list.sort()
list.each { file ->
fileContents = file.text
//def data = new JsonSlurper().parseText(fileContents)
def data = new JsonSlurper().parseText(fileContents)
println """<url>
<loc>https://cloud.vhp4safety.nl/service/${data.id}.html</loc>
<priority>1.00</priority>
<changefreq>weekly</changefreq>
</url>"""
}
println """</urlset>"""