diff --git a/nasg.py b/nasg.py index 40683bb..ca27f40 100644 --- a/nasg.py +++ b/nasg.py @@ -128,6 +128,8 @@ def writepath(fpath, content, mtime=0): 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 @@ class Gone(object): 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 @@ class WebmentionIO(object): 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 @@ class WebmentionIO(object): 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 @@ class WebmentionIO(object): 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 @@ def make(): # 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()) diff --git a/settings.py b/settings.py index 86648ed..ce5f4cc 100644 --- a/settings.py +++ b/settings.py @@ -147,11 +147,11 @@ menu = nameddict( 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' } ) diff --git a/templates/Redirect.j2.html b/templates/Redirect.j2.html index 4509b3a..49aa0e3 100644 --- a/templates/Redirect.j2.html +++ b/templates/Redirect.j2.html @@ -3,7 +3,7 @@ - + Moved @@ -20,7 +20,7 @@

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

diff --git a/templates/nginx.j2.conf b/templates/nginx.j2.conf index c0b7db3..2a87838 100644 --- a/templates/nginx.j2.conf +++ b/templates/nginx.j2.conf @@ -20,5 +20,5 @@ location /{{ from }} { {% endfor %} {% for source, target in rewrites.items() %} -#rewrite {{ source }} {{ target}} permanent; +rewrite {{ source }} {{ target}} permanent; {% endfor %} diff --git a/templates/style.css b/templates/style.css index ce89b03..188d5d6 100644 --- a/templates/style.css +++ b/templates/style.css @@ -1,4 +1,3 @@ - * { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; @@ -398,7 +397,7 @@ li p { #main.photo { max-width: 100%; } - + #main.photo { display: flex; flex-wrap: wrap; @@ -408,9 +407,25 @@ li p { #main.photo article { flex: 1 1 30em; margin: 0.2em; + max-width: 70em; } #main.photo article h3 { - text-align: center; + text-align: center; } -} \ No newline at end of file + + /* + #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; + } + */ +} \ No newline at end of file