forked from SolidOS/mashlib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
62 lines (52 loc) · 1.85 KB
/
index.ts
File metadata and controls
62 lines (52 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import * as $rdf from 'rdflib'
import * as panes from 'solid-panes'
import { authn, solidLogicSingleton } from 'solid-logic'
import versionInfo from './versionInfo'
import { mashStyle } from './styles/mashlib-style.js'
import './styles/mash.css'
const global: any = window
global.$rdf = $rdf
global.panes = panes
global.mashlib = {
versionInfo
}
global.panes.runDataBrowser = function (uri?:string|$rdf.NamedNode|null) {
document.getElementById('PageBody')?.setAttribute('style', mashStyle.dbLayout)
document.getElementById('PageHeader')?.setAttribute('style', mashStyle.dbLayoutHeader)
document.getElementById('PageFooter')?.setAttribute('style', mashStyle.dbLayoutFooter)
document.getElementById('DummyUUID')?.setAttribute('style', mashStyle.dbLayoutContent)
// Set up cross-site proxy
const fetcher: any = $rdf.Fetcher
fetcher.crossSiteProxyTemplate = window.origin + '/xss/?uri={uri}'
// Add web monetization tag to page header
try {
const webMonetizationTag: HTMLElement = document.createElement('meta')
webMonetizationTag.setAttribute('name', 'monetization')
webMonetizationTag.setAttribute('content', `$${window.location.host}`)
document.head.appendChild(webMonetizationTag)
} catch (e) {
console.error('Failed to add web monetization tag to page header')
}
// Authenticate the user
authn.checkUser().then(function (_profile: $rdf.NamedNode | null) {
const mainPage = panes.initMainPage(solidLogicSingleton.store, uri)
return mainPage
})
}
window.onpopstate = function (_event: any) {
global.document.outline.GotoSubject(
$rdf.sym(window.document.location.href),
true,
undefined,
true,
undefined
)
}
// It's not clear where this function is used, so unfortunately we cannot remove it:
function dump (msg: string[]) {
console.log(msg.slice(0, -1))
}
global.dump = dump
export {
versionInfo
}