- redirects and gones are now rendered
- xmlrpc link removed because spam - minor template cleanups - incmonig webmention logging improvements
This commit is contained in:
parent
a985f5ca33
commit
70a775b6d5
5 changed files with 58 additions and 22 deletions
47
nasg.py
47
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())
|
||||
|
||||
|
|
|
@ -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'
|
||||
}
|
||||
)
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<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>
|
||||
<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>
|
||||
|
|
|
@ -20,5 +20,5 @@ location /{{ from }} {
|
|||
{% endfor %}
|
||||
|
||||
{% for source, target in rewrites.items() %}
|
||||
#rewrite {{ source }} {{ target}} permanent;
|
||||
rewrite {{ source }} {{ target}} permanent;
|
||||
{% endfor %}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
#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;
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in a new issue