diff options
author | bnewbold <bnewbold@archive.org> | 2020-08-20 21:17:59 +0000 |
---|---|---|
committer | bnewbold <bnewbold@archive.org> | 2020-08-20 21:17:59 +0000 |
commit | daf91b137483b7345448b597289c78f8fb3f9969 (patch) | |
tree | 712c27d902235d8d007763b512c57eaecd8045ad /extra/sitemap/generate_sitemap_indices.py | |
parent | 5007ee299ce07b31db6d48cd4ab2587f87af53ab (diff) | |
parent | 2a98d10be1cc1368f9510745bff07c343974d4a7 (diff) | |
download | fatcat-daf91b137483b7345448b597289c78f8fb3f9969.tar.gz fatcat-daf91b137483b7345448b597289c78f8fb3f9969.zip |
Merge branch 'bnewbold-sitemap' into 'master'
basic sitemap setup
See merge request webgroup/fatcat!79
Diffstat (limited to 'extra/sitemap/generate_sitemap_indices.py')
-rwxr-xr-x | extra/sitemap/generate_sitemap_indices.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/extra/sitemap/generate_sitemap_indices.py b/extra/sitemap/generate_sitemap_indices.py new file mode 100755 index 00000000..0a5624a1 --- /dev/null +++ b/extra/sitemap/generate_sitemap_indices.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +import sys +import glob +import datetime + +def index_entity(entity_type, output): + + now = datetime.date.today().isoformat() + print("""<?xml version="1.0" encoding="UTF-8"?>""", file=output) + print("""<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">""", file=output) + + for filename in glob.glob(f"sitemap-{entity_type}-*.txt.gz"): + print(" <sitemap>", file=output) + print(f" <loc>https://fatcat.wiki/{filename}</loc>", file=output) + print(f" <lastmod>{now}</lastmod>", file=output) + print(" </sitemap>", file=output) + + print("</sitemapindex>", file=output) + +def main(): + with open('sitemap-index-containers.xml', 'w') as output: + index_entity("containers", output) + with open('sitemap-index-releases.xml', 'w') as output: + index_entity("releases", output) + +if __name__=="__main__": + main() |