gnunet-svn
[Top][All Lists]
Advanced

[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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]