diff --git a/.venv/bin/activate b/.venv/bin/activate index 5d23d51..d88952c 100644 --- a/.venv/bin/activate +++ b/.venv/bin/activate @@ -37,7 +37,7 @@ deactivate () { # unset irrelevant variables deactivate nondestructive -VIRTUAL_ENV="/home/cadeyrn/Projects/petermolnar.net/nasg/.venv" +VIRTUAL_ENV="~/Projects/petermolnar.net/nasg/.venv" export VIRTUAL_ENV _OLD_VIRTUAL_PATH="$PATH" diff --git a/.venv/bin/pip3 b/.venv/bin/pip3 deleted file mode 100755 index 0f85e0f..0000000 --- a/.venv/bin/pip3 +++ /dev/null @@ -1,11 +0,0 @@ -#!/home/cadeyrn/Projects/petermolnar.net/nasg/.venv/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from pip import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/.venv/bin/pip3 b/.venv/bin/pip3 new file mode 120000 index 0000000..4d6aa0d --- /dev/null +++ b/.venv/bin/pip3 @@ -0,0 +1 @@ +pip \ No newline at end of file diff --git a/.venv/bin/pip3.6 b/.venv/bin/pip3.6 deleted file mode 100755 index 0f85e0f..0000000 --- a/.venv/bin/pip3.6 +++ /dev/null @@ -1,11 +0,0 @@ -#!/home/cadeyrn/Projects/petermolnar.net/nasg/.venv/bin/python3 - -# -*- coding: utf-8 -*- -import re -import sys - -from pip import main - -if __name__ == '__main__': - sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) - sys.exit(main()) diff --git a/.venv/bin/pip3.6 b/.venv/bin/pip3.6 new file mode 120000 index 0000000..4d6aa0d --- /dev/null +++ b/.venv/bin/pip3.6 @@ -0,0 +1 @@ +pip \ No newline at end of file diff --git a/nasg.py b/nasg.py index 92a6e1f..92627bd 100644 --- a/nasg.py +++ b/nasg.py @@ -287,16 +287,22 @@ class Singular(MarkdownDoc): return True return False + @property + def photo(self): + if not self.is_photo: + return None + return next(iter(self.images.values())) + @property def enclosure(self): if not self.is_photo: - return False - photo = next(iter(self.images.values())) - return { - 'mime': photo.mime_type, - 'size': photo.mime_size, - 'url': photo.href - } + return None + else: + return { + 'mime': self.photo.mime_type, + 'size': self.photo.mime_size, + 'url': self.photo.href + } @property def summary(self): @@ -942,6 +948,7 @@ class Category(dict): 'display': self.display, 'url': self.url, 'feed': "%s%s/" % (self.url, 'feed'), + 'jsonfeed': "%s%s/index.json" % (self.url, 'feed'), 'title': self.title } @@ -953,10 +960,15 @@ class Category(dict): def exists(self): if settings.args.get('force'): return False - renderfile = os.path.join(self.renderdir, 'feed', 'index.xml') - if not os.path.exists(renderfile): - return False - elif self.mtime > os.path.getmtime(renderfile): + ismissing = False + for f in [ + os.path.join(self.renderdir, 'feed', 'index.xml'), + ]: + if not os.path.exists(f): + ismissing = True + elif self.mtime > os.path.getmtime(f): + ismissing = True + if ismissing: return False else: return True @@ -981,30 +993,8 @@ class Category(dict): fg.logo('%s/favicon.png' % settings.site.get('url')) fg.updated(arrow.get(self.mtime).to('utc').datetime) - jselements = [] - jsfeed = { - 'items': jselements, - 'version': 'https://jsonfeed.org/version/1', - 'title': self.title, - 'home_page_url': settings.site.get('url'), - 'feed_url': self.feed, - 'author': { - 'name': settings.author.get('name'), - 'url': settings.author.get('url'), - 'email': settings.author.get('email'), - } - } - for post in self.get_posts(start, end): dt = arrow.get(post.get('pubtime')) - jselements.append({ - "title": post.get('title'), - "date_published": post.get('pubtime'), - "id": post.get('url'), - "url": post.get('url'), - "content_html": post.get('html_content') - }) - fe = fg.add_entry() fe.id(post.get('url')) fe.link(href=post.get('url')) @@ -1015,7 +1005,6 @@ class Category(dict): post.get('html_content'), type='CDATA' ) - fe.rights('%s %s %s' % ( post.get('licence').upper(), settings.author.get('name'), @@ -1033,9 +1022,6 @@ class Category(dict): logging.info('writing file: %s', atom) f.write(fg.atom_str(pretty=True)) jsfile = os.path.join(dirname, 'index.json') - with open(jsfile, 'wt') as f: - logging.info('writing file: %s', jsfile) - f.write(json.dumps(jsfeed, indent=4, sort_keys=True)) def render_page(self, pagenum=1, pages=1): if self.display == 'flat': diff --git a/settings.py b/settings.py index 0024c5b..cc233d5 100644 --- a/settings.py +++ b/settings.py @@ -101,10 +101,8 @@ tips = [ ] dateformat = { - 'iso': 'YYYY-MM-DDTHH:mm:ssZ', + 'iso': 'YYYY-MM-DDTHH:mm:ssZZ', 'display': 'YYYY-MM-DD HH:mm', - 'rcf': 'ddd, DD MMM YYYY HH:mm:ss Z', - 'twitter': 'ddd MMM DD HH:mm:ss Z YYYY' } loglevels = {