Skip to content

Commit d6d0d57

Browse files
committed
remo traces of the old footer web component
1 parent 53373e3 commit d6d0d57

4 files changed

Lines changed: 126 additions & 17 deletions

File tree

README.md

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -216,20 +216,6 @@ I want this all to be presented flexible in the component.
216216

217217
* Raptor mini: when we are on layout mobile we do not want to display the help menu at all.
218218

219-
* Raptor mini: Create for me a footer Lit Component in tsy style of the components I have and under v2. Take the code from this index.ts to start with.
220-
221-
* Raptor mini: Good. Now, I want the footer to be a rectangular with round corners, grey background and it should have an adjustable position.
222-
223-
* Raptor mini: The content of the footer should be different upon loggedin or not.
224-
If not logged in, it should say:
225-
Title Public View
226-
You are viewving this profile as a guest,
227-
And if logged in:
228-
Title: Logged in View
229-
You are logged in as nameOfLoggedIn user.
230-
231-
* Raptor mini: add a readme to the Footer component with example.
232-
233219
* Claude Sonnet 4.6: Make the drop down as a list under the input field and enlarge the pop up, make it higher, adjustable to fit the drop down. And make the drop down arrow area larger
234220

235221
* GPT-5.4 Model: can you wire up the keyboard interactions and aria attributes for Select?

src/components/footer/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/types/custom-elements.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type DialogFooter from '../components/dialog-footer/DialogFooter'
1414
import type DialogHeader from '../components/dialog-header/DialogHeader'
1515
import type DialogProvider from '../components/dialog-provider/DialogProvider'
1616
import type DialogsRoot from '../components/dialogs-root/DialogsRoot'
17-
import type Footer from '../components/footer/Footer'
1817
import type Guard from '../components/guard/Guard'
1918
import type Header from '../components/header/Header'
2019
import type Input from '../components/input/Input'
@@ -42,7 +41,6 @@ declare global {
4241
'solid-ui-dialog-header': DialogHeader
4342
'solid-ui-dialog-provider': DialogProvider
4443
'solid-ui-dialogs-root': DialogsRoot
45-
'solid-ui-footer': Footer
4644
'solid-ui-guard': Guard
4745
'solid-ui-header': Header
4846
'solid-ui-input': Input

src/utils/headerHelpers.ts

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
Copied from mashlib/src/global/metadata.ts
3+
*/
4+
import { IndexedFormula, LiveStore, NamedNode, parse, sym } from 'rdflib'
5+
import ns from '../lib/ns'
6+
7+
/* @ts-ignore no-console */
8+
type ThrottleOptions = {
9+
leading?: boolean;
10+
throttling?: boolean;
11+
trailing?: boolean;
12+
}
13+
14+
/**
15+
* @ignore exporting this only for the unit test
16+
*/
17+
export function getPod (): NamedNode {
18+
const { origin, pathname } = document.location
19+
const isDatabrowserShell = document.body?.dataset?.appShell === 'databrowser'
20+
const segments = pathname.split('/').filter(Boolean)
21+
const lastSegment = segments[segments.length - 1] || ''
22+
const looksLikeFile = /\.[^/]+$/.test(lastSegment)
23+
24+
if (isDatabrowserShell && segments.length > 0 && !looksLikeFile) {
25+
return sym(`${origin}/${segments[0]}/`)
26+
}
27+
28+
// Root-hosted pods and static databrowser pages still use the site root.
29+
return sym(origin).site()
30+
}
31+
/**
32+
*/
33+
export async function getPodOwner (pod: NamedNode, store: LiveStore): Promise<NamedNode | null> {
34+
// This is a massive guess. In future
35+
// const podOwner = sym(`${pod.uri}profile/card#me`)
36+
37+
try {
38+
// load turtle Container representation
39+
if (!store.any(pod, null, ns.ldp('Container'), pod)) {
40+
const response = await store.fetcher.webOperation('GET', pod.uri, store.fetcher.initFetchOptions(pod.uri, { headers: { accept: 'text/turtle' } }))
41+
const containerTurtle = response.responseText
42+
parse(containerTurtle as string, store, pod.uri, 'text/turtle')
43+
}
44+
} catch (err) {
45+
console.error('Error loading pod ' + pod + ': ' + err)
46+
return null
47+
}
48+
if (!store.holds(pod, ns.rdf('type'), ns.space('Storage'), pod)) {
49+
console.warn('Pod ' + pod + ' does not declare itself as a space:Storage')
50+
return null
51+
}
52+
const podOwner = store.any(pod, ns.solid('owner'), null, pod) ||
53+
store.any(null, ns.space('storage'), pod, pod)
54+
if (podOwner) {
55+
try {
56+
await store.fetcher.load((podOwner as NamedNode).doc())
57+
} catch (_err) {
58+
console.warn('Unable to load profile of pod owner ' + podOwner)
59+
return null
60+
}
61+
if (!store.holds(podOwner, ns.space('storage'), pod, (podOwner as NamedNode).doc())) {
62+
console.warn(`Pod owner ${podOwner} does NOT list pod ${pod} as their storage`)
63+
}
64+
return podOwner as NamedNode// Success!
65+
} else { // pod owner not declared in pod
66+
// @@ TODO: This is given the structure that NSS provides
67+
// This is a massive guess. For old pods which don't have owner link
68+
const guess = sym(`${pod.uri}profile/card#me`)
69+
try {
70+
// @ts-ignore LiveStore always has fetcher
71+
await store.fetcher.load(guess)
72+
} catch (_err) {
73+
console.error('Ooops. Guessed wrong pod owner webid {$guess} : can\'t load it.')
74+
return null
75+
}
76+
if (store.holds(guess, ns.space('storage'), pod, guess.doc())) {
77+
console.warn('Using guessed pod owner webid but it links back.')
78+
return guess
79+
}
80+
return null
81+
}
82+
}
83+
/**
84+
* @ignore exporting this only for the unit test
85+
*/
86+
export function getName (store: IndexedFormula, user: NamedNode): string {
87+
return store.anyValue(user, ns.vcard('fn'), null, user.doc()) ||
88+
store.anyValue(user, ns.foaf('name'), null, user.doc()) ||
89+
user.uri
90+
}
91+
/**
92+
* @ignore exporting this only for the unit test
93+
*/
94+
export function throttle (func: Function, wait: number, options: ThrottleOptions = {}): (...args: any[]) => any {
95+
let context: any,
96+
args: any,
97+
result: any
98+
let timeout: any = null
99+
let previous = 0
100+
const later = function () {
101+
previous = !options.leading ? 0 : Date.now()
102+
timeout = null
103+
result = func.apply(context, args)
104+
if (!timeout) context = args = null
105+
}
106+
return function () {
107+
const now = Date.now()
108+
if (!previous && !options.leading) previous = now
109+
const remaining = wait - (now - previous)
110+
// @ts-ignore
111+
context = this
112+
args = arguments
113+
if (remaining <= 0 || remaining > wait) {
114+
if (timeout) {
115+
clearTimeout(timeout)
116+
timeout = null
117+
}
118+
previous = now
119+
result = func.apply(context, args)
120+
if (!timeout) context = args = null
121+
} else if (!timeout && options.trailing !== false) {
122+
timeout = setTimeout(later, remaining)
123+
}
124+
return result
125+
}
126+
}

0 commit comments

Comments
 (0)