Files
StarPunk/templates/note.html
T
PhilandClaude Opus 5.5 4aaa7a8122 feat: W3C Webmention compliance (v2.7.0)
Sending: RFC 8288 Link header parsing, rel token matching and document
order for <link>/<a>, endpoint re-discovery on every send, re-send to
previous targets on update/delete/undelete, 410 Gone for deleted notes,
no redirect following on the POST, 429 retried.

Receiving: exact target match per media type, Accept header, final URL
for relative links, only published notes accepted, fragments ignored,
moderation kept on updates, transient errors keep valid mentions.

Security: every redirect hop SSRF-checked, all resolved addresses
checked, broader blocklist, total time and size limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 08:07:04 -07:00

198 lines
8.3 KiB
HTML

{% extends "base.html" %}
{% from "partials/media.html" import display_media %}
{% from "partials/reaction.html" import reaction %}
{% block title %}{% if note.content.strip().startswith('#') %}{{ note.title }}{% elif note.excerpt.strip() %}{{ note.excerpt|truncate(60) }}{% elif note.repost_of %}Repost{% elif note.like_of %}Like{% elif note.in_reply_to %}Reply{% else %}Photo{% endif %} · {{ config.SITE_NAME }}{% endblock %}
{% block content %}
<article class="h-entry">
{# Detect if note has explicit title (starts with # heading) - per Q22 #}
{% set has_explicit_title = note.content.strip().startswith('#') %}
{# p-name only if note has explicit title (per Q22) #}
{% if has_explicit_title %}
<h1 class="p-name">{{ note.title }}</h1>
{% endif %}
{# Reply context (v1.6.0 Phase 4) - displayed if this is a reply post #}
{% if note.in_reply_to %}
<div class="reply-context">
<span class="reply-label">In reply to:</span>
{# u-in-reply-to on the h-cite itself makes it the entry's property (Post Type Discovery) #}
<blockquote class="u-in-reply-to h-cite">
{% if reply_context and reply_context.fetch_status == 'fetched' %}
{% if reply_context.content_snippet %}
<p class="p-content">{{ reply_context.content_snippet }}</p>
{% endif %}
<cite>
<a class="u-url" href="{{ note.in_reply_to }}">
{% if reply_context.author_name %}{{ reply_context.author_name }}{% endif %}
{% if reply_context.site_name %} on {{ reply_context.site_name }}{% endif %}
{% if not reply_context.author_name and not reply_context.site_name %}{{ note.in_reply_to }}{% endif %}
</a>
</cite>
{% else %}
<cite>
<a class="u-url" href="{{ note.in_reply_to }}">{{ note.in_reply_to }}</a>
</cite>
{% endif %}
</blockquote>
</div>
{% endif %}
{{ reaction(note) }}
{# u-photo placement: Per draft spec, u-photo must be direct child of h-entry, #}
{# NOT inside e-content. Media is rendered ABOVE e-content to meet this requirement. #}
{{ display_media(note.media, note.excerpt|truncate(150)) }}
{# e-content: note content BELOW media (per ADR-057) #}
<div class="e-content">
{{ note.body_html|safe }}
</div>
<footer class="note-meta">
{# u-url and u-uid same for notes (per Q23) #}
<a class="u-url u-uid" href="{{ absolute_url_for('public.note', slug=note.slug) }}"><time class="dt-published" datetime="{{ note.created_at.isoformat() }}">{{ note.created_at.strftime('%B %-d, %Y · %-I:%M %p') }}</time></a>
{% if note.updated_at and note.updated_at != note.created_at %}
<span class="updated">Updated <time class="dt-updated" datetime="{{ note.updated_at.isoformat() }}">{{ note.updated_at.strftime('%b %-d, %Y') }}</time></span>
{% endif %}
{# rel="tag" per microformats2 p-category #}
{% if note.tags %}
<span class="note-tags">
{% for tag in note.tags %}<a class="p-category" rel="tag" href="{{ url_for('public.tag', tag=tag.name) }}">{{ tag.display_name }}</a>{% endfor %}
</span>
{% endif %}
{% set synced = (syndications or [])|selectattr('remote_url')|list %}
{% if synced %}
<span class="syndication">Also on {% for s in synced %}<a class="u-syndication" href="{{ s.remote_url }}" rel="syndication">{{ s.name }}</a>{% if not loop.last %}, {% endif %}{% endfor %}</span>
{% endif %}
{# Author h-card (nested within h-entry per Q20); hidden on a single-author site #}
{% if author %}
<span class="p-author h-card visually-hidden">
{% if author.photo %}<img class="u-photo" src="{{ author.photo }}" alt="">{% endif %}
<a class="p-name u-url" href="{{ author.url or author.me }}">{{ author.name or author.url or author.me }}</a>
{% if author.note %}<span class="p-note">{{ author.note }}</span>{% endif %}
</span>
{% endif %}
</footer>
<nav class="note-nav">
<a href="/">← All notes</a>
</nav>
{# Webmentions section (v1.6.0 Phase 5) - only shown if approved webmentions exist #}
{% if webmentions %}
<section class="webmentions">
<h2>Responses</h2>
{% if replies %}
<div class="webmention-group webmention-replies">
<h3>{{ replies|length }} {{ 'Reply' if replies|length == 1 else 'Replies' }}</h3>
{% for reply in replies %}
<article class="webmention webmention-reply h-cite">
<div class="webmention-author">
{% if reply.author_photo %}
<img src="{{ reply.author_photo }}" alt="" width="48" height="48" loading="lazy">
{% endif %}
<a class="p-author" href="{{ reply.author_url or reply.source_url }}">
{{ reply.author_name or 'Anonymous' }}
</a>
</div>
{% if reply.content_snippet %}
<div class="p-content">{{ reply.content_snippet|safe }}</div>
{% endif %}
<a class="u-url webmention-date" href="{{ reply.source_url }}">
<time class="dt-published" datetime="{{ reply.received_at.isoformat() }}">
{{ reply.received_at.strftime('%B %d, %Y') }}
</time>
</a>
</article>
{% endfor %}
</div>
{% endif %}
{% if likes %}
<div class="webmention-group webmention-likes">
<h3>{{ likes|length }} {{ 'Like' if likes|length == 1 else 'Likes' }}</h3>
<div class="facepile">
{% for wm in likes[:8] %}
<a href="{{ wm.author_url or wm.source_url }}" class="face" title="{{ wm.author_name or 'Anonymous' }}">
{% if wm.author_photo %}
<img src="{{ wm.author_photo }}" alt="{{ wm.author_name or '' }}" width="32" height="32" loading="lazy">
{% else %}
<span class="face-initial" style="background-color: {{ wm.author_url|url_to_color }}">
{{ (wm.author_name or '?')[0]|upper }}
</span>
{% endif %}
</a>
{% endfor %}
{% if likes|length > 8 %}
<span class="face-overflow">+{{ likes|length - 8 }} others</span>
{% endif %}
</div>
</div>
{% endif %}
{% if reposts %}
<div class="webmention-group webmention-reposts">
<h3>{{ reposts|length }} {{ 'Repost' if reposts|length == 1 else 'Reposts' }}</h3>
<div class="facepile">
{% for wm in reposts[:8] %}
<a href="{{ wm.author_url or wm.source_url }}" class="face" title="{{ wm.author_name or 'Anonymous' }}">
{% if wm.author_photo %}
<img src="{{ wm.author_photo }}" alt="{{ wm.author_name or '' }}" width="32" height="32" loading="lazy">
{% else %}
<span class="face-initial" style="background-color: {{ wm.author_url|url_to_color }}">
{{ (wm.author_name or '?')[0]|upper }}
</span>
{% endif %}
</a>
{% endfor %}
{% if reposts|length > 8 %}
<span class="face-overflow">+{{ reposts|length - 8 }} others</span>
{% endif %}
</div>
</div>
{% endif %}
{% if bookmarks %}
<div class="webmention-group webmention-bookmarks">
<h3>{{ bookmarks|length }} {{ 'Bookmark' if bookmarks|length == 1 else 'Bookmarks' }}</h3>
<div class="facepile">
{% for wm in bookmarks[:8] %}
<a href="{{ wm.author_url or wm.source_url }}" class="face" title="{{ wm.author_name or 'Anonymous' }}">
{% if wm.author_photo %}
<img src="{{ wm.author_photo }}" alt="{{ wm.author_name or '' }}" width="32" height="32" loading="lazy">
{% else %}
<span class="face-initial" style="background-color: {{ wm.author_url|url_to_color }}">
{{ (wm.author_name or '?')[0]|upper }}
</span>
{% endif %}
</a>
{% endfor %}
{% if bookmarks|length > 8 %}
<span class="face-overflow">+{{ bookmarks|length - 8 }} others</span>
{% endif %}
</div>
</div>
{% endif %}
{% if mentions %}
<div class="webmention-group webmention-mentions">
<h3>{{ mentions|length }} {{ 'Mention' if mentions|length == 1 else 'Mentions' }}</h3>
{% for mention in mentions %}
<div class="webmention webmention-mention">
<a href="{{ mention.source_url }}">{{ mention.author_name or mention.source_url }}</a>
{% if mention.content_snippet %}
<p>{{ mention.content_snippet|striptags|truncate(200) }}</p>
{% endif %}
</div>
{% endfor %}
</div>
{% endif %}
</section>
{% endif %}
</article>
{% endblock %}