[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[www_shared] 05/19: add sitemap generator script in python.
From: |
gnunet |
Subject: |
[www_shared] 05/19: add sitemap generator script in python. |
Date: |
Sat, 25 Jan 2020 11:29:20 +0100 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository www_shared.
commit b91d7308fc9ab4f0658d180ff563ed0bee35f166
Author: ng0 <address@hidden>
AuthorDate: Tue Nov 12 23:59:53 2019 +0000
add sitemap generator script in python.
---
make_sitemap.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/make_sitemap.py b/make_sitemap.py
new file mode 100644
index 0000000..d406e8b
--- /dev/null
+++ b/make_sitemap.py
@@ -0,0 +1,52 @@
+# This file is part of www_shared.
+# (C) 2019 GNUnet e.V.
+#
+# Authors:
+# Author: ng0 <address@hidden>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
+# LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+# THIS SOFTWARE.
+#
+# SPDX-License-Identifier: 0BSD
+#
+# A sitemap generator.
+
+import sys
+from pathlib import Path
+from datetime import datetime
+
+def main():
+ if len(sys.argv) >= 2 and sys.argv[1] == "-i":
+ i = sys.argv[2]
+ else:
+ i = "rendered"
+
+ p = Path(i)
+ links = sorted(p.rglob("*.html"))
+ t0 = datetime.now()
+ timestamp = t0.strftime("%Y-%m-%d")
+
+ o = Path("sitemap.xml")
+ with o.open("w") as f:
+ f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
+ f.write('<urlset\n')
+ f.write('xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\n')
+
f.write('xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 ')
+ f.write('http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"\n')
+ f.write('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n')
+ for link in links:
+ f.write('<url><loc>' + str(link).lstrip("rendered") +
'</loc><lastmod>' + timestamp + '</lastmod><priority>1.0</priority></url>\n')
+ f.write('</urlset>\n')
+
+
+if __name__ == "__main__":
+ main()
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [www_shared] branch master created (now 6a51c97), gnunet, 2020/01/25
- [www_shared] 02/19: add README., gnunet, 2020/01/25
- [www_shared] 04/19: LICENSE., gnunet, 2020/01/25
- [www_shared] 06/19: readme, gnunet, 2020/01/25
- [www_shared] 01/19: init from www.git, gnunet, 2020/01/25
- [www_shared] 03/19: drop sum.py, remove function from fileproc., gnunet, 2020/01/25
- [www_shared] 09/19: rss2.0 spec., gnunet, 2020/01/25
- [www_shared] 14/19: add macro for single link preview, gnunet, 2020/01/25
- [www_shared] 08/19: follow-up, add rss, gnunet, 2020/01/25
- [www_shared] 05/19: add sitemap generator script in python.,
gnunet <=
- [www_shared] 07/19: debug print statements., gnunet, 2020/01/25
- [www_shared] 11/19: Merge branch 'default' of gnunet.org:www_shared into default, gnunet, 2020/01/25
- [www_shared] 17/19: news.macro.j2: use date: title for shortnews, gnunet, 2020/01/25
- [www_shared] 12/19: merge README.text and README, gnunet, 2020/01/25
- [www_shared] 18/19: avoid need to have Makefile set PYTHONPATH (breaks then other things), gnunet, 2020/01/25
- [www_shared] 16/19: remove forgotten todo file, gnunet, 2020/01/25
- [www_shared] 13/19: Add copyright header, fix copyright headers., gnunet, 2020/01/25
- [www_shared] 10/19: licensing, notes, todo, readme, gnunet, 2020/01/25
- [www_shared] 15/19: site.py: expose conf directly to jinja2., gnunet, 2020/01/25
- [www_shared] 19/19: add mybabel wrapper, gnunet, 2020/01/25