Okay, I’ve made my first “lunch break app” and got it running with WebID login. Next step is to build something simple that writes data to my POD. So I’ve dived into JavaScript programming with Vue and Bootstrap to make a single-page web-app that allows me to enter logbook entries - Click “New entry”, enter date and text and update HTML DOM using Vue to show the new entry. So far, so good.
Check if my POD has a container for my lognotes: does my POD have a container at /public/logbook ?
If there is no container at /public/logbook then create a new one.
Assuming the logbook container exists, create new resources in the container for my logbook entries. What if I want to use the “slug” header to name the new resource? Where to I state the “link” header that declares the type of my new resource? Can that be done at all in RDFLIB?
Delete resources.
I probably wouldn’t have much problem doing all that with HTTP from server side code in C# - but I’m absolutely lost in the world of JavaScript
Can anyone point me to the right tutorial section or sample code?
I think I can answer at least one of your questions - about the slug and the link:
// add a file to a directory
//
var link = ‘http://www.w3.org/ns/ldp#Resource; rel=“type”’
var filename = ‘myfile.ttl’
var parentFolder = “https://me.solid.community/public/somepath/”
var request = {
method : ‘POST’,
headers : { ‘Content-Type’:‘text/turtle’,slug:filename,link:link }
}
solid.auth.fetch( parentFolder, request ) // …
My fork of Solid Plume is a simple blog app which does all those functions IIRC.
The original Plume was old but I updated/bugfixed it a bit so it did work (with SAFE as a backend). I chose it because it is so simple, and made it easier for me to understand what it was doing, so I think it’s still good for this kind of learning.
Thanks Mark. I did actually scroll through Plume as one of the mentioned example applications. But I was surprised to see how much manual HTTP work you had implemented and was expecting to be able to use something like RDFLIB.js for more of that kind of heavy lifting.
Thanks. I’ve been trying to understand Inrupt’s guide, but there are a few funky corners I fail to understand. For instance:
[about the updater]
Just as the Fetcher allows the store to read and write resources from the web, generally a resource (file) at a time, the UpdateManager object allows the store to send small changes to the data web.
So apparently the Fetcher can do updates - but how? I can insert quads as they describe:
which will add the triple <me, fn, “John Bloggs”> to the profile document. But does that mean the original profile document on the web gets updated instantaneously? If not, where is then the “sync” method that initiates the write operation?
And, either using Fetcher or Updater, what if the fourth quad (document) element does not exist already - how will the document/resource be created? Where can I specify the “slug” and “link” headers for the new resource?
Just noticed how the data browser creates folders - nothing about “slug” or “link” headers here. It simply creates an empty “.dummy” file under the folder name and leave it to the server to create the folder itself:
Finally found an easy way to create new resources using the standard utilities. Browsing through the Fetcher source “indexed-formula.js” I found “putBack”:
let store = $rdf.graph();
let fetcher = new $rdf.Fetcher(store);
let entry = store.sym(LogbookRepository.logBookUrl + 'entry');
store.add(entry, NS_SOLIDRC('fn'), 'TEST', entry);
fetcher.putBack(entry);
The above code adds a new resource at “logBookUrl/entry” with one single RDF statement.
(beware, this seems like an older version of rdflib.js as “add” is “addEntry” in the github repo).
For what it is worth, I actually managed to pull off a little “append only” (so far) application that depends on RDFLIB only without using any direct HTTP actions. It helps a lot reading through the RDFLIB source to figure out how it is supposed to be used.
I’ll post a few more notes here as it develops (adding delete and update features). If someone feels that is an inappropriate use of this forum then please let me know.
The logbook is for logging flights with model airplanes (which explains some of the values present on the entries).
The UI/UX so far is not relevant - and it is hard coded to my WebID.
I have seen the data browser simply doing a PUT …/X/.dummy and then DELETE …/X/.dummy to create the empty container …/X. No need for slug or special headers that way.