Compare commits

..
4 Commits
Author SHA1 Message Date
Phil d312fa0074 Merge branch 'fix/v2.13.4-list-counts' for v2.13.4 release
Build Container / build (push) Successful in 8m56s
2026-11-10 14:05:05 -07:00
PhilandClaude Opus 5.5 647f6c723b feat: counts on lists of notes, reply cards link to the reply, fix class clash (v2.13.4)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 14:05:03 -07:00
Phil 81c730813c Merge branch 'fix/v2.13.3-count-opted-out' for v2.13.3 release
Build Container / build (push) Successful in 8m35s
2026-11-10 13:19:18 -07:00
PhilandClaude Opus 5.5 113f28aff1 fix: count opted-out likes and reposts without naming them (v2.13.3)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-10 13:16:19 -07:00
15 changed files with 261 additions and 41 deletions

No files matched your search

+20
View File
@@ -7,6 +7,26 @@ 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
- Likes and reposts by people who opted out of backfeed (`#nobridge` or `#nobot` in their profile, or Bluesky's "don't show me to logged-out users" label) are counted in a note's totals, without their name or avatar ("+1 on Bluesky"). Before, they were left out entirely, so totals were lower than on the silo
## [2.13.2] - 2026-11-10
### Changed
+9
View File
@@ -235,6 +235,15 @@ While at it, the Threads client moves from `graph.threads.net` to
the same action on each crosspost. No web-action polyfill is loaded;
handlers such as browser extensions can use the markup.
## Amendments (v2.13.3, 2026-11-10)
- **Opted-out people are counted.** Their likes, reposts and quotes are
still not stored or named (Decision 5), but each check records how many
there were on the copy's `syndications` row (`likes_count`,
`reposts_count`, `quotes_count`, the columns Threads' counts use), and
the counts line adds them to the totals as "N on <silo>". Totals then
match the silo.
## Consequences
- Responses on all three silos show on the note within 15 minutes for new
+9 -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) · [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
@@ -434,6 +434,14 @@ OIDC admin login and built-in IndieAuth server.
- [2026-11-10-reaction-counts.md](v2.13.2/2026-11-10-reaction-counts.md) - Likes/reposts as a counts line with hover lists; web actions
## v2.13.3
- [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,22 @@
# v2.13.3: Count opted-out people without naming them
## Why
A note's Bluesky copy had 1 like on Bluesky and 0 on the note. The liker's
account has the `!no-unauthenticated` label, so backfeed skipped them
(ADR-073 Decision 5). Every other Bluesky copy's like and repost counts
matched what StarPunk had stored.
## Change
`backfeed.hidden_counts(harvest)`: the silo's own counts when it gives no
names (Threads), else the number of opted-out likes, reposts and quotes in
the harvest. `check()` stores it on the copy's `syndications` row, and the
counts line (v2.13.2) already adds those columns to the totals as
"N on <silo>". Opted-out people are still not stored.
## Verification
`tests/test_backfeed.py::test_people_who_opt_out_are_counted_not_named`:
label, `#nobot` and `#nobridge` opt-outs counted (2 likes, 1 repost), not
stored, not named on the page; totals include them.
@@ -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.2**. 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.2"
__version_info__ = (2, 13, 2)
__version__ = "2.13.4"
__version_info__ = (2, 13, 4)
+19 -3
View File
@@ -64,7 +64,9 @@ class Harvest:
"""What one check found. complete=False: some list was cut short."""
responses: List[Response]
complete: bool = True
counts: Optional[Dict[str, int]] = None # Threads likes/reposts/quotes
# Likes/reposts/quotes shown only as numbers: all of them on Threads
# (its API doesn't say who); elsewhere, those by people who opted out
counts: Optional[Dict[str, int]] = None
# --- Text -----------------------------------------------------------------
@@ -243,11 +245,25 @@ def _display_state(db, note_id: int) -> list:
)]
def hidden_counts(harvest: Harvest) -> Dict[str, int]:
"""
Likes, reposts and quotes to show only as numbers: the silo's own counts
when it gives no names (Threads), else those by people who opted out
(v2.13.3: they're counted, not named)
"""
if harvest.counts is not None:
return harvest.counts
hidden = [r.kind for r in harvest.responses if _opted_out(r)]
return {k: hidden.count(kind) for k, kind in
(("likes", "like"), ("reposts", "repost"), ("quotes", "quote"))}
def store(db, note_id: int, target_url: str, origin: str, harvest: Harvest) -> None:
"""
Upsert a check's responses for one note and silo. With a complete
harvest, that silo's responses for the note that weren't found are
marked invalid. Responses from people who opted out are removed.
marked invalid. Responses from people who opted out are removed (they
are counted instead, see `hidden_counts`).
"""
from starpunk.webmention_processor import _snippet
@@ -358,7 +374,7 @@ def check(row, target) -> None:
site = current_app.config["SITE_URL"].rstrip("/")
harvest = target.client.responses(row["remote_id"], row["remote_url"] or "")
store(db, row["note_id"], f"{site}/note/{row['note_slug']}", row["target"], harvest)
_store_counts(db, row["id"], harvest.counts)
_store_counts(db, row["id"], hidden_counts(harvest))
def process_due(limit: int = 3) -> int:
+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>
+24 -11
View File
@@ -56,8 +56,9 @@
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
its fallback, so web action handlers can take over. Counts without names
(all of Threads; elsewhere people who opted out, v2.13.3) 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>',
@@ -72,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>
@@ -102,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 #}
@@ -111,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 %}
+38 -3
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
@@ -604,3 +604,38 @@ def test_own_gotosocial_redirect_to_remote_avatar_is_followed(app, web, monkeypa
monkeypatch.setattr("starpunk.webmention_ssrf.TRANSPORT", httpx.MockTransport(fake))
with app.app_context():
assert avatars.fetch(app.config["DATA_PATH"], f"{GTS}/fileserver/x/avatar.jpeg", SITE)
def test_people_who_opt_out_are_counted_not_named(app, client):
"""v2.13.3: likes and reposts by people who opted out add to the totals anonymously"""
note, sid = crossposted(app)
shy = like(5, opted_out=True)
client.harvest = Harvest([like(1), shy, like(6, bio="#nobot"),
Response(kind="repost", source_url=f"{COPY}#reposted-by-7", remote_id="7",
author_name="Quiet", author_bio="#nobridge")])
run(app)
with app.app_context():
s = get_db(app).execute("SELECT likes_count, reposts_count FROM syndications WHERE id = ?",
(sid,)).fetchone()
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="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)