diff --git a/app.py b/app.py index c7993f5..e9a0bf5 100644 --- a/app.py +++ b/app.py @@ -474,7 +474,15 @@ def note_by_id(note_id): })) likes = [ACTOR_SERVICE.get(doc['activity']['actor']) for doc in likes] - return render_template('note.html', likes=likes, me=ME, thread=thread, note=data) + shares = list(DB.inbox.find({ + 'meta.undo': False, + 'type': ActivityType.ANNOUNCE.value, + '$or': [{'activity.object.id': data['activity']['object']['id']}, + {'activity.object': data['activity']['object']['id']}], + })) + shares = [ACTOR_SERVICE.get(doc['activity']['actor']) for doc in shares] + + return render_template('note.html', likes=likes, shares=shares, me=ME, thread=thread, note=data) @app.route('/nodeinfo') diff --git a/templates/note.html b/templates/note.html index 0ff83ed..8599778 100644 --- a/templates/note.html +++ b/templates/note.html @@ -16,6 +16,6 @@ {% block content %}
{% include "header.html" %} -{{ utils.display_thread(thread, likes) }} +{{ utils.display_thread(thread, likes=likes, shares=shares) }}
{% endblock %} diff --git a/templates/utils.html b/templates/utils.html index 07fb19e..2535e9c 100644 --- a/templates/utils.html +++ b/templates/utils.html @@ -32,7 +32,7 @@ {%- endmacro %} -{% macro display_note(item, perma=False, ui=False, likes=[]) -%} +{% macro display_note(item, perma=False, ui=False, likes=[], shares=[]) -%} {% set actor = item.activity.object.attributedTo | get_actor %}
@@ -76,12 +76,14 @@ {% endif %}
-{% if perma %}{{ item.activity.object.published | format_time }} {% endif %} +{% if perma %}{{ item.activity.object.published | format_time }} +{% else %} permalink {% if item.meta.count_reply %}{{ item.meta.count_reply }} replies{% endif %} {% if item.meta.count_boost %}{{ item.meta.count_boost }} boosts{% endif %} {% if item.meta.count_like %}{{ item.meta.count_like }} likes{% endif %} +{% endif %} {% if ui and session.logged_in %} @@ -124,23 +126,38 @@ {% endif %}
-
- +{% if likes or shares %} +
{% if likes %} -
-

Liked by

{% for like in likes %} +
+

{{ item.meta.count_like }} likes

{% for like in likes %} {{ display_actor_inline(like) }} {% endfor %}
{% endif %} +{% if shares %} +
+

{{ item.meta.count_boost }} boosts

{% for boost in shares %} +{{ display_actor_inline(boost) }} +{% endfor %} +
+{% endif %} +
+{% endif %} + + + +
+ + {%- endmacro %} -{% macro display_thread(thread, likes=[]) -%} +{% macro display_thread(thread, likes=[], shares=[]) -%} {% for reply in thread %} {% if reply._requested %} -{{ display_note(reply, perma=True, ui=False, likes=likes) }} +{{ display_note(reply, perma=True, ui=False, likes=likes, shares=shares) }} {% else %} {{ display_note(reply, perma=False, ui=True) }} {% endif %}