- 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:
|
with open(fpath, mode) as f:
|
||||||
logger.info("writing file %s", fpath)
|
logger.info("writing file %s", fpath)
|
||||||
f.write(content)
|
f.write(content)
|
||||||
|
if mtime > 0:
|
||||||
|
os.utime(fpath, (mtime, mtime))
|
||||||
|
|
||||||
|
|
||||||
def maybe_copy(source, target):
|
def maybe_copy(source, target):
|
||||||
|
@ -240,15 +242,14 @@ class Gone(object):
|
||||||
return {"source": self.source}
|
return {"source": self.source}
|
||||||
|
|
||||||
async def render(self):
|
async def render(self):
|
||||||
""" this is disabled for now """
|
if self.exists:
|
||||||
return
|
return
|
||||||
|
logger.info(
|
||||||
# if self.exists:
|
"rendering %s to %s", self.__class__, self.renderfile
|
||||||
# return
|
)
|
||||||
# logger.info("rendering %s to %s", self.__class__, self.renderfile)
|
writepath(
|
||||||
# writepath(
|
self.renderfile, J2.get_template(self.template).render()
|
||||||
# self.renderfile, J2.get_template(self.template).render()
|
)
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
class Redirect(Gone):
|
class Redirect(Gone):
|
||||||
|
@ -2325,23 +2326,38 @@ class WebmentionIO(object):
|
||||||
urlparse(webmention.get("target")).path.lstrip("/")
|
urlparse(webmention.get("target")).path.lstrip("/")
|
||||||
)[0]
|
)[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
|
# ignore selfpings
|
||||||
if slug == settings.site.get("name"):
|
if slug == settings.site.get("name"):
|
||||||
return
|
return
|
||||||
|
elif not len(slug):
|
||||||
|
logger.error(
|
||||||
|
"couldn't find post for incoming webmention: %s",
|
||||||
|
webmention.get("source"),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
fdir = glob.glob(
|
fdir = glob.glob(
|
||||||
os.path.join(settings.paths.get("content"), "*", slug)
|
os.path.join(settings.paths.get("content"), "*", slug)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not len(fdir):
|
if not len(fdir):
|
||||||
logger.error(
|
logger.error(
|
||||||
"couldn't find post for incoming webmention: %s",
|
"couldn't find post for incoming webmention: %s",
|
||||||
webmention,
|
webmention.get("source"),
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
elif len(fdir) > 1:
|
elif len(fdir) > 1:
|
||||||
logger.error(
|
logger.error(
|
||||||
"multiple posts found for incoming webmention: %s",
|
"multiple posts found for incoming webmention: %s",
|
||||||
webmention,
|
webmention.get("source"),
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -2354,7 +2370,10 @@ class WebmentionIO(object):
|
||||||
|
|
||||||
author = webmention.get("data", {}).get("author", None)
|
author = webmention.get("data", {}).get("author", None)
|
||||||
if not author:
|
if not author:
|
||||||
logger.error("missing author info on webmention; skipping")
|
logger.error(
|
||||||
|
"missing author info on webmention: %s",
|
||||||
|
webmention,
|
||||||
|
)
|
||||||
return
|
return
|
||||||
meta = {
|
meta = {
|
||||||
"author": {
|
"author": {
|
||||||
|
@ -2377,7 +2396,7 @@ class WebmentionIO(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
r = "---\n%s\n---\n\n%s\n" % (utfyamldump(meta), txt)
|
r = "---\n%s\n---\n\n%s\n" % (utfyamldump(meta), txt)
|
||||||
writepath(fpath, r)
|
writepath(fpath, r, mtime=dt.timestamp)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
webmentions = requests.get(self.url, params=self.params)
|
webmentions = requests.get(self.url, params=self.params)
|
||||||
|
@ -2483,10 +2502,12 @@ def make():
|
||||||
# make gone and redirect arrays for PHP
|
# make gone and redirect arrays for PHP
|
||||||
for e in glob.glob(os.path.join(content, "*", "*.del")):
|
for e in glob.glob(os.path.join(content, "*", "*.del")):
|
||||||
post = Gone(e)
|
post = Gone(e)
|
||||||
|
queue.put(post.render())
|
||||||
rules.add_gone(post.source)
|
rules.add_gone(post.source)
|
||||||
for e in glob.glob(os.path.join(content, "*", "*.url")):
|
for e in glob.glob(os.path.join(content, "*", "*.url")):
|
||||||
post = Redirect(e)
|
post = Redirect(e)
|
||||||
rules.add_redirect(post.source, post.target)
|
rules.add_redirect(post.source, post.target)
|
||||||
|
queue.put(post.render())
|
||||||
# render 404 fallback PHP
|
# render 404 fallback PHP
|
||||||
queue.put(rules.render())
|
queue.put(rules.render())
|
||||||
|
|
||||||
|
|
|
@ -147,11 +147,11 @@ menu = nameddict(
|
||||||
meta = nameddict(
|
meta = nameddict(
|
||||||
{
|
{
|
||||||
"webmention": "https://webmention.io/petermolnar.net/webmention",
|
"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/",
|
"hub": "https://petermolnar.superfeedr.com/",
|
||||||
"authorization_endpoint": "https://indieauth.com/auth",
|
"authorization_endpoint": "https://indieauth.com/auth",
|
||||||
"token_endpoint": "https://tokens.indieauth.com/token",
|
"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'
|
#'microsub': 'https://aperture.p3k.io/microsub/83'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8"/>
|
<meta charset="utf-8"/>
|
||||||
<meta content="width=device-width,initial-scale=1,minimum-scale=1" name="viewport"/>
|
<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>
|
<title>Moved</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<center>
|
<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>
|
</center>
|
||||||
</p>
|
</p>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -20,5 +20,5 @@ location /{{ from }} {
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for source, target in rewrites.items() %}
|
{% for source, target in rewrites.items() %}
|
||||||
#rewrite {{ source }} {{ target}} permanent;
|
rewrite {{ source }} {{ target}} permanent;
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
* {
|
* {
|
||||||
-webkit-box-sizing: border-box;
|
-webkit-box-sizing: border-box;
|
||||||
-moz-box-sizing: border-box;
|
-moz-box-sizing: border-box;
|
||||||
|
@ -398,7 +397,7 @@ li p {
|
||||||
#main.photo {
|
#main.photo {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main.photo {
|
#main.photo {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
@ -408,9 +407,25 @@ li p {
|
||||||
#main.photo article {
|
#main.photo article {
|
||||||
flex: 1 1 30em;
|
flex: 1 1 30em;
|
||||||
margin: 0.2em;
|
margin: 0.2em;
|
||||||
|
max-width: 70em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main.photo article h3 {
|
#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