Merge branch 'fix/v2.13.4-list-counts' for v2.13.4 release
Build Container / build (push) Successful in 8m56s

This commit is contained in:
Phil committed 2026-11-10 14:05:05 -07:00
commit d312fa0074
12 files changed
+181 -37

No files matched your search

+14
View File
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [2.13.4] - 2026-11-10
### Added
- The home page, tag pages and the Likes page show each note's like, repost and reply counts next to its date (♥ 3 🔁 1 💬 2), linking to the note's responses. Notes with none show nothing
### Changed
- Clicking anywhere on a reply opens it where it was posted (the reply on Bluesky, GoToSocial or Threads, or the page that sent the webmention). The author link and links in the reply still go to their own pages
### Fixed
- The "Liked", "Reposted" and "In reply to" lines on notes picked up styles meant for v2.13.2's counts line (both used the class `reaction`). The counts line's classes are now `response-*`
## [2.13.3] - 2026-11-10
### Changed
+5 -1
View File
@@ -21,7 +21,7 @@ is in `../architecture/`; decisions are in `../decisions/` (ADRs).
## Contents
[v1.0.0](#v100) · [v1.1.1](#v111) · [v1.1.2](#v112) · [v1.2.0](#v120) · [v1.3.0](#v130) · [v1.3.1](#v131) · [v1.4.0](#v140) · [v1.4.1](#v141) · [v1.4.2](#v142) · [v1.5.0](#v150) · [v1.6.0](#v160) · [v2.0.0](#v200) · [v2.0.1](#v201) · [v2.0.2](#v202) · [v2.1.0](#v210) · [v2.2.0](#v220) · [v2.3.0](#v230) · [v2.3.1](#v231) · [v2.3.2](#v232) · [v2.3.3](#v233) · [v2.4.0](#v240) · [v2.5.0](#v250) · [v2.6.0](#v260) · [v2.6.1](#v261) · [v2.6.2](#v262) · [v2.6.3](#v263) · [v2.6.4](#v264) · [v2.6.5](#v265) · [v2.6.6](#v266) · [v2.6.7](#v267) · [v2.6.8](#v268) · [v2.6.9](#v269) · [v2.7.0](#v270) · [v2.7.1](#v271) · [v2.7.2](#v272) · [v2.8.0](#v280) · [v2.8.1](#v281) · [v2.9.0](#v290) · [v2.10.0](#v2100) · [v2.10.1](#v2101) · [v2.10.2](#v2102) · [v2.11.0](#v2110) · [v2.12.0](#v2120) · [v2.12.1](#v2121) · [v2.13.0](#v2130) · [v2.13.1](#v2131) · [v2.13.2](#v2132) · [v2.13.3](#v2133) · [hotfix](#hotfix)
[v1.0.0](#v100) · [v1.1.1](#v111) · [v1.1.2](#v112) · [v1.2.0](#v120) · [v1.3.0](#v130) · [v1.3.1](#v131) · [v1.4.0](#v140) · [v1.4.1](#v141) · [v1.4.2](#v142) · [v1.5.0](#v150) · [v1.6.0](#v160) · [v2.0.0](#v200) · [v2.0.1](#v201) · [v2.0.2](#v202) · [v2.1.0](#v210) · [v2.2.0](#v220) · [v2.3.0](#v230) · [v2.3.1](#v231) · [v2.3.2](#v232) · [v2.3.3](#v233) · [v2.4.0](#v240) · [v2.5.0](#v250) · [v2.6.0](#v260) · [v2.6.1](#v261) · [v2.6.2](#v262) · [v2.6.3](#v263) · [v2.6.4](#v264) · [v2.6.5](#v265) · [v2.6.6](#v266) · [v2.6.7](#v267) · [v2.6.8](#v268) · [v2.6.9](#v269) · [v2.7.0](#v270) · [v2.7.1](#v271) · [v2.7.2](#v272) · [v2.8.0](#v280) · [v2.8.1](#v281) · [v2.9.0](#v290) · [v2.10.0](#v2100) · [v2.10.1](#v2101) · [v2.10.2](#v2102) · [v2.11.0](#v2110) · [v2.12.0](#v2120) · [v2.12.1](#v2121) · [v2.13.0](#v2130) · [v2.13.1](#v2131) · [v2.13.2](#v2132) · [v2.13.3](#v2133) · [v2.13.4](#v2134) · [hotfix](#hotfix)
## v1.0.0
@@ -438,6 +438,10 @@ OIDC admin login and built-in IndieAuth server.
- [2026-11-10-count-opted-out.md](v2.13.3/2026-11-10-count-opted-out.md) - Opted-out people's likes and reposts counted without names
## v2.13.4
- [2026-11-10-list-counts.md](v2.13.4/2026-11-10-list-counts.md) - Counts on lists of notes; whole reply card links to the reply; class clash fixed
## hotfix
Not a release folder.
@@ -0,0 +1,24 @@
# v2.13.4: Counts on lists of notes, reply cards as links
## What changed
- `webmention_queries.response_counts(note_ids)`: likes, reposts and
replies per note in two grouped queries (shown webmentions, plus the
anonymous counts on synced `syndications` rows). `routes/public.py`
`attach_response_counts()` runs after `attach_contexts()` on the home,
tag and Likes pages.
- `partials/responses.html` `list_counts`: icons and numbers in the note's
meta line, linking to `<permalink>#responses` (an anchor on the note page).
- Reply cards: the date link (already the reply's own URL) stretches over
the card with `::after`; author and content links sit above it.
- v2.13.2's `.reaction*` classes clashed with the older `.reaction` lines
(Liked / Reposted / In reply to, `partials/reaction.html`): the counts
line now uses `.response-count*` / `.response-card*` / `.response-*`.
## Verification
- `tests/test_backfeed.py::test_home_page_shows_counts`; template, route,
microformats and likes/reposts tests pass.
- Rendered the home page, a note page and the Likes page in headless
Chromium: counts beside the date, quiet notes unchanged, the Liked line
laid out as before v2.13.2.
+1 -1
View File
@@ -4,7 +4,7 @@
**Last Updated**: 2026-11-03 (v2.10.1)
StarPunk uses [Semantic Versioning 2.0.0](https://semver.org/):
`MAJOR.MINOR.PATCH`, currently **2.13.3**. Every release is a git tag
`MAJOR.MINOR.PATCH`, currently **2.13.4**. Every release is a git tag
`vX.Y.Z` and a `CHANGELOG.md` entry. Where the number is stored and how to
write the changelog entry is in
[version-implementation-guide.md](version-implementation-guide.md); the
+2 -2
View File
@@ -465,5 +465,5 @@ def create_app(config=None):
# Package version (Semantic Versioning 2.0.0)
# See docs/standards/versioning-strategy.md for details
__version__ = "2.13.3"
__version_info__ = (2, 13, 3)
__version__ = "2.13.4"
__version_info__ = (2, 13, 4)
+16
View File
@@ -292,9 +292,23 @@ def index():
object.__setattr__(note, '_cached_tags', tags)
attach_contexts(notes)
attach_response_counts(notes)
return render_template("index.html", notes=notes)
def attach_response_counts(notes) -> None:
"""Give listed notes their like, repost and reply counts (v2.13.4)"""
counts = {}
if current_app.config.get('WEBMENTION_ENABLED', False) and notes:
try:
from starpunk.webmention_queries import response_counts
counts = response_counts([n.id for n in notes])
except Exception as e:
current_app.logger.warning(f"Could not count responses: {e}")
for note in notes:
object.__setattr__(note, 'response_counts', counts.get(note.id))
def attach_contexts(notes) -> None:
"""Give likes and reposts the fetched context of the post they point at"""
from starpunk.webmention_queries import get_reply_context
@@ -320,6 +334,7 @@ def likes():
object.__setattr__(note, 'media', get_note_media(note.id))
object.__setattr__(note, '_cached_tags', get_note_tags(note.id))
attach_contexts(notes)
attach_response_counts(notes)
return render_template("likes.html", notes=notes)
@@ -467,6 +482,7 @@ def tag(tag: str):
media = get_note_media(note.id)
object.__setattr__(note, 'media', media)
attach_contexts(notes)
attach_response_counts(notes)
return render_template(
"tag.html",
+41
View File
@@ -110,6 +110,47 @@ def get_webmentions_for_note(note_id: int) -> Dict[str, List[Dict[str, Any]]]:
return grouped
def response_counts(note_ids: List[int]) -> Dict[int, Dict[str, int]]:
"""
Likes, reposts and replies per note, for lists of notes (v2.13.4).
Shown responses (valid and approved) plus the counts silos give without
names (Threads; people who opted out of backfeed) on synced crossposts.
Notes with none are left out.
"""
if not note_ids:
return {}
db = get_db()
marks = ','.join('?' * len(note_ids))
counts: Dict[int, Dict[str, int]] = {}
def add(note_id, key, n):
if n:
counts.setdefault(note_id, {'likes': 0, 'reposts': 0, 'replies': 0})[key] += n
for row in db.execute(
f"""
SELECT target_note_id, mention_type, COUNT(*) FROM webmentions
WHERE target_note_id IN ({marks}) AND validation_status = 'valid'
AND moderation_status = 'approved' AND mention_type IN ('like', 'repost', 'reply')
GROUP BY target_note_id, mention_type
""",
note_ids,
):
add(row[0], {'like': 'likes', 'repost': 'reposts', 'reply': 'replies'}[row[1]], row[2])
for row in db.execute(
f"""
SELECT note_id, SUM(COALESCE(likes_count, 0)), SUM(COALESCE(reposts_count, 0))
FROM syndications WHERE note_id IN ({marks}) AND state = 'synced'
GROUP BY note_id
""",
note_ids,
):
add(row[0], 'likes', row[1])
add(row[0], 'reposts', row[2])
return counts
def list_webmentions(
status_filter: Optional[str] = None,
page: int = 1,
+33 -20
View File
@@ -350,31 +350,44 @@ small { display: block; margin-top: var(--spacing-xs); color: var(--color-text-l
}
/* Likes, reposts and bookmarks: counts with a hover list (v2.13.2) */
.reactions { display: flex; flex-wrap: wrap; gap: var(--spacing-md); margin-top: var(--spacing-sm); color: var(--color-text-light); font-size: 0.875rem; }
.reaction { position: relative; display: inline-flex; align-items: center; gap: 0.3rem; padding-bottom: 0.4rem; cursor: default; }
.reaction > svg { width: 1rem; height: 1rem; flex: none; }
.reaction:hover, .reaction:focus-within { color: var(--color-text); }
.reaction-like:hover > svg, .reaction-like:focus-within > svg { color: #e0245e; }
.reaction-repost:hover > svg, .reaction-repost:focus-within > svg { color: #17bf63; }
.reaction-who {
.response-counts { display: flex; flex-wrap: wrap; gap: var(--spacing-md); margin-top: var(--spacing-sm); color: var(--color-text-light); font-size: 0.875rem; }
.response-count { position: relative; display: inline-flex; align-items: center; gap: 0.3rem; padding-bottom: 0.4rem; cursor: default; }
.response-count > svg { width: 1rem; height: 1rem; flex: none; }
.response-count:hover, .response-count:focus-within { color: var(--color-text); }
.response-count-like:hover > svg, .response-count-like:focus-within > svg { color: #e0245e; }
.response-count-repost:hover > svg, .response-count-repost:focus-within > svg { color: #17bf63; }
.response-card {
display: none; position: absolute; left: 0; top: 100%; z-index: 10;
flex-direction: column; gap: 0.4rem; min-width: 13rem; max-width: 20rem;
padding: var(--spacing-sm); background: var(--color-bg-alt); border: 1px solid var(--color-border);
border-radius: var(--border-radius); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}
.reaction:hover .reaction-who, .reaction:focus-within .reaction-who { display: flex; }
.reaction-title { font-weight: 600; color: var(--color-text); }
.reaction-people { display: flex; flex-direction: column; gap: 0.35rem; max-height: 14rem; overflow-y: auto; }
.reaction-person { display: flex; align-items: center; gap: 0.4rem; min-width: 0; line-height: 1.3; }
.reaction-person .h-card { display: flex; min-width: 0; }
.reaction-person .h-card a { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--color-text); min-width: 0; }
.reaction-person .p-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reaction-person img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: none; }
.reaction-person .webmention-via { margin-left: auto; padding-left: 0.5rem; white-space: nowrap; }
.reaction-anon { color: var(--color-text-light); }
.reaction-elsewhere { display: block; margin-top: 0.15rem; padding-top: 0.4rem; border-top: 1px solid var(--color-border); color: var(--color-text-light); }
.reaction-elsewhere:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.reaction-elsewhere a { color: var(--color-link); }
.response-count:hover .response-card, .response-count:focus-within .response-card { display: flex; }
.response-card-title { font-weight: 600; color: var(--color-text); }
.response-people { display: flex; flex-direction: column; gap: 0.35rem; max-height: 14rem; overflow-y: auto; }
.response-person { display: flex; align-items: center; gap: 0.4rem; min-width: 0; line-height: 1.3; }
.response-person .h-card { display: flex; min-width: 0; }
.response-person .h-card a { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--color-text); min-width: 0; }
.response-person .p-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.response-person img { width: 20px; height: 20px; border-radius: 50%; object-fit: cover; flex: none; }
.response-person .webmention-via { margin-left: auto; padding-left: 0.5rem; white-space: nowrap; }
.response-anon { color: var(--color-text-light); }
.response-elsewhere { display: block; margin-top: 0.15rem; padding-top: 0.4rem; border-top: 1px solid var(--color-border); color: var(--color-text-light); }
.response-elsewhere:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.response-elsewhere a { color: var(--color-link); }
/* A reply card opens the reply where it was posted (v2.13.4): its date link
stretches over the card; the author link and links in the text stay on top */
.webmention-reply { position: relative; }
.webmention-reply .webmention-date::after { content: ""; position: absolute; inset: 0; }
.webmention-reply .webmention-author a, .webmention-reply .e-content a { position: relative; z-index: 1; }
.webmention-reply:hover { cursor: pointer; }
/* Counts in lists of notes (v2.13.4) */
.list-counts { display: inline-flex; gap: 0.6rem; color: var(--color-text-light); }
.note-meta a.list-counts:hover { color: var(--color-text); text-decoration: none; }
.list-count { display: inline-flex; align-items: center; gap: 0.2rem; }
.list-count > svg { width: 0.85rem; height: 0.85rem; flex: none; }
/* Generic Mentions */
.webmention-mention {
+1
View File
@@ -78,6 +78,7 @@
{% endif %}
</footer>
<div id="responses"></div>
{{ responses.reactions(likes, reposts, replies, bookmarks, syndications, absolute_url_for('public.note', slug=note.slug)) }}
<nav class="note-nav">
+2
View File
@@ -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/responses.html" import list_counts %}
{% macro note_preview(note, author) %}
<article class="h-entry note-preview">
{# Notes starting with a '# Heading' have a title (Q22; Note.has_title) #}
@@ -37,6 +38,7 @@
{% 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 %}
{{ list_counts(note.response_counts if note.response_counts is defined else None, absolute_url_for('public.note', slug=note.slug)) }}
{% if author %}
{# Single-author site: keep the h-card for parsers, hide it from readers #}
<span class="p-author h-card visually-hidden"><a class="p-name u-url" href="{{ author.url or author.me }}">{{ author.name or author.url or author.me }}</a></span>
+21 -9
View File
@@ -73,22 +73,22 @@
{% 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 %}
<span class="response-count response-count-{{ kind }}" tabindex="0">
{{ ICONS[kind]|safe }}{% if ns.total %}<span class="response-count-n">{{ ns.total }}</span>{% endif %}<span class="visually-hidden"> {{ ns.total }} {{ one if ns.total == 1 else many }}</span>
<span class="response-card" role="tooltip">
{% if ns.total %}<span class="response-card-title">{{ ns.total }} {{ one if ns.total == 1 else many }}</span>{% endif %}
{% if (people and items) or anon %}
<span class="reaction-people">
<span class="response-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>
<span class="response-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 %}
{% for name, n in anon %}<span class="response-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>
<indie-action class="response-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>
@@ -103,7 +103,7 @@
{% 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">
<div class="response-counts">
{{ 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 #}
@@ -112,3 +112,15 @@
</div>
{% endif %}
{%- endmacro %}
{# Compact like / repost / reply counts for lists of notes (v2.13.4); links
to the note's responses. `counts` is from webmention_queries.response_counts. #}
{% macro list_counts(counts, permalink) %}
{% if counts %}
<a class="list-counts" href="{{ permalink }}#responses">
{%- for key, kind, one, many in [('likes', 'like', 'like', 'likes'), ('reposts', 'repost', 'repost', 'reposts'), ('replies', 'reply', 'reply', 'replies')] if counts[key] -%}
<span class="list-count list-count-{{ kind }}" title="{{ counts[key] }} {{ one if counts[key] == 1 else many }}">{{ ICONS[kind]|safe }}{{ counts[key] }}<span class="visually-hidden"> {{ one if counts[key] == 1 else many }}</span></span>
{%- endfor -%}
</a>
{% endif %}
{%- endmacro %}
+21 -4
View File
@@ -335,9 +335,9 @@ def test_note_page_shows_backfed_responses_quotes_and_counts(app, client, web):
assert "via GoToSocial" in page
assert "1 Quote" in page and "Look at this" in page
# Likes and reposts are a counts line (v2.13.2): named likes plus the silo's anonymous count
assert '<span class="reaction-count">13</span>' in page and "+12 on GoToSocial" in page
assert '<span class="reaction-count">1</span>' in page
assert f'<indie-action class="reaction-elsewhere" do="like" with="{SITE}/note/{note.slug}">' in page
assert '<span class="response-count-n">13</span>' in page and "+12 on GoToSocial" in page
assert '<span class="response-count-n">1</span>' in page
assert f'<indie-action class="response-elsewhere" do="like" with="{SITE}/note/{note.slug}">' in page
assert f'Like on <a href="{COPY}"' in page
assert 'src="/avatars/' in page and 'src="https://cdn.example/a.png"' not in page
@@ -620,5 +620,22 @@ def test_people_who_opt_out_are_counted_not_named(app, client):
assert (s["likes_count"], s["reposts_count"]) == (2, 1)
assert [r["source_url"] for r in rows(app, note.id)] == [like(1).source_url]
page = app.test_client().get(f"/note/{note.slug}").get_data(as_text=True)
assert '<span class="reaction-count">3</span>' in page and "+2 on GoToSocial" in page
assert '<span class="response-count-n">3</span>' in page and "+2 on GoToSocial" in page
assert "Liker 5" not in page and "Quiet" not in page
def test_home_page_shows_counts(app, client):
"""v2.13.4: lists of notes show like, repost and reply counts, linking to the responses"""
note, sid = crossposted(app)
with app.app_context():
quiet = create_note(content="Nobody saw this", published=True)
client.harvest = Harvest([like(1), like(2), reply(3)])
run(app)
with app.app_context():
get_db(app).execute("UPDATE syndications SET likes_count = 1, reposts_count = 2 WHERE id = ?", (sid,))
get_db(app).commit()
page = app.test_client().get("/").get_data(as_text=True)
assert f'href="{SITE}/note/{note.slug}#responses"' in page
assert 'title="3 likes"' in page and 'title="2 reposts"' in page and 'title="1 reply"' in page
assert f"/note/{quiet.slug}#responses" not in page
assert 'id="responses"' in app.test_client().get(f"/note/{note.slug}").get_data(as_text=True)