From ce9ddb451a9f7cd9f27a2cb67c43b8ce459d611f Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Fri, 8 Jun 2018 09:14:39 +0000 Subject: [PATCH] before autopep --- nasg.py | 31 +++++++++++++++++++++++++++++++ templates/Singular.html | 1 + 2 files changed, 32 insertions(+) diff --git a/nasg.py b/nasg.py index 9be362d..bd40c6c 100644 --- a/nasg.py +++ b/nasg.py @@ -786,6 +786,29 @@ class Singular(object): def description(self): return html.escape(self.meta.get('summary', '')) + @property + def oembedvars(self): + if not hasattr(self, '_oembedvars'): + self._oembedvars = { + "version": "1.0", + "type": "link", + "title": self.title, + "url": "%s/%s/" % (shared.site.get('url'), self.fname), + "author_name": shared.site.get('author').get('name'), + "author_url": shared.site.get('author').get('url'), + "provider_name": shared.site.get('title'), + "provider_url": shared.site.get('url'), + } + if self.photo: + self._oembedvars.update({ + "type": "photo", + "width": self.photo.tmplvars.get('width'), + "height": self.photo.tmplvars.get('height'), + "url": self.photo.tmplvars.get('src'), + }) + return self._oembedvars + + @property def tmplvars(self): # very simple caching because we might use this 4 times: @@ -851,6 +874,14 @@ class Singular(object): out.write(r) # use the comment time, not the source file time for this os.utime(o, (self.stime, self.stime)) + #oembed = os.path.join( + #shared.config.get('common', 'build'), + #self.fname, + #'oembed.json' + #) + #with open(oembed, 'wt') as out: + #logging.debug('writing oembed file %s', oembed) + #out.write(json.dumps(self.oembedvars)) def __repr__(self): return "%s/%s" % (self.category, self.fname) diff --git a/templates/Singular.html b/templates/Singular.html index 5a5d6f9..776a321 100644 --- a/templates/Singular.html +++ b/templates/Singular.html @@ -8,6 +8,7 @@ + {% include 'block_header_close.html' %}