diff options
| Commit | 3aad82d6e811212b81d574058afc6a7134e45706 (patch) | |
|---|---|---|
| Author | 2023-10-23 15:03:36 +0300 | |
| Committer | 2023-10-23 15:03:36 +0300 | |
| Files | 8d660e7d07988bf8afe580af7252e8d675bbf7b4 | |
| csg-3aad82d6e811212b81d574058afc6a7134e45706.tar csg-3aad82d6e811212b81d574058afc6a7134e45706.tar.gz csg-3aad82d6e811212b81d574058afc6a7134e45706.zip | ||
| Parent | f39bb5ca1b498d9b7fc556ff6026efc08b46ab8a (diff) | |
[s2] Reworked sitemap creation with a single awk script
This should be generally faster and opens more possibilities for file-dependant properties
Also went away with the process substitution, improving portability
1 files changed, 18 insertions, 14 deletions
| -rwxr-xr-x | csg | 32 |
@@ -304,19 +304,23 @@ wait overwriteLine "[Stage 2] Generating sitemap" # This cannot really be done while transforming files, since you could have static .html pages -echo '<?xml version="1.0" encoding="UTF-8"?> -<urlset -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" -xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' > "$DESTINATION/sitemap.xml" -date="$(date +%Y-%m-%d)" - -while read -r file -do - echo "<url><loc>$URL${file#$DESTINATION}</loc><lastmod>$date</lastmod><priority>1.0</priority></url>" >> "$DESTINATION/sitemap.xml" -done < <(find "$DESTINATION" -type f -name "*.html") - -echo '</urlset>' >> "$DESTINATION/sitemap.xml" +$CSG_AWK -v url="$URL" -v dest="$DESTINATION" -v date="$(date +%Y-%m-%d)" ' + BEGIN { + print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" ORS \ + "<urlset" ORS \ + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" ORS \ + "xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9" ORS \ + "http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\"" ORS \ + "xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">" + lendest = length(dest) + } + { + $0 = substr($0, index($0, dest) + lendest) + print "<url><loc>" url $0 "</loc><lastmod>" date "</lastmod><priority>1.0</priority></url>" + } + END { print "</urlset>" } +'<< EOF > "$DESTINATION/sitemap.xml" +$(find "$DESTINATION" -type f -name "*.html") +EOF endTimer "[Stage 2] Done" |
