aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-05-07 12:53:54 +0200
committerFlorian Dold <florian@dold.me>2021-05-07 12:53:54 +0200
commit24aa0a0b16ec3b358be585d5409fe3dc93f71a67 (patch)
tree42f6e7648e6e7d61ade71369cfb7997f2f727b7c
parent543f91c2566e547d5c50d8e519ab57b10e8dd650 (diff)
downloadwww_shared-24aa0a0b16ec3b358be585d5409fe3dc93f71a67.tar.gz
www_shared-24aa0a0b16ec3b358be585d5409fe3dc93f71a67.zip
fix sitemap URLs, cleanup
-rw-r--r--site.py14
-rw-r--r--textproc.py2
-rw-r--r--time.py3
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:
134 yaml = YAML(typ="safe") 134 yaml = YAML(typ="safe")
135 site_configfile = self.root / "www.yml" 135 site_configfile = self.root / "www.yml"
136 self.config = yaml.load(site_configfile) 136 self.config = yaml.load(site_configfile)
137 137 print(type(self.config))
138 def copy_trees(self, directory): 138 print(self.config)
139 """ Take a directory name (string) and pass it to copy_tree() as Path object. """ 139 self.baseurl = os.environ.get("BASEURL")
140 i = Path(directory) 140 if self.baseurl is None:
141 o = Path("rendered/" + directory) 141 self.baseurl = self.config["siteconf"].get("baseurl")
142 copy_tree(i, o)
143 142
144 def gen_abstract(self, name, member, pages, length): 143 def gen_abstract(self, name, member, pages, length):
145 conf = self.config 144 conf = self.config
@@ -198,9 +197,10 @@ class SiteGenerator:
198 f.write('http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"\n') 197 f.write('http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"\n')
199 f.write('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n') 198 f.write('xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n')
200 for link in links: 199 for link in links:
200 href = self.baseurl + str(link.relative_to(p))
201 f.write( 201 f.write(
202 "<url><loc>" 202 "<url><loc>"
203 + str(link).lstrip("rendered") 203 + href
204 + "</loc><lastmod>" 204 + "</loc><lastmod>"
205 + timestamp 205 + timestamp
206 + "</lastmod><priority>1.0</priority></url>\n" 206 + "</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):
77 with open(filename) as html: 77 with open(filename) as html:
78 soup = BeautifulSoup(html, features="lxml") 78 soup = BeautifulSoup(html, features="lxml")
79 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>', "") 79 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>', "")
80 urlstr = "https://" + conf["siteconf"][0]["baseurl"] + "/" + lang + "/" 80 urlstr = "https://" + conf["siteconf"]["baseurl"] + "/" + lang + "/"
81 text = i.replace("\n", "").replace("{{ url_localized('", urlstr).replace("') }}", "") 81 text = i.replace("\n", "").replace("{{ url_localized('", urlstr).replace("') }}", "")
82 # .replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;') 82 # .replace('<', '&lt;').replace('>', '&gt;').replace('"', '&quot;')
83 return text 83 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):
42 return email.utils.formatdate(t) 42 return email.utils.formatdate(t)
43 elif type(t) == datetime.datetime: 43 elif type(t) == datetime.datetime:
44 return email.utils.format_datetime(t,usegmt=True) 44 return email.utils.format_datetime(t,usegmt=True)
45 else: 45 raise TypeError()
46 return sys.exit(1)