AffordanceVocabulary

From W3C Wiki
Jump to: navigation, search

An attempt to hack together the vocabulary necessary to describe affordances. See RdfAffordances

Vocabulary

Status : rough proposal

Initial aim is to do just enough to be able to write some running code to try things out. For the setup described further down, the following terms seem to be needed.

Future compatibility with Web Intents is desirable and should be zero cost if we define an Intent as a composite Action, where an Action is a HTTP-level operation.

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . 
@prefix : <http://purl.org/stuff/actions/> .

# Classes

:Affordance a rdfs:Class ;
rdfs:label "Affordance";
rdfs:comment "resource description which allows a client to perform an action" .

:Action a rdfs:Class ;
rdfs:subClassOf :Affordance ;
rdfs:label "Action";
rdfs:comment "a HTTP-level affordance" .

:Intent a rdfs:Class ;
rdfs:subClassOf :Affordance ;
rdfs:label "Intent";
rdfs:comment "composite affordance, e.g. edit" .

:Target a rdfs:Class ;
rdfs:label "Target";
rdfs:comment "resource to which an affordance applies" .

:Representation a rdfs:Class ;
rdfs:label "Representation";
rdfs:comment "media type-specific representation of a resource" .

# Properties

:supports a rdf:Property ;
rdfs:label "supports";
rdfs:comment "affordance available at resource" ;
rdfs:domain :Target;
rdfs:range :Affordance .

:method a rdf:Property ;
rdfs:label "method" ;
rdfs:comment "the HTTP method" ;
rdfs:domain rdf:Resource;
rdfs:range rdfs:Literal .

:media a rdf:Property ;
rdfs:label "media" ;
rdfs:comment "supported media type" ;
rdfs:domain rdf:Resource;
rdfs:range rdfs:Literal .

:requires a rdf:Property ;
rdfs:label "requires" ;
rdfs:comment "prerequisite for an affordance" ;
rdfs:domain :Affordance;
rdfs:range rdf:Resource .

:representation a rdf:Property ;
rdfs:label "representation" ;
rdfs:comment "object is a representation of the subject" ;
rdfs:domain :Target;
rdfs:range rdf:Representation .

:content a rdf:Property ;
rdfs:label "content" ;
rdfs:comment "content" ;
rdfs:domain rdf:Representation;
rdfs:range rdf:Literal .

# special affordances - these seem common enough that they should be given an elevated status

:login a rdf:Property ;
rdfs:label "login" ;
rdfs:comment "endpoint through which authorization may be obtained" ;
rdfs:domain :Target;
rdfs:range rdf:Resource .

:sparql a rdf:Property ;
rdfs:label "sparql" ;
rdfs:comment "SPARQL endpoint to a triplestore containing information about the target" ;
rdfs:domain :Target;
rdfs:range rdf:Resource .

Possible setup

I've got a node.js installation that should be ideal for playing with this stuff. A simple Wiki-like setup with NTriple content seems like a reasonable first app. - DannyAyers

While the affordance description RDF could appear anywhere, because this stuff is meant to be interactive then such data ideally needs to be easily available just-in-time in close proximity to the resource it describes. So I'm going to try the following:

Affordance data about e.g.
http://hyperdata.org/active/index
will be available at
http://hyperdata.org/active/index?

in JSON-LD format. (As far as I can tell the ? is legal and doesn't break anything, seems a reasonable place to put metadata about the resource without the ?).

MCA: Another option for accessing the affordance information associated w/ a URI is to use a protocol-level request on the same URI:

*** REQUEST ***
OPTIONS /active/index HTTP/1.1
Host: hyperdata.org
Accept: application/json-ld
...

*** RESPONSE ***
...

Or provide a URI as control information in the response to the initial request (via Web Linking [RFC5988]):

*** REQUEST ***
GET /active/index HTTP/1.1
Host: hyperdata.org
Accept: text/turtle
...
*** RESPONSE ***
200 OK
Content-Type: text/turtle
Link:<http://hyperdata.org/active/index?affordances>;rel="affordances";type="application/json-ld"
...

Sample Data

(will appear in JSON-LD at
http://hyperdata.org/active/index?
)
# tags the URI as a target
<http://hyperdata.org/active/index> a :Target .

# the simplest affordance (well, almost)
<http://hyperdata.org/active/index> :supports [
a :Action ;
:method "GET" ;
:media "application/rdf+xml" ; 
:media "text/html" .
] .

# something requiring UI
<http://hyperdata.org/active/index> :supports <http://hyperdata.org/active/intents#Edit> .
<http://hyperdata.org/active/intents#Edit> a :Intent ;
# point to the Javascript that'll do the work
:ui <http://hyperdata.org/active/ui/edit> ;
:requires :Target ;
:requires :Representation .

the representation will contain the "before" part of the edit (the triples in question or whatever) and look something like:

[
a :Representation ;
:media "text/turtle" ;
:content "<#me> foaf:nick \"danja\" . "
]

(that " escaping probably isn't correct)

See Also