Files
StarPunk/templates/partials/reply_context.html
T
PhilandClaude Opus 5.5 952ca300c0 fix: keep GIFs moving in reply contexts (v2.20.1)
Mastodon turns GIFs into silent looping MP4s (gifv); only the first-frame
preview was kept. The MP4 is now saved locally and played muted and
looping with the still as poster. Animated GIFs from other sites are saved
as animated WebP. Migration 025 adds reply_contexts.video and has
fediverse contexts with an image fetched again once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 20:28:20 -07:00

67 lines
3.6 KiB
HTML

{# The post a reply answers (v2.19.0).
The card is the note's u-in-reply-to h-cite (Post Type Discovery reads it
as a reply). Avatars and images are this site's saved copies; until there
is one, the initial is shown and the image left out. #}
{% macro _who(ctx, url) %}{{ ctx.author_name or ctx.site_name or url.split('/')[2] }}{% endmacro %}
{% macro _when(ctx, fmt) %}
{%- set when = ctx.published_at -%}
{%- if when and when.strftime is defined -%}
<time class="dt-published" datetime="{{ when|iso_utc }}">{{ when.strftime(fmt) }}</time>
{%- endif -%}
{% endmacro %}
{# Full card, on the note's page #}
{% macro reply_card(url, ctx) %}
{% set fetched = ctx and ctx.fetch_status == 'fetched' %}
<div class="reply-context">
<span class="reply-label">↩ In reply to</span>
<blockquote class="u-in-reply-to h-cite reply-card">
{% if fetched and (ctx.author_name or ctx.content_snippet or ctx.title) %}
<header class="reply-author">
{% set avatar = ctx.author_photo|local_avatar %}
<span class="p-author h-card">
{%- if avatar %}<img class="u-photo" src="{{ avatar }}" alt="" width="40" height="40" loading="lazy">
{%- else %}<span class="face-initial" style="background-color: {{ (ctx.author_url or url)|url_to_color }}" aria-hidden="true">{{ _who(ctx, url)[0]|upper }}</span>{% endif %}
<span class="reply-who">
{%- if ctx.author_url %}<a class="p-name u-url" href="{{ ctx.author_url }}">{{ _who(ctx, url) }}</a>
{%- else %}<span class="p-name">{{ _who(ctx, url) }}</span>{% endif %}
{%- if ctx.author_handle %} <span class="reply-handle">{{ ctx.author_handle }}</span>{% endif -%}
</span>
</span>
</header>
{% if ctx.title %}<p class="p-name reply-title">{{ ctx.title }}</p>{% endif %}
{% if ctx.content_snippet %}<div class="e-content reply-content">{{ ctx.content_snippet|safe }}</div>{% endif %}
{% set image = ctx.photo|local_preview %}
{% set video = ctx.video|local_video if ctx.video is defined else None %}
{% if video %}
{# Mastodon "GIFs" are silent looping MP4s: shown as Mastodon shows them (v2.20.1) #}
<video class="reply-photo" src="{{ video }}"{% if image %} poster="{{ image }}"{% endif %} autoplay loop muted playsinline{% if ctx.photo_alt %} aria-label="{{ ctx.photo_alt }}" title="{{ ctx.photo_alt }}"{% endif %}></video>
{% elif image %}<img class="reply-photo" src="{{ image }}" alt="{{ ctx.photo_alt or '' }}" loading="lazy">{% endif %}
<footer class="reply-source">
<a class="u-url" href="{{ url }}">{{ _when(ctx, '%B %-d, %Y · %-I:%M %p') }}{% if ctx.published_at and ctx.published_at.strftime is defined %} · {% endif %}{{ ctx.site_name or url.split('/')[2] }} ↗</a>
</footer>
{% else %}
<cite><a class="u-url" href="{{ url }}">{{ url }}</a></cite>
{% endif %}
</blockquote>
</div>
{% endmacro %}
{# One line and a short quote, in lists of notes #}
{% macro reply_line(url, ctx) %}
{% set fetched = ctx and ctx.fetch_status == 'fetched' %}
<div class="reaction reply-to">
<span class="reaction-verb">↩ In reply to</span>
{% if fetched and (ctx.author_name or ctx.title) %}
<a class="u-in-reply-to" href="{{ url }}">{{ ctx.title or ctx.author_name }}</a>
{%- if ctx.title and ctx.author_name %} <span class="reaction-by">by {{ ctx.author_name }}</span>{% endif %}
{% set quote = ctx.content_snippet|striptags|replace('\n', ' ')|trim if ctx.content_snippet else '' %}
{% if quote and not ctx.title %}<q class="reply-quote">{{ quote|truncate(140) }}</q>{% endif %}
{% else %}
<a class="u-in-reply-to" href="{{ url }}">{{ url }}</a>
{% endif %}
</div>
{% endmacro %}