-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bookmarks-rdflib: simplify storage discovery
there is no need to distinguish documents and containers, since the module will handle the nuances anyway when creating or listing bookmarks
- Loading branch information
Showing
6 changed files
with
44 additions
and
79 deletions.
There are no files selected for viewing
24 changes: 9 additions & 15 deletions
24
bookmarks/rdflib/examples/create-bookmark-within-container.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import BookmarksModule from "../dist/index.js"; | ||
import { Fetcher, graph, UpdateManager } from "rdflib"; | ||
import BookmarksModule from '../dist/index.js'; | ||
import {Fetcher, graph, UpdateManager} from "rdflib"; | ||
|
||
const store = graph(); | ||
const fetcher = new Fetcher(store); | ||
const updater = new UpdateManager(store); | ||
const bookmarks = new BookmarksModule({ store, fetcher, updater }); | ||
|
||
const storages = await bookmarks.discoverStorage("http://localhost:3000/alice/profile/card#me"); | ||
const privateContainerUrl = storages.private.containerUrls[0]; | ||
if (!privateContainerUrl) { | ||
throw new Error("there is no private container for bookmarks"); | ||
} | ||
const store = graph() | ||
const fetcher = new Fetcher(store) | ||
const updater = new UpdateManager(store) | ||
const bookmarks = new BookmarksModule({store, fetcher, updater}) | ||
|
||
const uri = await bookmarks.createBookmark({ | ||
storageUrl: privateContainerUrl, | ||
storageUrl: "http://localhost:3000/alice/bookmarks/", | ||
title: "My favorite website", | ||
url: "https://favorite.example" | ||
}); | ||
}) | ||
|
||
console.log("new bookmark: " + uri); | ||
console.log("new bookmark: " + uri) |
24 changes: 9 additions & 15 deletions
24
bookmarks/rdflib/examples/create-bookmark-within-document.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import BookmarksModule from "../dist/index.js"; | ||
import { Fetcher, graph, UpdateManager } from "rdflib"; | ||
import BookmarksModule from '../dist/index.js'; | ||
import {Fetcher, graph, UpdateManager} from "rdflib"; | ||
|
||
const store = graph(); | ||
const fetcher = new Fetcher(store); | ||
const updater = new UpdateManager(store); | ||
const bookmarks = new BookmarksModule({ store, fetcher, updater }); | ||
|
||
const storages = await bookmarks.discoverStorage("http://localhost:3000/alice/profile/card#me"); | ||
const publicDocumentUrl = storages.public.documentUrls[0]; | ||
if (!publicDocumentUrl) { | ||
throw new Error("there is no public document for bookmarks"); | ||
} | ||
const store = graph() | ||
const fetcher = new Fetcher(store) | ||
const updater = new UpdateManager(store) | ||
const bookmarks = new BookmarksModule({store, fetcher, updater}) | ||
|
||
const uri = await bookmarks.createBookmark({ | ||
storageUrl: publicDocumentUrl, | ||
storageUrl: "http://localhost:3000/alice/public/bookmarks", | ||
title: "My favorite website", | ||
url: "https://favorite.example" | ||
}); | ||
}) | ||
|
||
console.log("new bookmark: " + uri); | ||
console.log("new bookmark: " + uri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters