Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load container representation #491

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
},
"homepage": "https://github.com/solid/solid-ui",
"dependencies": {
"@mdx-js/react": "^2.1.1",
"escape-html": "^1.0.3",
"jss": "^10.9.0",
"jss-preset-default": "^10.9.0",
Expand All @@ -74,6 +73,7 @@
"@babel/preset-env": "^7.16.11",
"@babel/preset-typescript": "^7.16.7",
"@babel/runtime": "^7.17.8",
"@mdx-js/react": "^2.1.1",
"@storybook/addon-docs": "^6.4.19",
"@storybook/addon-essentials": "^6.4.19",
"@storybook/addon-links": "^6.4.19",
Expand Down
13 changes: 8 additions & 5 deletions src/utils/headerFooterHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
Copied from mashlib/src/global/metadata.ts
*/
import { IndexedFormula, LiveStore, NamedNode, sym } from 'rdflib'
import { IndexedFormula, LiveStore, NamedNode, parse, sym } from 'rdflib'
import { ns } from '..'
import { styleMap as headerStyleMap } from '../header/styleMap'
import { styleMap as footerStyleMap } from '../footer/styleMap'
Expand Down Expand Up @@ -48,8 +48,12 @@ export async function getPodOwner (pod: NamedNode, store: LiveStore): Promise<Na
// const podOwner = sym(`${pod.uri}profile/card#me`)
/* eslint-disable no-console */
try {
// @ts-ignore LiveStore always has fetcher
store.fetcher.load(pod)
// load turtle Container representation
if (!store.any(pod, null, ns.ldp('Container'), pod)) {
const response = await store.fetcher.webOperation('GET', pod.uri, store.fetcher.initFetchOptions(pod.uri, { headers: { accept: 'text/turtle' } }))
const containerTurtle = response.responseText
parse(containerTurtle as string, store, pod.uri, 'text/turtle')
}
} catch (err) {
console.error('Error loading pod ' + pod + ': ' + err)
return null
Expand All @@ -62,8 +66,7 @@ export async function getPodOwner (pod: NamedNode, store: LiveStore): Promise<Na
store.any(null, ns.space('storage'), pod, pod)
if (podOwner) {
try {
// @ts-ignore LiveStore always has fetcher
store.fetcher.load(podOwner.doc())
store.fetcher.load((podOwner as NamedNode).doc())
} catch (err) {
console.warn('Unable to load profile of pod owner ' + podOwner)
return null
Expand Down