Skip to content

fix(cite-as): claim it only on the page a nanopublication resolves to - #717

Open
ashleycaselli wants to merge 1 commit into
masterfrom
fix/716-cite-as-only-on-nanopub-page
Open

ashleycaselli wants to merge 1 commit into
masterfrom
fix/716-cite-as-only-on-nanopub-page

Conversation

@ashleycaselli

Copy link
Copy Markdown
Member

Closes #716. Follow-up to #633.

The problem

rel="cite-as" (RFC 8574) says which IRI the page being read is to be cited as. It lived in the markup of the SourceNanopub panel:

<a wicket:id="np" class="source" rel="cite-as" vocab="…relation#">^</a>

That panel is the general "link to a source nanopublication" and renders wherever one is linked — ItemListElement creates one per list item. So a page listing n nanopublications made n conflicting claims about itself, none of them its own identity, and a link to another item's source made a wrong claim even on a single-item page.

For dokieli — the reason #633 added the link — that is worse than not having it at all: an annotation would anchor to whichever nanopublication happened to be linked on the page rather than the one being read.

The change

  • NanodashPage.getCiteAsIri() — a page says what it is to be cited as, and answers nothing unless it is that resource's own page. The default is nothing, so every page that merely links to nanopublications is silent.
  • ExplorePage answers with the nanopublication's IRI when the explored id resolves to one.
  • SourceNanopub goes back to being a plain link.

Why the head, not the visible IRI link

#716 suggested hanging it off the visible IRI link, and I started there. It doesn't work cleanly: a rel is a list of tokens and every token resolves against the vocab in scope. That link carries rel="noopener noreferrer" for its target="_blank", so putting the vocabulary on it would assert two further link relations about the page — relation#noopener and relation#noreferrer — alongside the one we want.

A <link> of its own carries the relation and nothing else, is what Signposting recommends for an HTML landing page, and is still RDFa-visible so dokieli reads it the same way. It also makes about="" unnecessary: the subject falls back to the document, which is exactly the claim. Rendered:

<link rel="cite-as" href="https://w3id.org/np/RA…" vocab="https://www.w3.org/ns/iana/link-relations/relation#" />

Testing

CiteAsLinkTest renders pages through WicketTester and asserts against the markup: a resource's own page claims exactly one cite-as pointing at itself, with the vocabulary in scope and no other relation on the tag; a page without a subject of its own claims nothing. CiteAsSubjectPage is a test-only stand-in so none of this needs a nanopublication over the network.

Full suite: 1439 tests, 0 failures.

Note

#716 asked whether a pinned-version or ?ref=-scoped rendering still counts as "the page it resolves to". This takes the straightforward reading — the page claims a cite-as whenever the explored id resolves to a nanopublication — which is right for the redirect target that motivated #633. If a ?ref=-scoped view should stay silent, that is a one-line change to getCiteAsIri() and worth deciding separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NnGpEQkFqCaf4AEQwwhFFn

rel="cite-as" (RFC 8574) says which IRI the page being read is to be cited as.
It sat in the markup of the SourceNanopub panel, which is the general "link to a
source nanopublication" and renders wherever one is linked -- once per item in
ItemListElement, for instance. A page listing n nanopublications therefore made
n conflicting claims about itself, none of them its own identity, and a link to
another item's source made a wrong one even on a single-item page. For dokieli,
the reason #633 added the link, that is worse than not having it: an annotation
would anchor to whichever nanopublication happened to be linked.

Pages now say what they are to be cited as through getCiteAsIri(), which answers
nothing unless the page is that resource's own page. ExplorePage answers with the
nanopublication's IRI when the explored id resolves to one.

Rendered into the head rather than onto the visible IRI link. A rel is a list of
tokens and every token resolves against the vocabulary in scope, so putting the
vocab on the visible link -- which carries noopener noreferrer for its target
-- would assert two further link relations about the page. A link of its own
carries the relation and nothing else.

Closes #716

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NnGpEQkFqCaf4AEQwwhFFn
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.

Emit rel="cite-as" only on the page a nanopub resolves to, not wherever a nanopub is linked

1 participant