all repos — nasg @ 70a775b6d5510481512ba66487dccb11cc2328ee

- redirects and gones are now rendered
- xmlrpc link removed because spam
- minor template cleanups
- incmonig webmention logging improvements
Peter Molnar hello@petermolnar.eu
Sat, 19 Oct 2019 10:05:54 +0100
commit

70a775b6d5510481512ba66487dccb11cc2328ee

parent

a985f5ca334a97acd11b6f3e8c4f49003146b51a

5 files changed, 58 insertions(+), 22 deletions(-)

jump to
M nasg.pynasg.py

@@ -128,6 +128,8 @@ mode = "wb"

with open(fpath, mode) as f: logger.info("writing file %s", fpath) f.write(content) + if mtime > 0: + os.utime(fpath, (mtime, mtime)) def maybe_copy(source, target):

@@ -240,15 +242,14 @@ def tmplvars(self):

return {"source": self.source} async def render(self): - """ this is disabled for now """ - return - - # if self.exists: - # return - # logger.info("rendering %s to %s", self.__class__, self.renderfile) - # writepath( - # self.renderfile, J2.get_template(self.template).render() - # ) + if self.exists: + return + logger.info( + "rendering %s to %s", self.__class__, self.renderfile + ) + writepath( + self.renderfile, J2.get_template(self.template).render() + ) class Redirect(Gone):

@@ -2325,23 +2326,38 @@ slug = os.path.split(

urlparse(webmention.get("target")).path.lstrip("/") )[0] + author = webmention.get("data", {}).get("author", None) + if not author: + logger.error( + "missing author info on webmention; skipping; webmention data is: %s", + webmention.get("source"), + ) + return + # ignore selfpings if slug == settings.site.get("name"): return + elif not len(slug): + logger.error( + "couldn't find post for incoming webmention: %s", + webmention.get("source"), + ) + fdir = glob.glob( os.path.join(settings.paths.get("content"), "*", slug) ) + if not len(fdir): logger.error( "couldn't find post for incoming webmention: %s", - webmention, + webmention.get("source"), ) return elif len(fdir) > 1: logger.error( "multiple posts found for incoming webmention: %s", - webmention, + webmention.get("source"), ) return

@@ -2354,7 +2370,10 @@ )

author = webmention.get("data", {}).get("author", None) if not author: - logger.error("missing author info on webmention; skipping") + logger.error( + "missing author info on webmention: %s", + webmention, + ) return meta = { "author": {

@@ -2377,7 +2396,7 @@ txt = ""

pass r = "---\n%s\n---\n\n%s\n" % (utfyamldump(meta), txt) - writepath(fpath, r) + writepath(fpath, r, mtime=dt.timestamp) def run(self): webmentions = requests.get(self.url, params=self.params)

@@ -2483,10 +2502,12 @@

# make gone and redirect arrays for PHP for e in glob.glob(os.path.join(content, "*", "*.del")): post = Gone(e) + queue.put(post.render()) rules.add_gone(post.source) for e in glob.glob(os.path.join(content, "*", "*.url")): post = Redirect(e) rules.add_redirect(post.source, post.target) + queue.put(post.render()) # render 404 fallback PHP queue.put(rules.render())
M settings.pysettings.py

@@ -147,11 +147,11 @@

meta = nameddict( { "webmention": "https://webmention.io/petermolnar.net/webmention", - "pingback": "https://webmention.io/petermolnar.net/xmlrpc", + #"pingback": "https://webmention.io/petermolnar.net/xmlrpc", "hub": "https://petermolnar.superfeedr.com/", "authorization_endpoint": "https://indieauth.com/auth", "token_endpoint": "https://tokens.indieauth.com/token", - "micropub": "https://petermolnar.net/micropub.php", + "micropub": "https://hooks.zapier.com/hooks/catch/3982452/o3hpw1x/", #'microsub': 'https://aperture.p3k.io/microsub/83' } )
M templates/Redirect.j2.htmltemplates/Redirect.j2.html

@@ -3,7 +3,7 @@ <html lang="en">

<head> <meta charset="utf-8"/> <meta content="width=device-width,initial-scale=1,minimum-scale=1" name="viewport"/> - <meta http-equiv="refresh" content="0; url={{ target }}" /> + <meta http-equiv="refresh" content="3; url={{ target }}" /> <title>Moved</title> </head>

@@ -20,7 +20,7 @@ </p>

<p> <center> - You will be redirected in 3 seconds; if that does not happen, please click in the link. + You will be redirected in 3 seconds; if that does not happen, please click on the link. </center> </p> </body>
M templates/nginx.j2.conftemplates/nginx.j2.conf

@@ -20,5 +20,5 @@

{% endfor %} {% for source, target in rewrites.items() %} -#rewrite {{ source }} {{ target}} permanent; +rewrite {{ source }} {{ target}} permanent; {% endfor %}
M templates/style.csstemplates/style.css

@@ -1,4 +1,3 @@

- * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box;

@@ -398,7 +397,7 @@ @media all and (min-width: 70em) {

#main.photo { max-width: 100%; } - + #main.photo { display: flex; flex-wrap: wrap;

@@ -408,9 +407,25 @@

#main.photo article { flex: 1 1 30em; margin: 0.2em; + max-width: 70em; } #main.photo article h3 { - text-align: center; + text-align: center; } -} + + /* + #main.photo article section p, + #main.photo article section section, + #main.photo article h3 { + display: none; + } + + #main.photo article * > img { + height: 20em; + max-width: 100%; + min-width: 100%; + object-fit:contain; + } + */ +}