feat: likes and reposts as a counts line with hover lists, web actions (v2.13.2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b247de011d
commit
44f77a3adf
11 files changed
+178
-104
No files matched your search
@@ -41,22 +41,6 @@
|
||||
</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">
|
||||
@@ -68,12 +52,62 @@
|
||||
</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>
|
||||
{# Likes, reposts, replies and bookmarks: one line of counts under the note,
|
||||
like other sites (v2.13.2). Hovering or focusing a count lists who, and
|
||||
offers the same action on the note's crossposts. Each action is an
|
||||
<indie-action> (https://indieweb.org/webactions) with those silo links as
|
||||
its fallback, so web action handlers can take over. Counts a silo gives
|
||||
without names (Threads) are added to the total. The people stay in the
|
||||
markup as u-like / u-repost / u-bookmark h-cites. #}
|
||||
{% set ICONS = {
|
||||
'like': '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>',
|
||||
'repost': '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M17 1l4 4-4 4"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><path d="M7 23l-4-4 4-4"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg>',
|
||||
'reply': '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M21 11.5a8.4 8.4 0 0 1-9 8.4 8.6 8.6 0 0 1-3.9-.9L3 21l1.9-5.1A8.4 8.4 0 0 1 12 3.1a8.4 8.4 0 0 1 9 8.4z"/></svg>',
|
||||
'bookmark': '<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><path d="M6 2h12a1 1 0 0 1 1 1v19l-7-4-7 4V3a1 1 0 0 1 1-1z"/></svg>',
|
||||
} %}
|
||||
{% set VERBS = {'like': 'Like', 'repost': 'Repost', 'reply': 'Reply'} %}
|
||||
|
||||
{% macro reaction(kind, items, prop, anon, one, many, copies=[], permalink='', people=True) %}
|
||||
{% set ns = namespace(total=items|length) %}
|
||||
{% for name, n in anon %}{% set ns.total = ns.total + n %}{% endfor %}
|
||||
{% set verb = VERBS.get(kind) %}
|
||||
{% if ns.total or (verb and copies) %}
|
||||
<span class="reaction reaction-{{ kind }}" tabindex="0">
|
||||
{{ ICONS[kind]|safe }}{% if ns.total %}<span class="reaction-count">{{ ns.total }}</span>{% endif %}<span class="visually-hidden"> {{ ns.total }} {{ one if ns.total == 1 else many }}</span>
|
||||
<span class="reaction-who" role="tooltip">
|
||||
{% if ns.total %}<span class="reaction-title">{{ ns.total }} {{ one if ns.total == 1 else many }}</span>{% endif %}
|
||||
{% if (people and items) or anon %}
|
||||
<span class="reaction-people">
|
||||
{% if people %}
|
||||
{% for wm in items %}
|
||||
<span class="reaction-person {{ prop }} h-cite">{{ author_card(wm, photo_size=20) }}{% if wm.via %}<span class="webmention-via">{{ wm.via }}</span>{% endif %}<a class="u-url" href="{{ response_url(wm) }}" hidden>{{ response_time(wm) }}</a></span>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% for name, n in anon %}<span class="reaction-anon">{{ '+' if items and people else '' }}{{ n }} on {{ name }}</span>{% endfor %}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if verb and copies %}
|
||||
<indie-action class="reaction-elsewhere" do="{{ kind }}" with="{{ permalink }}">{{ verb }} on {% for s in copies %}<a href="{{ s.remote_url }}" rel="noopener">{{ s.name }}</a>{% if not loop.last %} · {% endif %}{% endfor %}</indie-action>
|
||||
{% endif %}
|
||||
</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
{% macro reactions(likes, reposts, replies, bookmarks, syndications, permalink) %}
|
||||
{% set anon_likes, anon_reposts = [], [] %}
|
||||
{% for s in syndications or [] %}
|
||||
{% if s.likes_count %}{% set _ = anon_likes.append((s.name, s.likes_count)) %}{% endif %}
|
||||
{% if s.reposts_count %}{% set _ = anon_reposts.append((s.name, s.reposts_count)) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% set copies = (syndications or [])|selectattr('remote_url')|list %}
|
||||
{% if copies or likes or reposts or replies or bookmarks or anon_likes or anon_reposts %}
|
||||
<div class="reactions">
|
||||
{{ reaction('like', likes or [], 'u-like', anon_likes, 'like', 'likes', copies, permalink) }}
|
||||
{{ reaction('repost', reposts or [], 'u-repost', anon_reposts, 'repost', 'reposts', copies, permalink) }}
|
||||
{# Replies are listed in full below; here just the count and where to reply #}
|
||||
{{ reaction('reply', replies or [], '', [], 'reply', 'replies', copies, permalink, people=False) }}
|
||||
{{ reaction('bookmark', bookmarks or [], 'u-bookmark', [], 'bookmark', 'bookmarks') }}
|
||||
</div>
|
||||
{% endif %}
|
||||
{%- endmacro %}
|
||||
Reference in new issue
Block a user