feat(pages): serve resource pages as RDF by content negotiation and embedded JSON-LD - #712
Merged
Merged
Conversation
…mbedded JSON-LD Space, user, maintained-resource and part pages answer an Accept header that prefers an RDF media type with a 303 to the download page in the matching format: graph-aware formats carry the full nanopublications, triple-only formats the assertions. Both the redirect and the HTML response vary on Accept. The HTML head links every download format as an alternate and embeds the resource's declaring assertions as a JSON-LD block, identified by the resource IRI and pointing at the full download via void:dataDump, so that HTML-reading Linked Data tools and search engines find the RDF. Closes #710 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EHzVZYfuW9yuZrjYvG1rnh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #710.
Space, user, maintained-resource and part pages now offer their RDF three ways:
Acceptheader that prefers an RDF media type gets a 303 to/download-rdfin the matching format. TriG, N-Quads, JSON-LD and TriX carry the full nanopublications; Turtle, N-Triples and RDF/XML carry the assertions only. Wildcard and browser headers keep getting HTML. Both answers carryVary: Accept.<script type="application/ld+json">block with the resource's declaring assertion(s),@id= the resource IRI, plus avoid:dataDumplink to the full TriG download.<is escaped so a text value cannot close the block.<link rel="alternate" type="...">per download format.Implementation:
RdfNegotiation(media type → download variant),RdfSource(download URLs + JSON-LD serialization), agetRdfSource()hook andredirectIfRdfRequested()helper onNanodashPage, and a few lines in each of the four pages. Microdata/RDFa attributes are deliberately not used.Tested with unit tests for the negotiation and the serialization, WicketTester tests for the redirect, headers and head markup, and end to end on a local instance with curl and the Comunica command-line client.
Note: Comunica asks for N-Quads, so the triples arrive inside the nanopub graphs; a plain
?s ?p ?opattern matches nothing there, aGRAPH ?g { }pattern does.🤖 Generated with Claude Code
https://claude.ai/code/session_01EHzVZYfuW9yuZrjYvG1rnh