Sharon Stratsianis
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Tools Review solid-client and RDFlib The data behind a **Solid** Application is called Linked Data. You can read more about that [here](https://www.w3.org/wiki/LinkedData). While there are many ways you can interact with the data in your **Solid** Pod, this blog post highlights two libraries. (we can link here to blogs to other ways...) One from Inrupt, called [solid-client](https://github.com/inrupt/solid-client-js). This is used in the [PodBrowser](https://github.com/inrupt/pod-browser) an application that can be used to view your contacts, bookmarks, as well as the files you have stored in your Pod. This library attempts to simplify the concepts and make it easier to use for Application Developers who are just starting to learn about Linked Data. The second is one of the originals [RDFlib](https://github.com/linkeddata/rdflib.js). This is the library used in [SolidOS](https://github.com/SolidOS), and while a bit harder to understand for those who are just beginning their Semantic Web journey it has much more packed in to harness the power of Linked Data. ## Authentication Before getting into the data libraries, it should be mentioned that you will also need an authentication library. Right now the best one to use is [Solid Client Auth](https://github.com/inrupt/solid-client-authn-js). There are two different libraries you can use depending if you are writing client or server applications and both are mentioned in the library above. In order to read and write private data you will need to make sure the user is authenticated. ## solid-client When you are working with the solid-client library one of the biggest things to get your head around is something called a Dataset. ... https://github.com/inrupt/solid-client-js ... Docs are here https://docs.inrupt.com/developer-tools/javascript/client-libraries/structured-data/ .. 1. Explain what a dataset is and how it is used. 2. How do you read and write the data in the dataset. 3. What are the steps to get something working read, write... explain this with an example 4. What are the advantages to use solid-client Code Example: bits taken from pod-browser and tweaked. Explain.. what is a responder, why do I need it. Explain my data... but just point to another document that does this... explain getResource etc... explain what the code is doing and any detail around it that is important. ``` export async function getAddressBooks(fetch) { const { respond, error } = createResponder(); const addressesIri = joinPath(CONTACTS_CONTAINER, ADDRESSBOOKS_INDEX); const { response: addressesResponse, error: resourceError } = await getResource( addressesIri, fetch ); if (resourceError) return error(resourceError); const { dataset } = addressesResponse; const addressesThingUrl = `${getSourceUrl(dataset)}#this`; const addressesThing = getThing(dataset, addressesThingUrl); const iris = getUrlAll(addressesThing, vcardExtras("includesAddressBook")); const addresses = iris.map((iri) => { const addressThing = getThing(dataset, iri); return { iri, name: getStringNoLocale(addressThing, vcard.fn), }; }); return respond(addresses) } ``` ## RDFlib RDFlib is a powerful set if tools for not just dealing with RDF and turtle, but also reading and data to and from the web, and syncing your app when the data is changd by other apps or other users. There are three level of power you can invole with different leves of store. They all store quads - in other words they keep track of where the RDF facts, triples, each came from. This is important when you want to bring multiple pieces of data together. - Store is a quadstore which in load and dump data in many wasy, and can be queried - OnlineStore is a Store which also has extra power - to read and write data from the web. - LiveStore is like OnlineStore but also has the ability to send small changes from your app and to coordinate them with changes coming the other way, ### LiveStore You should almost certainly use LiveStore for your app. A typical thing to do it to create one LiveStore for the process, which acts as a cache of the data in the web. That way any request for data which has already been fetched will be returned from the cache immediately without waiting for the network and the server. The way SolidOS uses LiveStore, there is one for the whole client process. One cache of the data web across the process. This is important because when you write you code in functions like thngs to make a meeting, render a meeting, find yor addressbooks, display icons of people in the meeting, etc, if you do it naively those functions all end up loading the same solid document again and again. if you fix that by making app-level caching, having plain old JS objects where eyou keep everything you have read as a app-level cache, that’s a lot of work, lots of code, and you probably will be ineffective because you will miss some things, and also you will make classic cache mistakes .. using an out of date one etc. Instead, if you use rdflib as we do, with a process-wide livestore, it will do the caching automatically and you can just write the logic of the app. ### Fetcher and Update Manager The functionality of the fetcher allows you to do all the web I/O with functions of the fetcher — and esp. the update-manager. Normal RDF libaries, especially the standard API, has none of thos fnctionality. So you have simple functions for things like ‘make this change to this documents’ and ‘call me whenever this doc changes’. The nice thing about that last thing .. setting a listener for changes — s that it leaves RDFLIB to worry abou the upgade from the old protcol to the new ne fro example — your code stays the same. ### Performance The standard RDFJS library is designed for parser writers, not for users, not for developers who use it. So it is designed to be as fast as possible rather than to be easy for users to understand. And we have simple methods like x.doc() x.dir() etc whcih are handy for moving between a thing and the doc its data is stored in, the folder the doc is in, etc. And our store has not just match() but also things like each and any which are more intuitive to use and more powerful, so you end up writing fewer lines of code. 1. Explain what rdflib is.. a bit of history and point to https://linkeddata.github.io/rdflib.js/Documentation/webapp-intro.html 2. Explain how to read and write data 3. Show the same example from above in rdflib ## Comparison The library you select really depends on what you are trying to accomplish and where you are in your journey. At the end of the day any library interacting with Linked Data is backed by the HTTP protocol. Both libraries can take some time to understand how to work with the API, but if you are just starting out and do not have a serious Linked Data application idea in mind it will be easier for you to start with the solid-client library. What do I mean by serious Linked Data application... this I will need to explain in another blog post, but I'm talking about leveraging the power of Linked Data in your applications. This is something I am exploring myself and at the heart of this exercise. RDFlib, as mentioned previously was built with the intention of getting the full power of Linked Data. Some additonal things you get when you use it are completely flexible searching (e.g. find all triples with predicate X), the possibility to run sparql against the store, serialization into multiple formats, querying across multiple sources at once, and easy access to request data (headers,etc). If you want to see what Linked Data is really about and you don't mind taking a bit more time and enjoy the learning process you should really try it out. Another blog post to come about how to use all the cool features. ## My Journey One of the big things I struggled with was the concept of a Dataset and a LiveStore. Having come from SolidOS where we use LiveStore, but in a vanilla Javascript application, I wasn't sure how to translate this into the React world. I wanted to use React because it is faster for me to implement my idea. will add more as I go... ### Questions to clarify or research 1. Confirm if dataset is the same as a LiveStore 2. How is rdflib different from solid-client.. nowOrWhenFetched() is it true that you can follow data easier. need to ask or confirm.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully