diff --git a/keys.dist.py b/keys.dist.py index 5d3422c..960cc82 100644 --- a/keys.dist.py +++ b/keys.dist.py @@ -5,6 +5,5 @@ webmentionio = { } telegraph = { - 'token': 'https://telegraph.p3k.io/ -> select site under avatar -> settings gear icon -> API key' + 'token': 'https://telegraph.p3k.io/ -> select site under avatar -> settings gear icon -> API key' } - diff --git a/nasg.py b/nasg.py index 79dc2cf..421699f 100644 --- a/nasg.py +++ b/nasg.py @@ -931,30 +931,22 @@ class Singular(MarkdownDoc): def oembed_json(self): r = { "version": "1.0", - "url": self.url, "provider_name": settings.site.name, "provider_url": settings.site.url, "author_name": settings.author.name, "author_url": settings.author.url, "title": self.title, - "type": "link", - "html": self.html_content, + "type": "link" } - img = None if self.is_photo: - img = self.photo - elif not self.is_photo and len(self.images): - img = list(self.images.values())[0] - if img: r.update({ - "type": "rich", - "thumbnail_url": img.jsonld.thumbnail.url, - "thumbnail_width": img.jsonld.thumbnail.width, - "thumbnail_height": img.jsonld.thumbnail.height + "type": "photo", + "url": self.photo.jsonld.thumbnail.url, + "width": self.photo.jsonld.thumbnail.width, + "height": self.photo.jsonld.thumbnail.height }) return r - async def copyfiles(self): exclude = [ '.md', @@ -1027,14 +1019,14 @@ class Singular(MarkdownDoc): ) del(j) # oembed - writepath( - os.path.join(self.renderdir, settings.filenames.oembed_json), - json.dumps(self.oembed_json, indent=4, ensure_ascii=False) - ) - writepath( - os.path.join(self.renderdir, settings.filenames.oembed_xml), - self.oembed_xml - ) + # writepath( + # os.path.join(self.renderdir, settings.filenames.oembed_json), + # json.dumps(self.oembed_json, indent=4, ensure_ascii=False) + # ) + # writepath( + # os.path.join(self.renderdir, settings.filenames.oembed_xml), + # self.oembed_xml + # ) class Home(Singular): def __init__(self, fpath): @@ -1682,8 +1674,7 @@ class WebhookPHP(PHPFile): async def _render(self): r = J2.get_template(self.templatefile).render({ 'author': settings.author, - 'webmentionio': keys.webmentionio, - 'zapier': keys.zapier, + 'webmentionio': keys.webmentionio }) writepath(self.renderfile, r) @@ -2264,7 +2255,7 @@ def dat(): if not os.path.isdir(p): os.makedirs(p) p = os.path.join(settings.paths.build, '.well-known', 'dat') - if not os.path.exists(p): + if not os.path.exists(p) or settings.args.get('force'): writepath(p, "%s\nTTL=3600" % (url)) @@ -2273,7 +2264,7 @@ def make(): last = 0 # this needs to be before collecting the 'content' itself - if not settings.args.get('nosync'): + if not settings.args.get('offline') and not settings.args.get('noservices'): incoming = WebmentionIO() incoming.run() @@ -2373,12 +2364,12 @@ def make(): cp(e, t) # dat data - dat() + #dat() end = int(round(time.time() * 1000)) logger.info('process took %d ms' % (end - start)) - if not settings.args.get('nosync'): + if not settings.args.get('offline'): # upload site try: logger.info('starting syncing') @@ -2393,7 +2384,7 @@ def make(): except Exception as e: logger.error('syncing failed: %s', e) - if not settings.args.get('nosync'): + if not settings.args.get('offline') and not settings.args.get('noservices'): logger.info('sending webmentions') for wm in send: queue.put(wm.send()) diff --git a/settings.py b/settings.py index 8fe3b63..770f3f3 100644 --- a/settings.py +++ b/settings.py @@ -49,7 +49,6 @@ site = struct({ "image": "https://petermolnar.net/favicon.ico", "license": "https://spdx.org/licenses/%s.html" % (licence['_default']), "sameAs": [ - "dat://7efecc3c33baf69d6fecf801e15ede92b369f4944f766489b156263119220939" ], "author": { "@context": "http://schema.org", @@ -109,14 +108,6 @@ site = struct({ "name": "paypal", "url": "https://paypal.me/petermolnar/", "recipient": author - }, - { - "@context": "http://schema.org", - "@type": "DonateAction", - "description": "Cash App", - "name": "cash", - "url": "https://cash.app/%C2%A3pmlnr", - "recipient": author } ] }) @@ -181,6 +172,12 @@ filenames = struct({ 'oembed_json': 'oembed.json' }) +datignore = [ + '.git', + '.dat', + '**.php' +] + photo = struct({ 're_author': re.compile(r'(?:P[eé]ter Moln[aá]r)|(?:Moln[aá]r P[eé]ter)|(?:petermolnar\.(?:eu|net))'), 'default': 720, @@ -209,12 +206,13 @@ if not os.path.isdir(tmpdir): _parser = argparse.ArgumentParser(description='Parameters for NASG') _booleanparams = { - 'regenerate': 'force downsizing images', - 'force': 'force rendering HTML', - 'nosync': 'skip sync to live server', + 'regenerate': 'force (re)downsizing images', + 'force': 'force (re)rendering HTML', 'debug': 'set logging to debug level', 'quiet': 'show only errors', - 'noping': 'don\'t send webmentions but save a dummy that it was done' + 'offline': 'offline mode - no syncing, no querying services, etc.', + 'noping': 'make dummy webmention entries and don\'t really send them', + 'noservices': 'skip querying any service but do sync the website' } for k, v in _booleanparams.items(): diff --git a/templates/Singular.j2.html b/templates/Singular.j2.html index 3e69fff..edebdab 100644 --- a/templates/Singular.j2.html +++ b/templates/Singular.j2.html @@ -9,8 +9,6 @@ - - @@ -18,13 +16,6 @@ - {% if post.image is iterable %} @@ -33,6 +24,15 @@ {% else %} {% endif %} + + + + + + + + + {% if post['@type'] == 'TechArticle' %}