[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[www_shared] branch master updated (543f91c -> 99649d5)
From: |
gnunet |
Subject: |
[www_shared] branch master updated (543f91c -> 99649d5) |
Date: |
Fri, 07 May 2021 11:07:38 +0200 |
This is an automated email from the git hooks/post-receive script.
dold pushed a change to branch master
in repository www_shared.
from 543f91c fix relative linking
new 24aa0a0 fix sitemap URLs, cleanup
new 4b108ef gitignore
new 99649d5 formatting
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.gitignore | 33 ---------------------------------
mybabel.py | 10 +++++-----
site.py | 14 +++++++-------
textproc.py | 31 +++++++++++++++++++++----------
time.py | 9 ++++++---
5 files changed, 39 insertions(+), 58 deletions(-)
diff --git a/.gitignore b/.gitignore
index b25ec1e..bee8a64 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,34 +1 @@
-./*.html
-common/*.inc
-
-old/
-
-*.mo
-locale/*/
-locale/messages.pot
-
-videos/grothoff2014fossa.webm
-videos/grothoff2014fossa.ogv
-
-rendered/
-en/
-de/
-fr/
-it/
-es/
-ru/
-
__pycache__
-*.pyc
-
-static/styles.css
-
-sitemap.html
-
-*~
-\#*\#
-futility_engine_loader.sh
-
-config.mk
-
-*.core
diff --git a/mybabel.py b/mybabel.py
index 50fa0c4..daeb262 100644
--- a/mybabel.py
+++ b/mybabel.py
@@ -1,5 +1,5 @@
-#! /usr/bin/python3
-#
+#!/usr/bin/env python3
+
# This code is in the public domain.
#
# This is a wrapper around 'pybabel' that sets our include path
@@ -7,7 +7,7 @@
# pybabel program as the first argument (must be a Python script!)
# and passes the other arguments to pybabel after setting our
# sys.path.
-#
+
import shutil
import sys
@@ -15,11 +15,11 @@ import sys
sys.path.insert(0, ".")
# Now, find the actual pybabel program in the $PATH
-pb=shutil.which(sys.argv[1])
+pb = shutil.which(sys.argv[1])
# Remove 'pybabel' from argv[] so that pybabel doesn't confuse
# itself for the first command-line argument ;-)
sys.argv.remove(sys.argv[1])
# Now we can run pybabel. Yeah!
-exec(compile(source=open(pb).read(), filename=pb, mode='exec'))
+exec(compile(source=open(pb).read(), filename=pb, mode="exec"))
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..e39ee12 100644
--- a/textproc.py
+++ b/textproc.py
@@ -29,7 +29,7 @@ class extractText(html.parser.HTMLParser):
self.result.append(data)
def text_in(self):
- return ''.join(self.result)
+ return "".join(self.result)
def html2text(html):
@@ -44,12 +44,12 @@ def cut_text(filename, count):
for script in soup(["script", "style"]):
script.extract()
k = []
- for i in soup.findAll('p')[1]:
+ for i in soup.findAll("p")[1]:
k.append(i)
- b = ''.join(str(e) for e in k)
+ b = "".join(str(e) for e in k)
text = html2text(b.replace("\n", ""))
- textreduced = (text[:count] + ' [...]') if len(text) > count else
(text)
- return (textreduced)
+ textreduced = (text[:count] + " [...]") if len(text) > count else
(text)
+ return textreduced
def cut_news_text(filename, count):
@@ -63,9 +63,9 @@ def cut_by_frontier(filename):
with open(filename) as html:
soup = BeautifulSoup(html, features="lxml")
k = []
- for i in soup.find(id='newspost-content'):
+ for i in soup.find(id="newspost-content"):
k.append(i)
- b = ''.join(str(e) in k)
+ b = "".join(str(e) in k)
text = b.replace("\n", "")
return text
@@ -73,11 +73,22 @@ def cut_by_frontier(filename):
def cut_article(filename, conf, lang):
return cut_all("template/news/" + filename + ".j2", conf, lang)
+
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 + "/"
- text = i.replace("\n", "").replace("{{ url_localized('",
urlstr).replace("') }}", "")
+ 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"]["baseurl"] + "/" + lang + "/"
+ text = (
+ i.replace("\n", "")
+ .replace("{{ url_localized('", urlstr)
+ .replace("') }}", "")
+ )
# .replace('<', '<').replace('>', '>').replace('"', '"')
return text
diff --git a/time.py b/time.py
index 9b53d1b..d023de7 100644
--- a/time.py
+++ b/time.py
@@ -20,9 +20,11 @@ import time
import datetime
import email.utils
+
def time_now():
return datetime.datetime.now(tz=datetime.timezone.utc)
+
def conv_date(t):
# naively assumes its input is always a Y-m-d.
if type(t) == str:
@@ -34,13 +36,14 @@ def conv_date(t):
else:
return sys.exit(1)
+
def conv_date_rfc822(t):
return time_rfc822(conv_date(t))
+
def time_rfc822(t):
if type(t) == float:
return email.utils.formatdate(t)
elif type(t) == datetime.datetime:
- return email.utils.format_datetime(t,usegmt=True)
- else:
- return sys.exit(1)
+ return email.utils.format_datetime(t, usegmt=True)
+ raise TypeError()
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [www_shared] branch master updated (543f91c -> 99649d5),
gnunet <=