-
Notifications
You must be signed in to change notification settings - Fork 46
delete footer #829
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
base: staging
Are you sure you want to change the base?
delete footer #829
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I'm not sure we even want this file here. What's the purpose of moving it here? It's not even exported from any entrypoint, and isn't used internally either, so it's effectively dead code. Also, if we wanted some "header helpers" I'd also suppose they should go in the package where the header is defined, |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| /* | ||
| Copied from mashlib/src/global/metadata.ts | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't add this comment here. If you want to keep attribution, the commit message is a much better place for this. What if we keep refactoring this file in the future? It won't be "copied from mashlib" anymore. Or at what point does it stop being so? After changing one line? Two? The entire file? etc.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not mean to touch this file at all, this is an old code file used in the old header and footer believe. we will delete this when we depreciate the old header and footer. not now. |
||
| */ | ||
| import { IndexedFormula, LiveStore, NamedNode, parse, sym } from 'rdflib' | ||
| import ns from '../lib/ns' | ||
|
|
||
| /* @ts-ignore no-console */ | ||
| type ThrottleOptions = { | ||
| leading?: boolean; | ||
| throttling?: boolean; | ||
| trailing?: boolean; | ||
| } | ||
|
|
||
| /** | ||
| * @ignore exporting this only for the unit test | ||
| */ | ||
| export function getPod (): NamedNode { | ||
| const { origin, pathname } = document.location | ||
| const isDatabrowserShell = document.body?.dataset?.appShell === 'databrowser' | ||
| const segments = pathname.split('/').filter(Boolean) | ||
| const lastSegment = segments[segments.length - 1] || '' | ||
| const looksLikeFile = /\.[^/]+$/.test(lastSegment) | ||
|
|
||
| if (isDatabrowserShell && segments.length > 0 && !looksLikeFile) { | ||
| return sym(`${origin}/${segments[0]}/`) | ||
| } | ||
|
|
||
| // Root-hosted pods and static databrowser pages still use the site root. | ||
| return sym(origin).site() | ||
| } | ||
| /** | ||
| */ | ||
| export async function getPodOwner (pod: NamedNode, store: LiveStore): Promise<NamedNode | null> { | ||
| // This is a massive guess. In future | ||
| // const podOwner = sym(`${pod.uri}profile/card#me`) | ||
|
|
||
| try { | ||
| // 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 | ||
| } | ||
| if (!store.holds(pod, ns.rdf('type'), ns.space('Storage'), pod)) { | ||
| console.warn('Pod ' + pod + ' does not declare itself as a space:Storage') | ||
| return null | ||
| } | ||
| const podOwner = store.any(pod, ns.solid('owner'), null, pod) || | ||
| store.any(null, ns.space('storage'), pod, pod) | ||
| if (podOwner) { | ||
| try { | ||
| await store.fetcher.load((podOwner as NamedNode).doc()) | ||
| } catch (_err) { | ||
| console.warn('Unable to load profile of pod owner ' + podOwner) | ||
| return null | ||
| } | ||
| if (!store.holds(podOwner, ns.space('storage'), pod, (podOwner as NamedNode).doc())) { | ||
| console.warn(`Pod owner ${podOwner} does NOT list pod ${pod} as their storage`) | ||
| } | ||
| return podOwner as NamedNode// Success! | ||
| } else { // pod owner not declared in pod | ||
| // @@ TODO: This is given the structure that NSS provides | ||
| // This is a massive guess. For old pods which don't have owner link | ||
| const guess = sym(`${pod.uri}profile/card#me`) | ||
| try { | ||
| // @ts-ignore LiveStore always has fetcher | ||
| await store.fetcher.load(guess) | ||
| } catch (_err) { | ||
| console.error('Ooops. Guessed wrong pod owner webid {$guess} : can\'t load it.') | ||
| return null | ||
| } | ||
| if (store.holds(guess, ns.space('storage'), pod, guess.doc())) { | ||
| console.warn('Using guessed pod owner webid but it links back.') | ||
| return guess | ||
| } | ||
| return null | ||
| } | ||
| } | ||
| /** | ||
| * @ignore exporting this only for the unit test | ||
| */ | ||
| export function getName (store: IndexedFormula, user: NamedNode): string { | ||
| return store.anyValue(user, ns.vcard('fn'), null, user.doc()) || | ||
| store.anyValue(user, ns.foaf('name'), null, user.doc()) || | ||
| user.uri | ||
| } | ||
| /** | ||
| * @ignore exporting this only for the unit test | ||
| */ | ||
| export function throttle (func: Function, wait: number, options: ThrottleOptions = {}): (...args: any[]) => any { | ||
| let context: any, | ||
| args: any, | ||
| result: any | ||
| let timeout: any = null | ||
| let previous = 0 | ||
| const later = function () { | ||
| previous = !options.leading ? 0 : Date.now() | ||
| timeout = null | ||
| result = func.apply(context, args) | ||
| if (!timeout) context = args = null | ||
| } | ||
| return function () { | ||
| const now = Date.now() | ||
| if (!previous && !options.leading) previous = now | ||
| const remaining = wait - (now - previous) | ||
| // @ts-ignore | ||
| context = this | ||
| args = arguments | ||
| if (remaining <= 0 || remaining > wait) { | ||
| if (timeout) { | ||
| clearTimeout(timeout) | ||
| timeout = null | ||
| } | ||
| previous = now | ||
| result = func.apply(context, args) | ||
| if (!timeout) context = args = null | ||
| } else if (!timeout && options.trailing !== false) { | ||
| timeout = setTimeout(later, remaining) | ||
| } | ||
| return result | ||
| } | ||
| } | ||
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok to remove these comments? They are still part of the "prompt history", even if the code they generated is now removed.
I don't like these here either, to be honest, but if we want to keep prompt history it should be exhaustive. Maybe we can just move the to a separate .md file outside of the README or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should delete the prompts everywhere in the end. this approach was not ok. for now I deleted the prompts that I used to create the files I deleted.