feat: reply contexts that show the post (v2.19.0)
Replies to Mastodon posts showed only the server's domain: the page has no h-entry, so nothing was found and the host stood in for the author. - Context sources in order: Bluesky AppView API, microformats, the origin's Mastodon API or this site's GoToSocial instance, OpenGraph - Migration 024: author_handle, photo, photo_alt, source; rows without a source are fetched again once by the webmention worker - Note page: a card with avatar, name, handle, text, image and date; home/tag/likes: "In reply to <author>" with a short quote - Avatars and images saved locally (CSP allows only this site's images); avatar upkeep now covers reply contexts so their avatars aren't removed Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
22e588377f
commit
62e257e0e0
14 files changed
+1094
-309
No files matched your search
@@ -1,6 +1,7 @@
|
||||
{# One note in a list (home, tag pages). v2.3.0 #}
|
||||
{% from "partials/media.html" import display_media %}
|
||||
{% from "partials/reaction.html" import reaction %}
|
||||
{% from "partials/reply_context.html" import reply_line %}
|
||||
{% from "partials/responses.html" import list_counts %}
|
||||
{% macro note_preview(note, author) %}
|
||||
<article class="h-entry note-preview">
|
||||
@@ -10,7 +11,7 @@
|
||||
{% endif %}
|
||||
|
||||
{% if note.in_reply_to %}
|
||||
<p class="reaction reply-to"><span class="reaction-verb">↩ In reply to</span> <a class="u-in-reply-to" href="{{ note.in_reply_to }}">{{ note.in_reply_to }}</a></p>
|
||||
{{ reply_line(note.in_reply_to, note.context if note.context is defined else None) }}
|
||||
{% endif %}
|
||||
|
||||
{{ reaction(note) }}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
{# 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 %}
|
||||
{% if 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 %}
|
||||
Reference in new issue
Block a user