San Francisco 49ers
Joe Montana
1979
1992
Quarterback
```
--------------------------------
### JSON-LD Sports Team Example
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/rdfa/person.html
This JSON-LD snippet models a sports team and its members, including role-specific information like start and end dates.
```json
{
"@context": "http://schema.org",
"@type": "SportsTeam",
"name": "San Francisco 49ers",
"member": {
"@type": "OrganizationRole",
"member": {
"@type": "Person",
"name": "Joe Montana"
},
"startDate": "1979",
"endDate": "1992",
"roleName": "Quarterback"
}
}
```
--------------------------------
### Initialize Store and Fetcher
Source: https://github.com/linkeddata/rdflib.js/blob/main/Documentation/webapp-intro.html
Set up an RDF graph store and a Fetcher object to handle data transfer to and from the web. The Fetcher requires the store instance.
```javascript
const store = $rdf.graph();
const me = store.sym('https://example.com/alice/card#me');
const profile = me.doc();
const VCARD = new $rdf.Namespace('http://www.w3.org/2006/vcard/ns#');
const fetcher = new $rdf.Fetcher(store);
```
--------------------------------
### Initialize UI and Test Runner
Source: https://github.com/linkeddata/rdflib.js/blob/main/test/template/offline_index.html
Sets up the document ready state, initializes UI elements, and defines the test execution logic. Includes a note about test duration.
```javascript
$(document).ready(function() {
$("#globalresult").html("
Note: this test can take up several minutes to complete!
");
$("#viewSourceCode").click(function () {
viewSource("test_rdfparser.js");
});
$('#closeSourceView').live('click', function(){
hideSource();
});
$("#reset").click(function () {
location.reload(true);
});
$('#goOffline').iphoneSwitch("off", function() {
goOffline();
}, function() {
goOnline();
}, { switch_path: '../img/iphone_switch.png', switch_on_container_path: '../img/iphone_switch_container_on.png', switch_off_container_path: '../img/iphone_switch_container_off.png' } );
$('#runTests').click(function () {
tcXXXXPassed = true;
$('#tocTCXXXX').html("");
$("#detailedresults").html(testTCXXXX(true));
if(tcXXXXPassed) $("#globalresult").html("
Overall result: PASSED
");
else $("#globalresult").html("
Overall result: FAILED
");
});
});
```
--------------------------------
### Microdata Invoice Example
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/rdfa/person.html
Represents an invoice for services using Microdata with schema.org vocabulary. This example includes references to orders and products.
```html
New furnace and installation
ACME Home Heating
Jane Doe
2015-01-30
0.00
USD
0.00
USD
furnace
2014-12-01
123ABC
ACME Furnace 3000
furnace installation
2014-12-02
furnace installation
```
--------------------------------
### Discovering an Inbox with HTTP GET
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/serialize/csarven-ori.html
Use an HTTP GET request to discover the Inbox. The response is expected in JSON-LD compact form.
```http
GET / HTTP/1.1
```
--------------------------------
### Initialize Fetcher and Navigate to Subject
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/rdfa/test2.html
Sets up the cross-site proxy template and navigates to a specific subject URI when the DOM is ready. Ensure the proxy URI is correctly configured for cross-origin requests.
```javascript
document.addEventListener('DOMContentLoaded', function() {
var uri = window.location.href;
var data_uri = window.document.title = uri.slice(0, uri.lastIndexOf('/')+1) + 'book.ttl#this';
var path = uri.indexOf('/', uri.indexOf('//') +2) + 1;
var origin = uri.slice(0, path);
// var proxy_uri = origin + 'xss?uri={uri}'
// var proxy_uri = 'https://data.fm/proxy?uri={uri}'
// Temp hack @@
var proxy_uri = 'https://databox.me/,proxy?uri={uri}' // Temp hack @@
$rdf.Fetcher.crossSiteProxyTemplate = proxy_uri;
data_uri = 'http://melvincarvalho.com/';
var subject = $rdf.sym(data_uri);
tabulator.outline.GotoSubject(subject, true, undefined, true, undefined);
});
```
--------------------------------
### Retrieving a Specific Notification with HTTP GET
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/serialize/csarven-ori.html
A consumer retrieves an individual notification from the Inbox by making an HTTP GET request to its specific URL.
```http
GET /inbox/14a792f0 HTTP/1.1
```
--------------------------------
### Initialize and Run Offline Indexing Tests
Source: https://github.com/linkeddata/rdflib.js/blob/main/test/tc0005/offline_index.html
Sets up the test environment, handles UI interactions for switching online/offline modes, and runs the offline indexing tests. Includes a note about test duration.
```javascript
$(document).ready(function() {
$("#globalresult").html("
Note: this test can take up several minutes to complete!
");
$("#viewSourceCode").click(function () {
viewSource("test_rdfparser.js");
});
$('#closeSourceView').live('click', function(){
hideSource();
});
$("#reset").click(function () {
location.reload(true);
});
$('#goOffline').iphoneSwitch("off", function() {
goOffline();
}, function() {
goOnline();
}, {
switch_path: '../img/iphone_switch.png',
switch_on_container_path: '../img/iphone_switch_container_on.png',
switch_off_container_path: '../img/iphone_switch_container_off.png'
});
$('#runTests').click(function () {
tcXXXXPassed = true;
$('#tocTCXXXX').html("");
$("#detailedresults").html(testTCXXXX(true));
if(tcXXXXPassed) $("#globalresult").html("
Overall result: PASSED
");
else $("#globalresult").html("
Overall result: FAILED
");
});
});
```
--------------------------------
### Requesting Inbox Listing with HTTP GET
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/serialize/csarven-ori.html
A consumer requests the Inbox using an HTTP GET request. The receiver responds with a listing of notifications.
```http
GET /inbox/ HTTP/1.1
```
--------------------------------
### Initialize Test Harness and UI Elements
Source: https://github.com/linkeddata/rdflib.js/blob/main/test/tc0004/index.html
Sets up the test harness on document ready, initializes UI elements like the results display, source code viewer, reset button, and an offline switch. It also attaches event listeners for running tests and managing offline mode.
```javascript
$(document).ready(function() {
$("#globalresult").html("
Note: this test can take up to several minutes to complete. Consider using OFF-LINE mode (left upper corner).
");
$("#viewSourceCode").click(function () {
viewSource("test_rdfparser.js", true);
});
$('#closeSourceView').live('click', function(){
hideSource();
});
$("#reset").click(function () {
location.reload(true);
});
$('#goOffline').iphoneSwitch("off", function() {
goOffline();
}, function() {
goOnline();
}, { switch_path: '../img/iphone_switch.png', switch_on_container_path: '../img/iphone_switch_container_on.png', switch_off_container_path: '../img/iphone_switch_container_off.png' } );
$('#runTests').click(function () {
tc0004Passed = true;
$('#tocTC0004').html("");
$("#detailedresults").html(testTC0004(true));
if(tc0004Passed)
$("#globalresult").html("
Overall result: PASSED
");
else
$("#globalresult").html("
Overall result: FAILED
");
});
});
```
--------------------------------
### Initialize Test Harness and Event Listeners
Source: https://github.com/linkeddata/rdflib.js/blob/main/test/tc0007/index.html
Sets up the document ready event to initialize the test harness. It attaches click handlers for viewing source code and closing the source view, then executes the TC0007 test and displays the overall result.
```javascript
$(document).ready(function() { $("#viewSourceCode").click(function () { viewSource("test_UUU.js"); }); $('#closeSourceView').live('click', function(){ hideSource(); }); $("#detailedresults").html(testTC0007(true, newResults)); if(tc0007Passed) $("#globalresult").append("
Overall result: PASSED
"); else $("#globalresult").html("
Overall result: FAILED
"); });
```
--------------------------------
### Create a new rdflib.js store (graph shortcut)
Source: https://github.com/linkeddata/rdflib.js/blob/main/Documentation/webapp-intro.html
Initialize a new rdflib.js data store using the graph() shortcut. This is a convenient way to create a new store.
```javascript
const store = $rdf.graph();
```
--------------------------------
### GET Receiver reports
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/serialize/csarven-ori.html
Responds to GET requests with JSON-LD or RDF. Lists notification URIs with ldp:contains. Notifications are available as JSON-LD or RDF. The inbox has type ldp:Container and may advertise constraints with ldp:constrainedBy.
```APIDOC
## GET /inbox
### Description
Retrieves notifications from the inbox. The response format can be JSON-LD or RDF, depending on the `Accept` header.
### Method
GET
### Endpoint
/inbox
### Parameters
#### Header Parameters
- **Accept** (string) - Optional - Specifies the desired response format (e.g., `application/ld+json`, `application/rdf+xml`, `*/*`). Defaults to RDF if not specified or `*/*`.
### Response
#### Success Response (200 OK)
- **Content** (JSON-LD or RDF) - The list of notification URIs, potentially including `ldp:contains`.
- **ldp:constrainedBy** (string) - Optional - Header - URI advertising constraints.
#### Notes
- The inbox is of type `ldp:Container`.
- The list of notification URIs may be restricted based on access control.
```
--------------------------------
### Response to Sending a Notification
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/serialize/csarven-ori.html
An example HTTP response indicating successful creation of a notification after a POST request.
```http
HTTP/1.1 201 Created
```
--------------------------------
### Initialize RDFLib.js Store, Fetcher, and UpdateManager
Source: https://github.com/linkeddata/rdflib.js/blob/main/Documentation/webapp-intro.html
Sets up the necessary RDFLib.js objects for interacting with the web, including a graph store, a fetcher for loading resources, and an UpdateManager for sending changes.
```javascript
const store = $rdf.graph()
const fetcher = new $rdf.Fetcher(store)
const updater = new $rdf.UpdateManager(store)
```
--------------------------------
### Run Tests
Source: https://github.com/linkeddata/rdflib.js/blob/main/CONTRIBUTING.md
Execute the project's test suite using npm. Ensure all tests pass before submitting changes.
```sh
$ npm test
```
--------------------------------
### Agent Delegation with WebID
Source: https://github.com/linkeddata/rdflib.js/blob/main/tests/serialize/csarven-ori.html
Example of an agent delegating another agent to act on its behalf, using WebID.
```turtle
auth:delegatesTo .
```
--------------------------------
### Using Hub for Forking and PRs
Source: https://github.com/linkeddata/rdflib.js/blob/main/CONTRIBUTING.md
Utilize the 'hub' command-line tool to fork the repository, create branches, push changes, and initiate pull requests.
```bash
$ git clone https://github.com/linkeddata/rdflib.js
$ cd rdflib.js
# to fork the repository
$ hub fork
# to fork the repository
$ git checkout -b feature-branch
# after committing your changes, push to your repo
$ git push your_username feature-branch
# start a PR
$ hub pull-request
```
--------------------------------
### Local Identifiers with Default Prefix in Turtle
Source: https://github.com/linkeddata/rdflib.js/blob/main/Documentation/turtle-intro.html
Example using local identifiers with the default ':' prefix, which is assumed by rdflib.js.
```turtle
:this a :Example;
:age 123.
```