diff --git a/CHANGELOG.md b/CHANGELOG.md index b7c9331..adc6fc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/design/INDEX.md b/docs/design/INDEX.md index 53bcc82..499274e 100644 --- a/docs/design/INDEX.md +++ b/docs/design/INDEX.md @@ -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. diff --git a/docs/design/v2.13.4/2026-11-10-list-counts.md b/docs/design/v2.13.4/2026-11-10-list-counts.md new file mode 100644 index 0000000..40f3976 --- /dev/null +++ b/docs/design/v2.13.4/2026-11-10-list-counts.md @@ -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 `#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. diff --git a/docs/standards/versioning-strategy.md b/docs/standards/versioning-strategy.md index 3941060..5516775 100644 --- a/docs/standards/versioning-strategy.md +++ b/docs/standards/versioning-strategy.md @@ -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 diff --git a/starpunk/__init__.py b/starpunk/__init__.py index 11763f8..bf87a89 100644 --- a/starpunk/__init__.py +++ b/starpunk/__init__.py @@ -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) diff --git a/starpunk/routes/public.py b/starpunk/routes/public.py index 22a8db4..68f3fe2 100644 --- a/starpunk/routes/public.py +++ b/starpunk/routes/public.py @@ -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", diff --git a/starpunk/webmention_queries.py b/starpunk/webmention_queries.py index f1f1636..6046d1e 100644 --- a/starpunk/webmention_queries.py +++ b/starpunk/webmention_queries.py @@ -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, diff --git a/static/css/style.css b/static/css/style.css index 2f95d5a..025fd6d 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -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 { diff --git a/templates/note.html b/templates/note.html index 07ba29a..ff186ec 100644 --- a/templates/note.html +++ b/templates/note.html @@ -78,6 +78,7 @@ {% endif %} +
{{ responses.reactions(likes, reposts, replies, bookmarks, syndications, absolute_url_for('public.note', slug=note.slug)) }}