From f4e277f1d16f66bf44462821222c078206e19d7c Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Thu, 23 Nov 2017 16:16:10 +0100 Subject: [PATCH] Homepage: Render attachments on posts --- cloud/routes.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cloud/routes.py b/cloud/routes.py index fa57a63..f23bdd9 100644 --- a/cloud/routes.py +++ b/cloud/routes.py @@ -45,7 +45,8 @@ def _homepage_context() -> dict: 'node_type': 1, 'picture': 1, 'properties.url': 1, - 'properties.content': 1 + 'properties.content': 1, + 'properties.attachments': 1 }, 'where': {'node_type': 'post', 'properties.status': 'published'}, @@ -59,6 +60,15 @@ def _homepage_context() -> dict: post.picture = get_file(post.picture, api=api) post.url = url_for_node(node=post) + # Render attachments + try: + post_contents = post['properties']['content'] + except KeyError: + log.warning('Blog post %s has no content', post._id) + else: + post['properties']['content'] = pillar.web.nodes.attachments.render_attachments( + post, post_contents) + # Get latest assets added to any project latest_assets = Node.latest('assets', api=api)