Skip to content

Latest commit

 

History

History
148 lines (108 loc) · 3.94 KB

README.md

File metadata and controls

148 lines (108 loc) · 3.94 KB

Qworum logo and name

Qworum for web pages

This is Qworum's official JavaScript library for web frontends.

Documentation

The documentation for the latest version of this library is available here.

Some projects that are using this library

Template for a Qworum application that uses RDF data.

How to import this library in a web page

import { QworumScript, Qworum } from "https://esm.sh/gh/doga/[email protected]/mod.mjs";

Activating Qworum for a website

Qworum provides advanced browser capabilities through a browser extension. By default Qworum is actived for local development only. Activating Qworum for a website requires a subscription.

Usage

Tip: Run the examples below by typing this in your terminal (requires Deno 2+):

deno run \
  --allow-net --allow-run --allow-env --allow-read \
  jsr:@andrewbrey/[email protected] \
  --dax=false \
  https://raw.githubusercontent.com/doga/qworum-for-web-pages/master/README.md
Generate a Qworum script in-memory.
description = '''
Running this code is safe.
'''
import { QworumScript, Qworum } from 'https://esm.sh/gh/doga/[email protected]/mod.mjs';

const
Script   = QworumScript.Script.build,
Sequence = QworumScript.Sequence.build,
Call     = QworumScript.Call.build,
Goto     = QworumScript.Goto.build,
script   = Script(
  Sequence(
    Call(['@', 'shopping cart'], 'https://shopping-cart.example/view/'),
    Goto("/home/")
  )
);

console.info(`${script}`);

// In a browser the Qworum extension would run the Qworum script.
// await Qworum.eval(script);

Sample output for the code above:

Sequence(Call(object: [@, shopping cart], href: https://shopping-cart.example/view/),Goto(href: /home/))
Create semantic data sourced from a Turtle file.
description = '''
Running this code is safe.
'''
import { SemanticData, Qworum } from 'https://esm.sh/gh/doga/[email protected]/mod.mjs';

const org = new SemanticData();

await org.readFromUrl(new URL('https://qworum.net/data/org.ttl'));

console.info(`${org}`);

// In a browser the Qworum extension could store this as session data.
// await Qworum.setData('Organisation', org);

Sample output for the code above:

SemanticData(
  …
  <https://qworum.net/data/org.ttl#id> a <http://www.w3.org/ns/org#Organization>, <https://w3id.org/okn/o/sd#Organization>;
      <http://www.w3.org/ns/org#purpose> "Qworum is a provider of enterprise infrastructure software, with the overarching goal of making the web a fully fledged platform for applications."@en;
  …
)
Qworum scripts must not contain platform faults.
description = '''
Running this code is safe.
'''
import { QworumScript, Qworum } from 'https://esm.sh/gh/doga/[email protected]/mod.mjs';

const
Script     = QworumScript.Script.build,
Fault      = QworumScript.Fault.build,
faultTypes = ['* entitlement', 'payment cancelled', null];

for(const faultType of faultTypes){
  try{
    const script = Script(Fault(faultType));
    console.info(`${script}`);
  }catch(error){
    console.error(`${error}`);
  }
}

Sample output for the code above:

TypeError: not a service-specific fault: '* entitlement'
Fault(type: payment cancelled)
Fault(type: * service-specific)

License

This software is released under the terms of the Apache 2.0 license.