Phlex::RDF proposal (schema.org, ActivityStreams/ActivityPub, FOAF, etc.) #400
ziggythehamster
started this conversation in
Ideas
Replies: 1 comment
-
|
Thanks for writing this up. There's lots to unpack here, we should pair sometime. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is going to be a long post, mostly containing commented Ruby code.
@joeldrapper has been spitballing ways to support things besides HTML, and I've been thinking about specifically RDF. RDF has been around forever and can be serialized in a ton of different ways. And, in fact, it's possible to output RDF in many semantically identical but extremely different ways. In order to encourage people to use RDF-aware tooling, I think we should talk about how we might model RDF in Phlex.
Some things to think about:
renderdoes this already out of the box?schema.Date.new('value')would be good UX? (But how do we prevent you from doingschema.Thing.new, which isn't a literal?)toshould always be an array. This seems to be a bug in either the spec's definition file or injson-ld-preloaded's parser of the spec's definition file. This can be fixed by making theTermDefinitionfortosetcontainer_mapping: "@set"as:Publicshould be expanded tohttps://www.w3.org/ns/activitystreams#Public. This does not appear to be fixable inside ruby-rdf, so we could make the helper that buildsRDF::Resources have an option likeforce_expand: truewhich causes us to prefix the resource URI with__phlex_force_expand__, and we simply remove that after we have a hash of JSON-LD but before we serialize the JSON.Phlex::RDFshould by default patch ruby-rdf/json-ld so network access raises. maybe add aPhlex::RDF.allow_rdf_network_access!that can be called to restore the default.For reference, the above prints this output:
{ "@context": "http://schema.org/", "type": "PodcastEpisode", "name": "Marathon", "datePublished": "2022-06-09", "description": "This week the gang talks about the ins and outs of Marathon, one of Bungie's first breakout hits, and the granddaddy of Halo and Destiny! Also, we're gearing up for our Grand Reopening, Friday June 10th!", "timeRequired": "PT35M30S", "url": "https://art19.com/shows/the-madecast/episodes/2f98892e-1855-4d34-ba83-a4764b7cd7cb", "about": { "type": "VideoGame", "name": "Marathon", "gamePlatform": "Macintosh", "publisher": "Bungie" }, "associatedMedia": { "type": "MediaObject", "contentUrl": "https://rss.art19.com/episodes/2f98892e-1855-4d34-ba83-a4764b7cd7cb.mp3", "embedUrl": "https://art19.com/shows/the-madecast/episodes/2f98892e-1855-4d34-ba83-a4764b7cd7cb/embed", "encodingFormat": "audio/mpeg" }, "partOfSeries": { "type": "PodcastSeries", "name": "The MADEcast", "url": "https://art19.com/shows/the-madecast", "webFeed": "https://rss.art19.com/the-madecast" } }The compile phase would probably just have a graph it passes through successive templates and just have a bunch of RDF::Statement.new's and cache the
RDF::Resources in a Hash (or useRDF::URI.intern).Also I wanted to do an ActivityStreams example since that's what I'm most interested in, but it's a good test-bed for nesting templates, so I want to gut check my thoughts before I went down that rabbit hole :).
Beta Was this translation helpful? Give feedback.
All reactions