From 3a141795e6860ea2f6febf9cbe4ee4f01ea6c795 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 1 Sep 2019 14:19:33 +0200 Subject: [PATCH] Fix template and improve threads --- core/shared.py | 4 +++- templates/utils.html | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/core/shared.py b/core/shared.py index e1ab120..41c5192 100644 --- a/core/shared.py +++ b/core/shared.py @@ -142,7 +142,9 @@ def _get_ip(): def _build_thread(data, include_children=True): # noqa: C901 data["_requested"] = True app.logger.info(f"_build_thread({data!r})") - root_id = data["meta"][MetaKey.OBJECT_ID.value] + root_id = data["meta"].get( + MetaKey.THREAD_ROOT_PARENT.value, data["meta"][MetaKey.OBJECT_ID.value] + ) replies = [data] for dat in find_activities( diff --git a/templates/utils.html b/templates/utils.html index 34b5eb0..ed49404 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -15,6 +15,17 @@ {% endif %} {%- endmacro %} +{% macro display_actor_oneline(follower) -%} +{% if follower and follower.id %} + + +{{ (follower.name or follower.preferredUsername) | clean | replace_custom_emojis(follower) | safe }} +@{{ follower.preferredUsername }}@{{ follower | url_or_id | get_url | domain }} + + +{% endif %} +{%- endmacro %} + {% macro display_note(obj, perma=False, ui=False, likes=[], shares=[], meta={}, no_color=False) -%} {% if meta.object_actor %} @@ -60,11 +71,22 @@ {% if not perma %} - + {% endif %} +{% if meta.in_reply_to_actor %} +
+in reply to {{ display_actor_oneline(meta.in_reply_to_actor) }} +
+{% elif meta.in_reply_to_self %} +
+self reply +
+{% endif %} + + {% if obj.summary %}

{{ obj.summary | clean | replace_custom_emojis(obj) | safe }}

{% endif %} {% if obj | has_type('Video') %}
@@ -321,7 +343,9 @@ {% endif %} {% if meta.object_visibility | visibility_is_public %} -{% if obj | url_or_id | is_from_outbox %} +{% if obj.inReplyTo and not meta.count_reply and not perma %} +thread{% endif %} +{% if obj | url_or_id | get_url | is_from_outbox %} permalink {% else %} source