- Responses as u-comment/u-like/u-repost/u-bookmark/u-mention h-cites with author h-cards; source's own url and published (migration 014) - dt-* and Micropub published in RFC 3339 UTC - Title only for a real Markdown heading (hashtag notes stay notes) - Ignore webmentions from a note's own syndicated copies - Micropub/IndieAuth links independent of Webmention; rel=me/rel=author - Representative h-card and authorship algorithm (starpunk/mf2_utils.py) - Tag/likes h-feeds get url and author; previews get u-uid Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63 lines
3.0 KiB
HTML
63 lines
3.0 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 %}
|
|
|
|
{# 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 #}
|
|
{% macro author_card(wm, class='', photo_size=48, show_name=True) %}
|
|
<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.author_photo %}<img class="u-photo" src="{{ wm.author_photo }}" alt="" width="{{ photo_size }}" height="{{ photo_size }}" loading="lazy">
|
|
{%- 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>
|
|
</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 #}
|
|
{% 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>
|
|
</div>
|
|
{%- endmacro %}
|