diff --git a/devplacepy/templates/_comment.html b/devplacepy/templates/_comment.html index 7cb3810d..f611b1a6 100644 --- a/devplacepy/templates/_comment.html +++ b/devplacepy/templates/_comment.html @@ -1,4 +1,4 @@ -{% macro comment_cell(item, depth, parent_author=None) %} +{% macro comment_cell(item, depth, parent_author=None, parent_url=None) %}
@@ -26,6 +26,7 @@ {% endif %}
+ {% if owns(item.comment, user) %} @@ -39,21 +40,21 @@
{% endmacro %} -{% macro render_comment(item, depth=0) %} +{% macro render_comment(item, depth=0, parent_url=None) %} {% set max_depth = 2 %} {% set visual_depth = depth if depth < max_depth else max_depth %} -{% call comment_cell(item, visual_depth) %} +{% call comment_cell(item, visual_depth, parent_url=parent_url) %} {% if item.children %} {% if depth < max_depth %}
{% for child in item.children %} - {{ render_comment(child, depth + 1) }} + {{ render_comment(child, depth + 1, parent_url) }} {% endfor %}
{% else %}
{% for child in item.children %} - {{ render_comment_flat(child, max_depth, item.author) }} + {{ render_comment_flat(child, max_depth, item.author, parent_url) }} {% endfor %}
{% endif %} @@ -61,9 +62,9 @@ {% endcall %} {% endmacro %} -{% macro render_comment_flat(item, depth, parent_author) %} -{% call comment_cell(item, depth, parent_author) %}{% endcall %} +{% macro render_comment_flat(item, depth, parent_author, parent_url=None) %} +{% call comment_cell(item, depth, parent_author, parent_url=parent_url) %}{% endcall %} {% for child in item.children %} -{{ render_comment_flat(child, depth, item.author) }} +{{ render_comment_flat(child, depth, item.author, parent_url) }} {% endfor %} {% endmacro %} diff --git a/devplacepy/templates/_comment_section.html b/devplacepy/templates/_comment_section.html index 5f2d5538..e9041504 100644 --- a/devplacepy/templates/_comment_section.html +++ b/devplacepy/templates/_comment_section.html @@ -3,8 +3,10 @@ {% from "_comment.html" import render_comment with context %} + {% set parent_url = resolve_object_url(target_type, target_uid) %} + {% for item in comments %} - {{ render_comment(item, 0) }} + {{ render_comment(item, 0, parent_url) }} {% else %}

No comments yet. Start the discussion.

{% endfor %} diff --git a/devplacepy/templating.py b/devplacepy/templating.py index 4e328b68..13ac1e23 100644 --- a/devplacepy/templating.py +++ b/devplacepy/templating.py @@ -9,6 +9,7 @@ from devplacepy.cache import TTLCache from devplacepy.config import STATIC_VERSION, TEMPLATES_DIR, TEMPLATE_AUTO_RELOAD, PRESENCE_TIMEOUT_SECONDS from devplacepy.constants import TOPICS, REACTION_EMOJI from devplacepy.database import get_int_setting, get_setting, get_table +from devplacepy.database.content import resolve_object_url from devplacepy.avatar import avatar_url, avatar_seed from devplacepy.utils import format_date as _format_date from devplacepy.utils import time_ago as _time_ago @@ -49,6 +50,7 @@ templates.env.globals["is_self"] = is_self templates.env.globals["guest_disabled"] = guest_disabled templates.env.globals["is_online"] = presence.is_online templates.env.globals["presence_timeout"] = PRESENCE_TIMEOUT_SECONDS +templates.env.globals["resolve_object_url"] = resolve_object_url from devplacepy.docs_devrant import devrant_endpoints