Likes, reposts, quotes and replies to a note's GoToSocial, Bluesky and Threads copies are read back from the silos and stored as webmentions (ADR-073): age-based schedule to 90 days, pruning of withdrawn responses, #nobridge/#nobot opt-outs, admin backfill and Check now, Threads counts, a Quotes group, local avatar copies, and delete tombstones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
4.3 KiB
HTML
80 lines
4.3 KiB
HTML
{# Received webmentions as microformats2 responses (v2.8.0)
|
|
Each response is an h-cite in a property of the note's h-entry:
|
|
u-comment (replies), u-like, u-repost, u-bookmark, u-mention.
|
|
See https://indieweb.org/comments-presentation and microformats.org/wiki/h-entry #}
|
|
|
|
{# When the source said when it was posted, use that; else when we received it #}
|
|
{% macro response_time(wm, fmt='%B %-d, %Y') %}
|
|
{% set when = wm.source_published or wm.received_at %}
|
|
<time class="dt-published" datetime="{{ when|iso_utc }}">{{ when.strftime(fmt) if when.strftime is defined else when }}</time>
|
|
{%- endmacro %}
|
|
|
|
{# The response's own URL: the source's u-url if it gave one #}
|
|
{% macro response_url(wm) %}{{ wm.source_post_url or wm.source_url }}{% endmacro %}
|
|
|
|
{# Where a backfed response came from, e.g. "via Bluesky" (v2.13.0) #}
|
|
{% macro via(wm) %}{% if wm.via %}<span class="webmention-via">via {{ wm.via }}</span>{% endif %}{% endmacro %}
|
|
|
|
{# Author h-card: name, URL and photo. u-url is on an inner link: on the
|
|
h-card element itself it would belong to the enclosing h-cite.
|
|
The photo is this site's saved copy (v2.13.0); until there is one, the
|
|
initial is shown instead of loading it from the other site. #}
|
|
{% macro author_card(wm, class='', photo_size=48, show_name=True) %}
|
|
{% set photo = wm.author_photo|local_avatar %}
|
|
<span class="p-author h-card {{ class }}"><a class="u-url" href="{{ wm.author_url or wm.source_url }}" title="{{ wm.author_name or 'Anonymous' }}{% if wm.via %} via {{ wm.via }}{% endif %}">
|
|
{%- if photo %}<img class="u-photo" src="{{ photo }}" alt="" width="{{ photo_size }}" height="{{ photo_size }}" loading="lazy">
|
|
{%- elif wm.author_photo %}<data class="u-photo" value="{{ wm.author_photo }}"></data>{% if not show_name %}<span class="face-initial" style="background-color: {{ wm.author_url|url_to_color }}" aria-hidden="true">{{ (wm.author_name or '?')[0]|upper }}</span>{% endif %}
|
|
{%- elif not show_name %}<span class="face-initial" style="background-color: {{ wm.author_url|url_to_color }}" aria-hidden="true">{{ (wm.author_name or '?')[0]|upper }}</span>
|
|
{%- endif %}
|
|
<span class="p-name{{ '' if show_name else ' visually-hidden' }}">{{ wm.author_name or 'Anonymous' }}</span>
|
|
</a></span>
|
|
{%- endmacro %}
|
|
|
|
{# A reply, shown as a comment #}
|
|
{% macro reply(wm) %}
|
|
<article class="webmention webmention-reply u-comment h-cite">
|
|
<div class="webmention-author">{{ author_card(wm) }}</div>
|
|
{% if wm.content_snippet %}
|
|
<div class="e-content">{{ wm.content_snippet|safe }}</div>
|
|
{% endif %}
|
|
<a class="u-url webmention-date" href="{{ response_url(wm) }}">{{ response_time(wm) }}</a> {{ via(wm) }}
|
|
</article>
|
|
{%- endmacro %}
|
|
|
|
{# Likes, reposts or bookmarks as a facepile; prop is u-like / u-repost / u-bookmark.
|
|
Faces past `shown` are hidden on screen but kept for parsers. #}
|
|
{% macro facepile(items, prop, shown=8) %}
|
|
<div class="facepile">
|
|
{% for wm in items %}
|
|
<span class="face {{ prop }} h-cite"{% if loop.index > shown %} hidden{% endif %}>
|
|
{{ author_card(wm, photo_size=32, show_name=False) }}
|
|
<a class="u-url" href="{{ response_url(wm) }}" hidden>{{ response_time(wm) }}</a>
|
|
</span>
|
|
{% endfor %}
|
|
{% if items|length > shown %}
|
|
<span class="face-overflow">+{{ items|length - shown }} others</span>
|
|
{% endif %}
|
|
</div>
|
|
{%- endmacro %}
|
|
|
|
{# A post that mentions this note without replying; also quote posts (v2.13.0) #}
|
|
{% macro mention(wm) %}
|
|
<div class="webmention webmention-mention u-mention h-cite">
|
|
{{ author_card(wm, photo_size=24) }}
|
|
{% if wm.content_snippet %}
|
|
<p class="p-content">{{ wm.content_snippet|striptags|truncate(200) }}</p>
|
|
{% endif %}
|
|
<a class="u-url webmention-date" href="{{ response_url(wm) }}">{{ response_time(wm) }}</a> {{ via(wm) }}
|
|
</div>
|
|
{%- endmacro %}
|
|
|
|
{# Like, repost and quote counts a silo reports without saying who (Threads,
|
|
v2.13.0). Plain text: these aren't people, so no u-like / h-cite. #}
|
|
{% macro silo_counts(syndications) %}
|
|
{% for s in syndications or [] if s.likes_count or s.reposts_count or s.quotes_count %}
|
|
{% set parts = [] %}
|
|
{% for n, one, many in [(s.likes_count, 'like', 'likes'), (s.reposts_count, 'repost', 'reposts'), (s.quotes_count, 'quote', 'quotes')] if n %}{% set _ = parts.append(n ~ ' ' ~ (one if n == 1 else many)) %}{% endfor %}
|
|
<p class="silo-counts">On {{ s.name }}: {{ parts|join(' · ') }}</p>
|
|
{% endfor %}
|
|
{%- endmacro %}
|