gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[www_shared] 01/03: fix sitemap URLs, cleanup


From: gnunet
Subject: [www_shared] 01/03: fix sitemap URLs, cleanup
Date: Fri, 07 May 2021 11:07:39 +0200

This is an automated email from the git hooks/post-receive script.

dold pushed a commit to branch master
in repository www_shared.

commit 24aa0a0b16ec3b358be585d5409fe3dc93f71a67
Author: Florian Dold <florian@dold.me>
AuthorDate: Fri May 7 12:53:54 2021 +0200

    fix sitemap URLs, cleanup
---
 site.py     | 14 +++++++-------
 textproc.py |  2 +-
 time.py     |  3 +--
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/site.py b/site.py
index 260921f..e5cc461 100644
--- a/site.py
+++ b/site.py
@@ -134,12 +134,11 @@ class SiteGenerator:
         yaml = YAML(typ="safe")
         site_configfile = self.root / "www.yml"
         self.config = yaml.load(site_configfile)
-
-    def copy_trees(self, directory):
-        """ Take a directory name (string) and pass it to copy_tree() as Path 
object. """
-        i = Path(directory)
-        o = Path("rendered/" + directory)
-        copy_tree(i, o)
+        print(type(self.config))
+        print(self.config)
+        self.baseurl = os.environ.get("BASEURL")
+        if self.baseurl is None:
+            self.baseurl = self.config["siteconf"].get("baseurl")
 
     def gen_abstract(self, name, member, pages, length):
         conf = self.config
@@ -198,9 +197,10 @@ class SiteGenerator:
             
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:
+                href = self.baseurl + str(link.relative_to(p))
                 f.write(
                     "<url><loc>"
-                    + str(link).lstrip("rendered")
+                    + href
                     + "</loc><lastmod>"
                     + timestamp
                     + "</lastmod><priority>1.0</priority></url>\n"
diff --git a/textproc.py b/textproc.py
index ef44bf1..5a2f96d 100644
--- a/textproc.py
+++ b/textproc.py
@@ -77,7 +77,7 @@ def cut_all(filename, conf, lang):
     with open(filename) as html:
         soup = BeautifulSoup(html, features="lxml")
         i = repr(soup).replace('{% extends "common/news.j2" %}\n{% block 
body_content %}\n', "").replace('\n{% endblock body_content %}', 
"").replace('<html><body><p></p>',"").replace('</body></html>', "")
-        urlstr = "https://"; + conf["siteconf"][0]["baseurl"] + "/" + lang + "/"
+        urlstr = "https://"; + conf["siteconf"]["baseurl"] + "/" + lang + "/"
         text = i.replace("\n", "").replace("{{ url_localized('", 
urlstr).replace("') }}", "")
         # .replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;')
         return text
diff --git a/time.py b/time.py
index 9b53d1b..bfd6a39 100644
--- a/time.py
+++ b/time.py
@@ -42,5 +42,4 @@ def time_rfc822(t):
         return email.utils.formatdate(t)
     elif type(t) == datetime.datetime:
         return email.utils.format_datetime(t,usegmt=True)
-    else:
-        return sys.exit(1)
+    raise TypeError()

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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