solid-panes 4.2.4-test.4 → 4.2.4-test.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.basicPreferencesPane = void 0;
7
+ var _rdflib = require("rdflib");
8
+ var _solidUi = require("solid-ui");
9
+ /* babel-plugin-inline-import './ontologyData.ttl' */
10
+ const ontologyData = "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\n@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\n@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\n@prefix schema: <http:/schema.org/>.\n@prefix ui: <http://www.w3.org/ns/ui#>.\n@prefix vcard: <http://www.w3.org/2006/vcard/ns#>.\n@prefix : <#>.\n\nsolid:User a rdfs:Class;\n rdfs:label \"user\"@en, \"utilisateur\"@fr;\n rdfs:comment \"\"\"Any person who might use a Solid-based system\"\"\";\n rdfs:subClassOf foaf:Person, schema:Person, vcard:Individual.\n\n# Since these options are opt-in, it is a bit strange to have new users opt in\n# That they are new users - also we do not use this class for anything specific\n# yet\n# solid:NewUser a rdfs:Class;\n# rdfs:label \"new user\"@en;\n# rdfs:comment \"\"\"A person who might use a Solid-based system who has a low\n# level of familiarity with technical details.\"\"\";\n# rdfs:subClassOf solid:User.\n\nsolid:PowerUser a rdfs:Class;\n rdfs:label \"power user\"@en;\n rdfs:comment \"\"\"A person who might use a Solid-based system\n who is prepared to be given a more complex interface in order\n to be provided with more pwerful features.\"\"\";\n rdfs:subClassOf solid:User.\n\n solid:Developer a rdfs:Class;\n rdfs:label \"Developer\";\n rdfs:comment \"\"\"Any person who might use a Solid-based system,\n who has software development skills.\"\"\";\n rdfs:subClassOf solid:User.\n";
11
+ /* babel-plugin-inline-import './preferencesFormText.ttl' */
12
+ const preferencesFormText = "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>.\n@prefix solid: <http://www.w3.org/ns/solid/terms#>.\n@prefix ui: <http://www.w3.org/ns/ui#>.\n@prefix : <#>.\n\n:this <http://purl.org/dc/elements/1.1/title> \"Basic preferences\" ;\n a ui:Form ;\n ui:part :categorizeUser, :privateComment, :personalInformationHeading;\n ui:parts ( :personalInformationHeading :privateComment :categorizeUser ).\n\n:personalInformationHeading a ui:Heading;\n ui:contents \"Personal information\".\n\n:privateComment a ui:Comment;\n ui:contents \"This information is private.\".\n\n:categorizeUser a ui:Classifier;\n ui:label \"Level of user\"; ui:property rdf:type ; ui:category solid:User.\n";
13
+ const basicPreferencesPane = exports.basicPreferencesPane = {
14
+ icon: _solidUi.icons.iconBase + 'noun_Sliders_341315_000000.svg',
15
+ name: 'basicPreferences',
16
+ label: _subject => {
17
+ return null;
18
+ },
19
+ // Render the pane
20
+ // The subject should be the logged in user.
21
+ render: (subject, context) => {
22
+ const dom = context.dom;
23
+ const store = context.session.store;
24
+ function complainIfBad(ok, mess) {
25
+ if (ok) return;
26
+ container.appendChild(_solidUi.widgets.errorMessageBlock(dom, mess, '#fee'));
27
+ }
28
+ const container = dom.createElement('div');
29
+ const formArea = setupUserTypesSection(container, dom);
30
+ function loadData(doc, turtle) {
31
+ doc = doc.doc(); // remove # from URI if nec
32
+ if (!store.holds(undefined, undefined, undefined, doc)) {
33
+ // If not loaded already
34
+ ;
35
+ (0, _rdflib.parse)(turtle, store, doc.uri, 'text/turtle', null); // Load form directly
36
+ }
37
+ }
38
+ const preferencesForm = store.sym('urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597#this');
39
+ loadData(preferencesForm, preferencesFormText);
40
+ const ontologyExtra = store.sym('urn:uuid:93774ba1-d3b6-41f2-85b6-4ae27ffd2597-ONT');
41
+ loadData(ontologyExtra, ontologyData);
42
+ async function doRender() {
43
+ const renderContext = await _solidUi.login.ensureLoadedPreferences({
44
+ dom,
45
+ div: container
46
+ });
47
+ if (!renderContext.preferencesFile) {
48
+ // Could be CORS
49
+ console.log('Not doing private class preferences as no access to preferences file. ' + renderContext.preferencesFileError);
50
+ return;
51
+ }
52
+ const appendedForm = _solidUi.widgets.appendForm(dom, formArea, {}, renderContext.me, preferencesForm, renderContext.preferencesFile, complainIfBad);
53
+ appendedForm.style.borderStyle = 'none';
54
+ const trustedApplicationsView = context.session.paneRegistry.byName('trustedApplications');
55
+ if (trustedApplicationsView) {
56
+ container.appendChild(trustedApplicationsView.render(null, context));
57
+ }
58
+
59
+ // @@ TODO Remove need for casting as any and bang (!) syntax
60
+ addDeleteSection(container, store, renderContext.me, dom);
61
+ }
62
+ doRender();
63
+ return container;
64
+ }
65
+ };
66
+ function setupUserTypesSection(container, dom) {
67
+ const formContainer = createSection(container, dom, 'User types');
68
+ const description = formContainer.appendChild(dom.createElement('p'));
69
+ description.innerText = 'Here you can self-assign user types to help the data browser know which views you would like to access.';
70
+ const userTypesLink = formContainer.appendChild(dom.createElement('a'));
71
+ userTypesLink.href = 'https://github.com/solidos/userguide/#role';
72
+ userTypesLink.innerText = 'Read more';
73
+ const formArea = formContainer.appendChild(dom.createElement('div'));
74
+ return formArea;
75
+ }
76
+ var _default = exports.default = basicPreferencesPane; // ends
77
+ function addDeleteSection(container, store, profile, dom) {
78
+ const section = createSection(container, dom, 'Delete account');
79
+ const podServerNodes = store.each(profile, _solidUi.ns.space('storage'), null, profile.doc());
80
+ const podServers = podServerNodes.map(node => node.value);
81
+ const list = section.appendChild(dom.createElement('ul'));
82
+ podServers.forEach(async server => {
83
+ const deletionLink = await generateDeletionLink(server, dom);
84
+ if (deletionLink) {
85
+ const listItem = list.appendChild(dom.createElement('li'));
86
+ listItem.appendChild(deletionLink);
87
+ }
88
+ });
89
+ }
90
+ async function generateDeletionLink(podServer, dom) {
91
+ const link = dom.createElement('a');
92
+ link.textContent = `Delete your account at ${podServer}`;
93
+ const deletionUrl = await getDeletionUrlForServer(podServer);
94
+ if (typeof deletionUrl !== 'string') {
95
+ return null;
96
+ }
97
+ link.href = deletionUrl;
98
+ return link;
99
+ }
100
+
101
+ /**
102
+ * Hacky way to get the deletion link to a Pod
103
+ *
104
+ * This function infers the deletion link by assuming the URL structure of Node Solid server.
105
+ * In the future, Solid will hopefully provide a standardised way of discovering the deletion link:
106
+ * https://github.com/solidos/data-interoperability-panel/issues/18
107
+ *
108
+ * If NSS is in multi-user mode (the case on inrupt.net and solid.community), the deletion URL for
109
+ * vincent.dev.inrupt.net would be at dev.inrupt.net/account/delete. In single-user mode, the
110
+ * deletion URL would be at vincent.dev.inrupt.net/account/delete.
111
+ *
112
+ * @param server Pod server containing the user's account.
113
+ * @returns URL of the page that Node Solid Server would offer to delete the account, or null if
114
+ * the URLs we tried give invalid responses.
115
+ */
116
+ async function getDeletionUrlForServer(server) {
117
+ const singleUserUrl = new URL(server);
118
+ const multiUserUrl = new URL(server);
119
+ multiUserUrl.pathname = singleUserUrl.pathname = '/account/delete';
120
+ const hostnameParts = multiUserUrl.hostname.split('.');
121
+ // Remove `vincent.` from `vincent.dev.inrupt.net`, for example:
122
+ multiUserUrl.hostname = hostnameParts.slice(1).join('.');
123
+ const multiUserNssResponse = await fetch(multiUserUrl.href, {
124
+ method: 'HEAD'
125
+ });
126
+ if (multiUserNssResponse.ok) {
127
+ return multiUserUrl.href;
128
+ }
129
+ const singleUserNssResponse = await fetch(singleUserUrl.href, {
130
+ method: 'HEAD'
131
+ });
132
+ if (singleUserNssResponse.ok) {
133
+ return singleUserUrl.href;
134
+ }
135
+ return null;
136
+ }
137
+ function createSection(container, dom, title) {
138
+ const section = container.appendChild(dom.createElement('div'));
139
+ section.style.border = '0.3em solid #418d99';
140
+ section.style.borderRadius = '0.5em';
141
+ section.style.padding = '0.7em';
142
+ section.style.marginTop = '0.7em';
143
+ const titleElement = section.appendChild(dom.createElement('h3'));
144
+ titleElement.innerText = title;
145
+ return section;
146
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = exports.dashboardPane = void 0;
7
+ var _solidUi = require("solid-ui");
8
+ var _solidLogic = require("solid-logic");
9
+ var _homepage = require("./homepage");
10
+ const dashboardPane = exports.dashboardPane = {
11
+ icon: _solidUi.icons.iconBase + 'noun_547570.svg',
12
+ name: 'dashboard',
13
+ label: subject => {
14
+ if (subject.termType === 'NamedNode' && subject.uri === subject.site().uri) {
15
+ return 'Dashboard';
16
+ }
17
+ return null;
18
+ },
19
+ render: (subject, context) => {
20
+ console.log('Dashboard Pane Render');
21
+ const dom = context.dom;
22
+ const container = dom.createElement('div');
23
+ const runBuildPage = () => {
24
+ container.innerHTML = '';
25
+ buildPage(container, _solidLogic.authn.currentUser() || null, context, subject);
26
+ };
27
+ _solidLogic.authSession.events.on('login', () => {
28
+ // console.log('On Login')
29
+ runBuildPage();
30
+ });
31
+ _solidLogic.authSession.events.on('sessionRestore', () => {
32
+ // console.log('On Session Restore')
33
+ runBuildPage();
34
+ });
35
+ // console.log('Initial Load')
36
+ runBuildPage();
37
+ return container;
38
+ }
39
+ };
40
+ function buildPage(container, webId, context, subject) {
41
+ // if uri then SolidOS is a browse.html web app
42
+ const uri = new URL(window.location.href).searchParams.get('uri');
43
+ if (webId && (uri || webId.site().uri === subject.site().uri)) {
44
+ return buildDashboard(container, context);
45
+ }
46
+ return buildHomePage(container, subject);
47
+ }
48
+ function buildDashboard(container, context) {
49
+ // console.log('build dashboard')
50
+ // @@ TODO get a proper type
51
+ const outliner = context.getOutliner(context.dom);
52
+ outliner.getDashboard().then(dashboard => container.appendChild(dashboard));
53
+ }
54
+ function buildHomePage(container, subject) {
55
+ // console.log('build home page')
56
+ const wrapper = document.createElement('div');
57
+ container.appendChild(wrapper);
58
+ const shadow = wrapper.attachShadow({
59
+ mode: 'open'
60
+ });
61
+ const link = document.createElement('link');
62
+ link.rel = 'stylesheet';
63
+ link.href = '/common/css/bootstrap.min.css';
64
+ shadow.appendChild(link);
65
+ (0, _homepage.generateHomepage)(subject, _solidLogic.store, _solidLogic.store.fetcher).then(homepage => shadow.appendChild(homepage));
66
+ }
67
+ var _default = exports.default = dashboardPane;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.generateHomepage = generateHomepage;
7
+ var _rdflib = require("rdflib");
8
+ var _solidUi = require("solid-ui");
9
+ async function generateHomepage(subject, store, fetcher) {
10
+ const ownersProfile = await loadProfile(subject, store, fetcher);
11
+ const name = getName(store, ownersProfile);
12
+ const wrapper = document.createElement('div');
13
+ wrapper.classList.add('container');
14
+ wrapper.appendChild(createTitle(ownersProfile.uri, name));
15
+ wrapper.appendChild(createDataSection(name));
16
+ return wrapper;
17
+ }
18
+ function createDataSection(name) {
19
+ const dataSection = document.createElement('section');
20
+ const title = document.createElement('h2');
21
+ title.innerText = 'Data';
22
+ dataSection.appendChild(title);
23
+ const listGroup = document.createElement('div');
24
+ listGroup.classList.add('list-group');
25
+ dataSection.appendChild(listGroup);
26
+ const publicDataLink = document.createElement('a');
27
+ publicDataLink.classList.add('list-group-item');
28
+ publicDataLink.href = window.document.location.href + 'public/';
29
+ publicDataLink.innerText = `View ${name}'s files`;
30
+ listGroup.appendChild(publicDataLink);
31
+ return dataSection;
32
+ }
33
+ function createTitle(uri, name) {
34
+ const profileLink = document.createElement('a');
35
+ profileLink.href = uri;
36
+ profileLink.innerText = name;
37
+ const profileLinkPost = document.createElement('span');
38
+ profileLinkPost.innerText = '\'s Pod';
39
+ const title = document.createElement('h1');
40
+ title.appendChild(profileLink);
41
+ title.appendChild(profileLinkPost);
42
+ return title;
43
+ }
44
+ async function loadProfile(subject, store, fetcher) {
45
+ const pod = subject.site().uri;
46
+ // TODO: This is a hack - we cannot assume that the profile is at this document, but we will live with it for now
47
+ const webId = (0, _rdflib.sym)(`${pod}profile/card#me`);
48
+ try {
49
+ await fetcher.load(webId);
50
+ return webId;
51
+ } catch (err) {
52
+ // Fall back to pod root and any discovered profile links.
53
+ }
54
+ try {
55
+ await fetcher.load(subject);
56
+ } catch (err) {
57
+ return subject;
58
+ }
59
+ const primaryTopic = store.any(subject, _solidUi.ns.foaf('primaryTopic'), null, subject.doc());
60
+ if (primaryTopic && primaryTopic.termType === 'NamedNode') {
61
+ try {
62
+ await fetcher.load(primaryTopic);
63
+ return primaryTopic;
64
+ } catch (err) {
65
+ return subject;
66
+ }
67
+ }
68
+ return subject;
69
+ }
70
+ function getName(store, ownersProfile) {
71
+ return store.anyValue(ownersProfile, _solidUi.ns.vcard('fn'), null, ownersProfile.doc()) || store.anyValue(ownersProfile, _solidUi.ns.foaf('name'), null, ownersProfile.doc()) || new URL(ownersProfile.uri).host.split('.')[0];
72
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _solidLogic = require("solid-logic");
8
+ var _solidUi = require("solid-ui");
9
+ /* Home Pane
10
+ **
11
+ ** The home pane is avaiable everywhere and allows a user
12
+ ** to
13
+ ** - keep track of their stuff
14
+ ** - make new things, and possibly
15
+ ** - keep track of accounts and workspaces etc
16
+ **
17
+ */
18
+
19
+ const HomePaneSource = {
20
+ icon: _solidUi.icons.iconBase + 'noun_547570.svg',
21
+ // noun_25830
22
+
23
+ global: true,
24
+ name: 'home',
25
+ // Does the subject deserve an home pane?
26
+ //
27
+ // yes, always!
28
+ //
29
+ label: function () {
30
+ return 'home';
31
+ },
32
+ render: function (subject, context) {
33
+ const dom = context.dom;
34
+ const showContent = async function () {
35
+ const homePaneContext = {
36
+ div,
37
+ dom,
38
+ statusArea: div,
39
+ me
40
+ };
41
+ /*
42
+ div.appendChild(dom.createElement('h4')).textContent = 'Login status'
43
+ var loginStatusDiv = div.appendChild(context.dom.createElement('div'))
44
+ // TODO: Find out what the actual type is:
45
+ type UriType = unknown;
46
+ loginStatusDiv.appendChild(UI.login.loginStatusBox(context.dom, () => {
47
+ // Here we know new log in status
48
+ }))
49
+ */
50
+ div.appendChild(dom.createElement('h4')).textContent = 'Create new thing somewhere';
51
+ const creationDiv = div.appendChild(dom.createElement('div'));
52
+ const creationContext = {
53
+ div: creationDiv,
54
+ dom,
55
+ statusArea: div,
56
+ me
57
+ };
58
+ const relevantPanes = await _solidUi.login.filterAvailablePanes(context.session.paneRegistry.list);
59
+ _solidUi.create.newThingUI(creationContext, context, relevantPanes); // newUI Have to pass panes down
60
+
61
+ _solidUi.login.registrationList(homePaneContext, {}).then(function () {});
62
+ };
63
+ const div = dom.createElement('div');
64
+ const me = _solidLogic.authn.currentUser(); // this will be incorrect if not logged in
65
+
66
+ showContent();
67
+ return div;
68
+ }
69
+ }; // pane object
70
+
71
+ // ends
72
+ var _default = exports.default = HomePaneSource;
package/dist/index.js ADDED
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "OutlineManager", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _manager.default;
10
+ }
11
+ });
12
+ exports.UI = void 0;
13
+ Object.defineProperty(exports, "byName", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _paneRegistry.byName;
17
+ }
18
+ });
19
+ exports.getOutliner = getOutliner;
20
+ Object.defineProperty(exports, "initMainPage", {
21
+ enumerable: true,
22
+ get: function () {
23
+ return _mainPage.default;
24
+ }
25
+ });
26
+ Object.defineProperty(exports, "list", {
27
+ enumerable: true,
28
+ get: function () {
29
+ return _paneRegistry.list;
30
+ }
31
+ });
32
+ Object.defineProperty(exports, "paneForIcon", {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _paneRegistry.paneForIcon;
36
+ }
37
+ });
38
+ Object.defineProperty(exports, "paneForPredicate", {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _paneRegistry.paneForPredicate;
42
+ }
43
+ });
44
+ Object.defineProperty(exports, "register", {
45
+ enumerable: true,
46
+ get: function () {
47
+ return _paneRegistry.register;
48
+ }
49
+ });
50
+ Object.defineProperty(exports, "versionInfo", {
51
+ enumerable: true,
52
+ get: function () {
53
+ return _versionInfo.default;
54
+ }
55
+ });
56
+ var _versionInfo = _interopRequireDefault(require("./versionInfo"));
57
+ var UI = _interopRequireWildcard(require("solid-ui"));
58
+ exports.UI = UI;
59
+ var _solidLogic = require("solid-logic");
60
+ var _manager = _interopRequireDefault(require("./outline/manager.js"));
61
+ var _registerPanes = require("./registerPanes.js");
62
+ var _paneRegistry = require("pane-registry");
63
+ var _context = require("./outline/context");
64
+ var _mainPage = _interopRequireDefault(require("./mainPage"));
65
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
66
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
67
+ /* SOLID PANES
68
+ **
69
+ ** Panes are regions of the outline view in which a particular subject is
70
+ ** displayed in a particular way.
71
+ ** Different panes about the same subject are typically stacked vertically.
72
+ ** Panes may be used naked or with a pane selection header.
73
+ **
74
+ ** The label() method has two functions: it determines whether the pane is
75
+ ** relevant to a given subject, returning null if not.
76
+ ** If it is relevant, then it returns a suitable tooltip for a control which selects the pane
77
+ */
78
+
79
+ function getOutliner(dom) {
80
+ if (!dom.outlineManager) {
81
+ const context = (0, _context.createContext)(dom, {
82
+ list: _paneRegistry.list,
83
+ paneForIcon: _paneRegistry.paneForIcon,
84
+ paneForPredicate: _paneRegistry.paneForPredicate,
85
+ register: _paneRegistry.register,
86
+ byName: _paneRegistry.byName
87
+ }, _solidLogic.store, _solidLogic.solidLogicSingleton);
88
+ dom.outlineManager = new _manager.default(context);
89
+ }
90
+ return dom.outlineManager;
91
+ }
92
+ if (typeof window !== 'undefined') {
93
+ getOutliner(window.document);
94
+ }
95
+ (0, _registerPanes.registerPanes)(cjsOrEsModule => (0, _paneRegistry.register)(cjsOrEsModule.default || cjsOrEsModule));
96
+
97
+ // This has common outline mode functionality for the default and other other panes
98
+ // A separate outline manager is required per DOM in cases like a browser extension
99
+ // where there are many occurrences of window and of window.document
100
+ // But each DOM should have just one outline manager.
101
+
102
+ // export for simpler access by non-node scripts
103
+ if (typeof window !== 'undefined') {
104
+ ;
105
+ window.panes = {
106
+ getOutliner
107
+ };
108
+ }
@@ -0,0 +1,183 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _solidUi = require("solid-ui");
8
+ var _rdflib = require("rdflib");
9
+ /* Internal Pane
10
+ **
11
+ ** This outline pane contains the properties which are
12
+ ** internal to the user's interaction with the web, and are not normally displayed
13
+ */
14
+ /* global alert confirm */
15
+
16
+ const pane = {
17
+ icon: _solidUi.icons.originalIconBase + 'tango/22-emblem-system.png',
18
+ name: 'internal',
19
+ label: function () {
20
+ return 'under the hood'; // There is often a URI even of no statements
21
+ },
22
+ render: function (subject, context) {
23
+ const dom = context.dom;
24
+ const store = context.session.store;
25
+ const canonizedSubject = store.canon(subject);
26
+ const types = store.findTypeURIs(canonizedSubject);
27
+ function filter(pred) {
28
+ if (types['http://www.w3.org/2007/ont/link#ProtocolEvent']) return true; // display everything for them
29
+ const view = context.session.paneRegistry.byName('internal');
30
+ return view && view.predicates && !!(typeof view.predicates[pred.uri] !== 'undefined');
31
+ }
32
+ const div = dom.createElement('div');
33
+ div.setAttribute('class', 'internalPane');
34
+ div.setAttribute('style', 'background-color: #ddddff; padding: 0.5em; border-radius: 1em;');
35
+ function deleteRecursive(kb, folder) {
36
+ const fetcher = kb.fetcher;
37
+ if (!fetcher) {
38
+ console.error('No fetcher available');
39
+ return;
40
+ }
41
+ return new Promise(function (resolve, reject) {
42
+ fetcher.load(folder).then(function () {
43
+ const promises = kb.each(folder, _solidUi.ns.ldp('contains')).map(file => {
44
+ if (kb.holds(file, _solidUi.ns.rdf('type'), _solidUi.ns.ldp('BasicContainer'))) {
45
+ return deleteRecursive(kb, file);
46
+ } else {
47
+ console.log('deleteRecursive leaf file: ' + file);
48
+ return fetcher.webOperation('DELETE', file.uri);
49
+ }
50
+ });
51
+ Promise.all(promises).then(() => {
52
+ console.log('deleteRecursive empty folder: ' + folder);
53
+ fetcher.webOperation('DELETE', folder.uri).then(() => {
54
+ console.log('Deleted Ok: ' + folder);
55
+ resolve(undefined);
56
+ }).catch(err => {
57
+ const str = 'Unable to delete ' + folder + ': ' + err;
58
+ console.log(str);
59
+ reject(new Error(str));
60
+ });
61
+ resolve(undefined);
62
+ }, err => {
63
+ alert(err);
64
+ reject(err);
65
+ });
66
+ });
67
+ });
68
+ }
69
+ const isDocument = subject.uri && !subject.uri.includes('#');
70
+ if (isDocument) {
71
+ const controls = div.appendChild(dom.createElement('table'));
72
+ controls.style.width = '100%';
73
+ controls.style.margin = '1em';
74
+ const controlRow = controls.appendChild(dom.createElement('tr'));
75
+ const deleteCell = controlRow.appendChild(dom.createElement('td'));
76
+ const isFolder = subject.uri && subject.uri.endsWith('/') || store.holds(subject, _solidUi.ns.rdf('type'), _solidUi.ns.ldp('Container'));
77
+ const noun = isFolder ? 'folder' : 'file';
78
+ if (!isProtectedUri(subject)) {
79
+ console.log(subject);
80
+ const deleteButton = _solidUi.widgets.deleteButtonWithCheck(dom, deleteCell, noun, function () {
81
+ if (!confirm(`Are you sure you want to delete ${subject}? This cannot be undone.`)) {
82
+ return;
83
+ }
84
+ // @@ TODO Remove casing of store.fetcher
85
+ if (!store.fetcher) {
86
+ throw new Error('Store has no fetcher');
87
+ }
88
+ const promise = isFolder ? deleteRecursive(store, subject) || Promise.resolve() : store.fetcher.webOperation('DELETE', subject.uri) || Promise.resolve();
89
+ promise.then(() => {
90
+ const str = 'Deleted: ' + subject;
91
+ console.log(str);
92
+ }).catch(err => {
93
+ const str = 'Unable to delete ' + subject + ': ' + err;
94
+ console.log(str);
95
+ alert(str);
96
+ });
97
+ });
98
+ deleteButton.style = 'height: 2em;';
99
+ deleteButton.class = ''; // Remove hover hide
100
+ deleteCell.appendChild(deleteButton);
101
+ }
102
+ const refreshCell = controlRow.appendChild(dom.createElement('td'));
103
+ const refreshButton = _solidUi.widgets.button(dom, _solidUi.icons.iconBase + 'noun_479395.svg', 'refresh');
104
+ refreshCell.appendChild(refreshButton);
105
+ refreshButton.addEventListener('click', () => {
106
+ if (!store.fetcher) {
107
+ throw new Error('Store has no fetcher');
108
+ }
109
+ store.fetcher.refresh(subject, function (ok, errm) {
110
+ let str;
111
+ if (ok) {
112
+ str = 'Refreshed OK: ' + subject;
113
+ } else {
114
+ str = 'Error refreshing: ' + subject + ': ' + errm;
115
+ }
116
+ console.log(str);
117
+ alert(str);
118
+ });
119
+ });
120
+ }
121
+ let plist = store.statementsMatching(subject);
122
+ let docURI = '';
123
+ if (!store.fetcher) {
124
+ throw new Error('Store has no fetcher');
125
+ }
126
+ if (subject.uri) {
127
+ plist.push((0, _rdflib.st)(subject, (0, _rdflib.sym)('http://www.w3.org/2007/ont/link#uri'), subject.uri,
128
+ // @@ TODO Remove casting
129
+ store.fetcher.appNode));
130
+ if (subject.uri.indexOf('#') >= 0) {
131
+ docURI = subject.uri.split('#')[0];
132
+ plist.push((0, _rdflib.st)(subject, (0, _rdflib.sym)('http://www.w3.org/2007/ont/link#documentURI'), subject.uri.split('#')[0],
133
+ // @@ TODO Remove casting
134
+ store.fetcher.appNode));
135
+ plist.push((0, _rdflib.st)(subject, (0, _rdflib.sym)('http://www.w3.org/2007/ont/link#document'), (0, _rdflib.sym)(subject.uri.split('#')[0]), store.fetcher.appNode));
136
+ } else {
137
+ docURI = subject.uri;
138
+ }
139
+ }
140
+ if (docURI) {
141
+ if (!store.updater) {
142
+ throw new Error('Store has no updater');
143
+ }
144
+ const ed = store.updater.editable(docURI);
145
+ if (ed) {
146
+ plist.push((0, _rdflib.st)(subject, (0, _rdflib.sym)('http://www.w3.org/ns/rww#editable'), (0, _rdflib.literal)(ed.toString()), store.fetcher.appNode));
147
+ }
148
+ }
149
+ // @@ TODO get a proper type
150
+ const outliner = context.getOutliner(dom);
151
+ outliner.appendPropertyTRs(div, plist, false, filter);
152
+ plist = store.statementsMatching(undefined, undefined, subject);
153
+ outliner.appendPropertyTRs(div, plist, true, filter);
154
+ return div;
155
+ },
156
+ predicates: {
157
+ // Predicates used for inner workings. Under the hood
158
+ 'http://www.w3.org/2007/ont/link#request': 1,
159
+ 'http://www.w3.org/2007/ont/link#requestedBy': 1,
160
+ 'http://www.w3.org/2007/ont/link#source': 1,
161
+ 'http://www.w3.org/2007/ont/link#session': 2,
162
+ // 2= test neg but display
163
+ 'http://www.w3.org/2007/ont/link#uri': 1,
164
+ 'http://www.w3.org/2007/ont/link#documentURI': 1,
165
+ 'http://www.w3.org/2007/ont/link#document': 1,
166
+ 'http://www.w3.org/2007/ont/link#all': 1,
167
+ // From userinput.js
168
+ 'http://www.w3.org/2007/ont/link#Document': 1,
169
+ 'http://www.w3.org/ns/rww#editable': 1,
170
+ 'http://www.w3.org/2000/01/rdf-schema#seeAlso': 1,
171
+ 'http://www.w3.org/2002/07/owl#': 1
172
+ },
173
+ classes: {
174
+ // Things which are inherently already undercover
175
+ 'http://www.w3.org/2007/ont/link#ProtocolEvent': 1
176
+ }
177
+ };
178
+ function isProtectedUri(subject) {
179
+ // TODO: Could make the code below smarter by removing some of the redundancy by creating a recursive function, but did not bother now
180
+ const siteUri = subject.site().uri;
181
+ return subject.uri === siteUri || subject.uri === siteUri + 'profile/' || subject.uri === siteUri + 'profile/card' || subject.uri === siteUri + 'settings/' || subject.uri === siteUri + 'settings/prefs.ttl' || subject.uri === siteUri + 'settings/privateTypeIndex.ttl' || subject.uri === siteUri + 'settings/publicTypeIndex.ttl' || subject.uri === siteUri + 'settings/serverSide.ttl';
182
+ }
183
+ var _default = exports.default = pane; // ends
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createFooter = createFooter;
7
+ var _solidUi = require("solid-ui");
8
+ /**
9
+ * links in the footer
10
+ */
11
+ const SOLID_PROJECT_URL = 'https://solidproject.org';
12
+ const SOLID_PROJECT_NAME = 'solidproject.org';
13
+ function createFooter(store) {
14
+ (0, _solidUi.initFooter)(store, setFooterOptions());
15
+ }
16
+ function setFooterOptions() {
17
+ return {
18
+ solidProjectUrl: SOLID_PROJECT_URL,
19
+ solidProjectName: SOLID_PROJECT_NAME
20
+ };
21
+ }