From 4da7a84c86d4cc9ed71c1a993e1ccf49ffa38ae8 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Thu, 18 Jan 2018 16:02:29 +0100 Subject: [PATCH] Fix for broken urls in blog list This actually undoes commits 90c62664a6713a9330a4fe44f2cfe58124b29ed3 and 18fe240b931ab8dbd3a8a9fb6760c8b8cdba7ad3 and simply adds the node.url property when rendering a post in the posts_view function. This is what the template macro actually expected in the first place. --- pillar/web/nodes/custom/posts.py | 3 ++- src/templates/nodes/custom/blog/_macros.pug | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pillar/web/nodes/custom/posts.py b/pillar/web/nodes/custom/posts.py index f0b3834c..79ea81fd 100644 --- a/pillar/web/nodes/custom/posts.py +++ b/pillar/web/nodes/custom/posts.py @@ -35,7 +35,6 @@ def posts_view(project_id=None, project_url=None, url=None, *, archive=False, pa api = system_util.pillar_api() - # Fetch project (for backgroud images and links generation) # Fetch project (for background images and links generation) if project_id: project = Project.find(project_id, api=api) @@ -78,6 +77,8 @@ def posts_view(project_id=None, project_url=None, url=None, *, archive=False, pa if post.picture: post.picture = get_file(post.picture, api=api) + + post.url = url_for_node(node=post) elif posts._items: post = posts._items[0] else: diff --git a/src/templates/nodes/custom/blog/_macros.pug b/src/templates/nodes/custom/blog/_macros.pug index e2f83fea..e583186d 100644 --- a/src/templates/nodes/custom/blog/_macros.pug +++ b/src/templates/nodes/custom/blog/_macros.pug @@ -1,7 +1,7 @@ //- ******************************************************* -// | {% macro render_blog_post(node) %} | {% if node.picture %} -a.blog_index-header(href="{{ node.properties.url }}") +a.blog_index-header(href="{{ node.url }}") img(src="{{ node.picture.thumbnail('l', api=api) }}") | {% endif %} @@ -12,16 +12,16 @@ a.blog_index-header(href="{{ node.properties.url }}") | {% endif %} li.when - a(href="{{ node.properties.url }}", + a(href="{{ node.url }}", title="Updated {{ node._updated | pretty_date }}") | {{ node._created | pretty_date }} li - a(href="{{ node.properties.url }}#comments") + a(href="{{ node.url }}#comments") | comment a.item-title( - href="{{ node.properties.url }}") + href="{{ node.url }}") | {{ node.name }} .item-content