Add name and avatar as convenience methods
Closed this issue · 4 comments
It would be nice to return name and avatar in convenience methods from the SolidProfile
Currently I use code like:
var FOAF = $rdf.Namespace("http://xmlns.com/foaf/0.1/");
var kb = parsedProfile.parsedGraph;
var name = kb.any($rdf.sym(userURI), FOAF('name'));
var avatar = kb.any($rdf.sym(userURI), FOAF('depiction'))
|| kb.any($rdf.sym(userURI), FOAF('img'));
@melvincarvalho - I was just speaking to @deiu regarding this exact issue the other day.
I agree with your request. I've been experiencing this $rdf.any(...)
boiler plate as a bit of a leaky abstraction. That is, if I want to work with basic solid data, I don't think that I should have to know the nitty-gritty details of rdflib or even RDF (perhaps this could be controversial). Since the solid spec defines a profile data schema, the client library can abstract away the queries against that profile.
E.g. I can imagine two styles:
solidProfile.getAvatar() // returns url to avatar
solidProfile.getName() // returns name
vs.
// SolidProfile.prototype.get takes a... rdflib symbol? :/
solidProfile.get(solid.vocab.foaf('img')) // returns url to avatar
solidProfile.get(solid.vocab.foaf('name')) // returns name
I prefer the second because I don't love the idea of adding a getter method for every single profile field; it feels a bit more future proof to me. I'm also curious as to any designs you had in mind.
Tagging @dmitrizagidulin as he implemented the profile module.
I prefer the 2nd one as well.
I wonder to what extent we need to support both solidProfile.get()
and solidProfile.getAll()
. The later one can be useful to return multiple values -- e.g. phone numbers or emails.
Implemented in PR #101. See the README for details, but basically it exposes:
profile.name
profile.picture
profile.find(predicate)
profile.findAll(predicate)
Implemented. closing.