fixes to skip webmentions when post is_future; better regex match for markdown images, though it's not utilized yet

This commit is contained in:
Peter Molnar 2019-04-29 09:33:21 +01:00
parent f196b26b79
commit 8505789e1a

20
nasg.py
View file

@ -63,7 +63,7 @@ J2 = jinja2.Environment(
) )
RE_MDIMG = re.compile( RE_MDIMG = re.compile(
r'(?P<match>!\[(?P<alt>[^\]]+)?\]\((?P<fname>[^\s]+)' r'(?P<match>!\[(?P<alt>[^\]]+)?\]\((?P<fname>[^\s\]]+)'
r'(?:\s[\'\"](?P<title>[^\"\']+)[\'\"])?\)(?:{(?P<css>[^\}]+)\})?)', r'(?:\s[\'\"](?P<title>[^\"\']+)[\'\"])?\)(?:{(?P<css>[^\}]+)\})?)',
re.IGNORECASE re.IGNORECASE
) )
@ -245,7 +245,7 @@ class Webmention(object):
if self.exists: if self.exists:
return return
elif settings.args.get('noping'): elif settings.args.get('noping'):
self.save("noping entry at %" %(arrow.now())) self.save("noping entry at %s" % arrow.now() )
return return
telegraph_url = 'https://telegraph.p3k.io/webmention' telegraph_url = 'https://telegraph.p3k.io/webmention'
@ -653,7 +653,7 @@ class Singular(MarkdownDoc):
elif self.is_photo: elif self.is_photo:
w = Webmention( w = Webmention(
self.url, self.url,
'https://brid.gy/publish/flickr/', 'https://brid.gy/publish/flickr',
os.path.dirname(self.fpath), os.path.dirname(self.fpath),
self.dt self.dt
) )
@ -802,6 +802,7 @@ class Singular(MarkdownDoc):
"potentialAction": [], "potentialAction": [],
"comment": [], "comment": [],
"commentCount": len(self.comments.keys()), "commentCount": len(self.comments.keys()),
"keywords": self.tags
} }
if self.is_photo: if self.is_photo:
@ -2182,9 +2183,15 @@ class WebmentionIO(object):
'type': webmention.get('activity').get('type', 'webmention') 'type': webmention.get('activity').get('type', 'webmention')
} }
try:
txt = webmention.get('data').get('content', '').strip()
except Exception as e:
txt = ''
pass
r = "---\n%s\n---\n\n%s\n" % ( r = "---\n%s\n---\n\n%s\n" % (
utfyamldump(meta), utfyamldump(meta),
webmention.get('data').get('content', '').strip() txt
) )
writepath(fpath, r) writepath(fpath, r)
@ -2259,8 +2266,9 @@ def make():
# deal with images, if needed # deal with images, if needed
for i in post.images.values(): for i in post.images.values():
queue.put(i.downsize()) queue.put(i.downsize())
for i in post.to_ping: if not post.is_future:
send.append(i) for i in post.to_ping:
send.append(i)
# render and arbitrary file copy tasks for this very post # render and arbitrary file copy tasks for this very post
queue.put(post.render()) queue.put(post.render())