Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeff-zucker/solid-load-profile
Loads a full Solid profile and returns methods to access it
https://github.com/jeff-zucker/solid-load-profile
Last synced: 29 days ago
JSON representation
Loads a full Solid profile and returns methods to access it
- Host: GitHub
- URL: https://github.com/jeff-zucker/solid-load-profile
- Owner: jeff-zucker
- License: mit
- Created: 2022-06-27T19:19:34.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-28T23:11:52.000Z (over 2 years ago)
- Last Synced: 2024-10-16T10:41:39.392Z (3 months ago)
- Language: JavaScript
- Size: 672 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# loadProfile
loads a full Solid profile and provides methods to access it
## loadFullProfile()
Loads into the UI.store all of the required parts of a full Solid Profile that the current user and app have access to. Returns a context array containing full information on the user's inbox, oidcIssuers, storages, type registrations, and locations of all profile documents. The context array will look something like this:
```javascript
{
"me": {
"termType": "NamedNode",
"classOrder": 5,
"value": "https://jeff-zucker.solidcommunity.net/profile/card#me"
},
"publicProfile": {
"termType": "NamedNode",
"classOrder": 5,
"value": "https://jeff-zucker.solidcommunity.net/profile/card"
},
"storages": [
{
"termType": "NamedNode",
"classOrder": 5,
"value": "https://jeff-zucker.solidcommunity.net:8443/"
},
{
"termType": "NamedNode",
"classOrder": 5,
"value": "https://jeff-zucker.solidcommunity.net/"
},
{
"termType": "NamedNode",
"classOrder": 5,
"value": "https://jeffzucker.inrupt.net/"
}
]
"extendedDocs": [
{
"termType": "NamedNode",
"classOrder": 5,
"value": "https://jeff-zucker.solidcommunity.net/profile/mySeeAlso.ttl"
}
],
"registrations": {
"http://schema.org/DataFeed": {
"instances": [
{
"termType": "NamedNode",
"classOrder": 5,
"value": "https://jeff-zucker.solidcommunity.net/4cd1be50-2fab-11ec-a679-67f8e0446a98.ttl"
}
]
}
}
// etc with other predicates
}
```## profile.structure
The default context returned from profile.loadFullProfile() is an object containing named nodes. In some cases the app may want URL strings instead of named nodes. After profile.loadFullProfile() is called profile.structure will return the same context object but with strings instead of named nodes.
## getProperty()
Once the full profile is loaded, the getProperty() method can be called to retrieve specific information not contained in the context returned from the loadFullProfile() method. For example:
```javascript
alert( profile.getProperty('foaf:name') );
alert( profile.getProperty('http://xmlns.com/foaf/0.1/name') );
```
Note : You can use a curie (prefix:term) if the prefix is a common one, known to solid-namespaces. You can use a full URI for any predicate.## Calling in a script
The only prerequisite is solid-ui.
```htmlimport {LoadProfile} from './src/loadProfile.js';
async function showInfrastructure(webid){
let profile = new LoadProfile();
let context = await profile.loadFullProfile(webid);
context = "<pre>"+ JSON.stringify(context,null,4)+"</pre>";
let name = profile.getProperty('foaf:name');
document.getElementById('results').innerHTML = name + context;
}// ...
```