Skip to content

opds2: emit rel=alternate links for off-site identifier URLs#703

Merged
ajslater merged 1 commit intov1.11-performancefrom
claude/opds2-alternate-links
May 2, 2026
Merged

opds2: emit rel=alternate links for off-site identifier URLs#703
ajslater merged 1 commit intov1.11-performancefrom
claude/opds2-alternate-links

Conversation

@ajslater
Copy link
Copy Markdown
Owner

@ajslater ajslater commented May 2, 2026

Summary

Per beville's follow-up on #700: a comic's identifier URLs (ComicVine, Metron, etc.) are off-site representations of the same publication and belong in publication.links as rel=alternate. Mirrors the readino feed shape beville cited:

```json
"links": [
{"rel": "self", "type": "application/divina+json", "href": "..."},
{"rel": "alternate", "type": "text/html", "href": "https://comicvine.gamespot.com/...", "title": "View on ComicVine"}
]
```

Now emitted on both the per-comic manifest endpoint and on each publication in the feed.

Implementation notes

  • Base view (OPDS2PublicationBaseView) runs a per-comic identifier query — used by the manifest path, which serves one book per request.
  • Feed view (OPDS2PublicationsView) overrides with a batched query keyed by comic pk, populated in get_publications before the per-publication loop. Mirrors the existing credits / subjects batching, so a full feed page stays at one identifier query regardless of book count.
  • URLField(default="") means we filter .exclude(url="") rather than __isnull.
  • Title is "View on <source>" when the identifier has a source, "View externally" otherwise.

Test plan

  • make fix, ruff, basedpyright, complexity, make test-python all clean
  • Hit /opds/v2.0/c/<pk>/1 on a comic with ComicVine/Metron identifiers and confirm links contains rel=alternate entries
  • Hit /opds/v2.0/<group>/<pks>/1 (a feed page) and confirm each publication's links contains its identifier alternates
  • Confirm comics with no URL'd identifiers don't get spurious links

🤖 Generated with Claude Code

Per beville's follow-up on #700: identifier ``url`` values are off-site
representations of the same publication and belong in publication.links
as ``rel=alternate`` (e.g. {"rel": "alternate", "type": "text/html",
"href": "https://comicvine.gamespot.com/...", "title": "View on
ComicVine"}).

The base view runs a per-comic query for the manifest path; the feed
view overrides with a batched UNION query keyed by comic pk so a full
feed page stays at one identifier query regardless of book count
(matching the existing credits / subjects batching).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ajslater ajslater merged commit 5db8c74 into v1.11-performance May 2, 2026
1 check failed
@ajslater ajslater deleted the claude/opds2-alternate-links branch May 2, 2026 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant