solid-panes 3.7.3-125af630 → 3.7.3-18da570b

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.
Files changed (103) hide show
  1. package/dist/RDFXMLPane.js +58 -0
  2. package/dist/RDFXMLPane.js.map +1 -0
  3. package/dist/argument/argumentPane.js +61 -0
  4. package/dist/argument/argumentPane.js.map +1 -0
  5. package/dist/attach/attachPane.js +394 -0
  6. package/dist/attach/attachPane.js.map +1 -0
  7. package/dist/audio/audioPane.js +182 -0
  8. package/dist/audio/audioPane.js.map +1 -0
  9. package/dist/classInstancePane.js +92 -0
  10. package/dist/classInstancePane.js.map +1 -0
  11. package/dist/dashboard/basicPreferences.js +121 -129
  12. package/dist/dashboard/basicPreferences.js.map +1 -1
  13. package/dist/dashboard/dashboardPane.js +60 -54
  14. package/dist/dashboard/dashboardPane.js.map +1 -1
  15. package/dist/dashboard/homepage.js +45 -54
  16. package/dist/dashboard/homepage.js.map +1 -1
  17. package/dist/dataContentPane.js +259 -0
  18. package/dist/dataContentPane.js.map +1 -0
  19. package/dist/defaultPane.js +75 -0
  20. package/dist/defaultPane.js.map +1 -0
  21. package/dist/dokieli/dokieliPane.js +169 -0
  22. package/dist/dokieli/dokieliPane.js.map +1 -0
  23. package/dist/dokieli/new.js +28 -0
  24. package/dist/dokieli/new.js.map +1 -0
  25. package/dist/form/pane.js +185 -0
  26. package/dist/form/pane.js.map +1 -0
  27. package/dist/global.d.js +2 -0
  28. package/dist/global.d.js.map +1 -0
  29. package/dist/home/homePane.js +60 -55
  30. package/dist/home/homePane.js.map +1 -1
  31. package/dist/humanReadablePane.js +135 -0
  32. package/dist/humanReadablePane.js.map +1 -0
  33. package/dist/imagePane.js +70 -0
  34. package/dist/imagePane.js.map +1 -0
  35. package/dist/index.js +86 -25
  36. package/dist/index.js.map +1 -1
  37. package/dist/internal/internalPane.js +168 -179
  38. package/dist/internal/internalPane.js.map +1 -1
  39. package/dist/mainPage/footer.js +13 -7
  40. package/dist/mainPage/footer.js.map +1 -1
  41. package/dist/mainPage/header.js +59 -58
  42. package/dist/mainPage/header.js.map +1 -1
  43. package/dist/mainPage/index.js +19 -24
  44. package/dist/mainPage/index.js.map +1 -1
  45. package/dist/microblogPane/microblogPane.js +1031 -0
  46. package/dist/microblogPane/microblogPane.js.map +1 -0
  47. package/dist/n3Pane.js +56 -0
  48. package/dist/n3Pane.js.map +1 -0
  49. package/dist/outline/context.js +17 -11
  50. package/dist/outline/context.js.map +1 -1
  51. package/dist/outline/manager.js +1997 -0
  52. package/dist/outline/manager.js.map +1 -0
  53. package/dist/outline/outlineIcons.js +127 -0
  54. package/dist/outline/outlineIcons.js.map +1 -0
  55. package/dist/outline/propertyViews.js +39 -28
  56. package/dist/outline/propertyViews.js.map +1 -1
  57. package/dist/outline/queryByExample.js +285 -0
  58. package/dist/outline/queryByExample.js.map +1 -0
  59. package/dist/outline/userInput.js +1819 -0
  60. package/dist/outline/userInput.js.map +1 -0
  61. package/dist/outline/viewAsImage.js +13 -5
  62. package/dist/outline/viewAsImage.js.map +1 -1
  63. package/dist/outline/viewAsMbox.js +20 -11
  64. package/dist/outline/viewAsMbox.js.map +1 -1
  65. package/dist/pad/padPane.js +395 -404
  66. package/dist/pad/padPane.js.map +1 -1
  67. package/dist/playlist/playlistPane.js +124 -0
  68. package/dist/playlist/playlistPane.js.map +1 -0
  69. package/dist/registerPanes.js +146 -0
  70. package/dist/registerPanes.js.map +1 -0
  71. package/dist/schedule/schedulePane.js +888 -0
  72. package/dist/schedule/schedulePane.js.map +1 -0
  73. package/dist/sharing/sharingPane.js +36 -32
  74. package/dist/sharing/sharingPane.js.map +1 -1
  75. package/dist/slideshow/slideshowPane.js +80 -0
  76. package/dist/slideshow/slideshowPane.js.map +1 -0
  77. package/dist/socialPane.js +430 -0
  78. package/dist/socialPane.js.map +1 -0
  79. package/dist/tabbed/tabbedPane.js +54 -51
  80. package/dist/tabbed/tabbedPane.js.map +1 -1
  81. package/dist/tableViewPane.js +57 -0
  82. package/dist/tableViewPane.js.map +1 -0
  83. package/dist/transaction/pane.js +478 -0
  84. package/dist/transaction/pane.js.map +1 -0
  85. package/dist/transaction/period.js +324 -0
  86. package/dist/transaction/period.js.map +1 -0
  87. package/dist/trip/tripPane.js +175 -0
  88. package/dist/trip/tripPane.js.map +1 -0
  89. package/dist/trustedApplications/trustedApplications.dom.js +134 -146
  90. package/dist/trustedApplications/trustedApplications.dom.js.map +1 -1
  91. package/dist/trustedApplications/trustedApplications.utils.js +20 -20
  92. package/dist/trustedApplications/trustedApplications.utils.js.map +1 -1
  93. package/dist/trustedApplications/trustedApplications.view.js +51 -57
  94. package/dist/trustedApplications/trustedApplications.view.js.map +1 -1
  95. package/dist/types.js +5 -1
  96. package/dist/types.js.map +1 -1
  97. package/dist/ui/pane.js +147 -0
  98. package/dist/ui/pane.js.map +1 -0
  99. package/dist/versionInfo.js +35 -29
  100. package/dist/versionInfo.js.map +1 -1
  101. package/dist/video/videoPane.js +43 -0
  102. package/dist/video/videoPane.js.map +1 -0
  103. package/package.json +4 -3
@@ -1,420 +1,411 @@
1
- import { icons, ns, pad, widgets, login } from 'solid-ui';
2
- import { authn } from 'solid-logic';
3
- import { graph, log, NamedNode, Namespace, sym, serialize } from 'rdflib';
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 _solidLogic = require("solid-logic");
9
+ var _rdflib = require("rdflib");
4
10
  /* pad Pane
5
11
  **
6
12
  */
13
+
7
14
  const paneDef = {
8
- // icon: (module.__dirname || __dirname) + 'images/ColourOn.png',
9
- icon: icons.iconBase + 'noun_79217.svg',
10
- name: 'pad',
11
- audience: [ns.solid('PowerUser')],
12
- // Does the subject deserve an pad pane?
13
- label: function (subject, context) {
14
- const t = context.session.store.findTypeURIs(subject);
15
- if (t['http://www.w3.org/ns/pim/pad#Notepad']) {
16
- return 'pad';
17
- }
18
- return null; // No under other circumstances
19
- },
20
- mintClass: ns.pad('Notepad'),
21
- mintNew: function (context, newPaneOptions) {
22
- const store = context.session.store;
23
- const updater = store.updater;
24
- if (newPaneOptions.me && !newPaneOptions.me.uri) {
25
- throw new Error('notepad mintNew: Invalid userid');
15
+ // icon: (module.__dirname || __dirname) + 'images/ColourOn.png',
16
+ icon: _solidUi.icons.iconBase + 'noun_79217.svg',
17
+ name: 'pad',
18
+ audience: [_solidUi.ns.solid('PowerUser')],
19
+ // Does the subject deserve an pad pane?
20
+ label: function (subject, context) {
21
+ const t = context.session.store.findTypeURIs(subject);
22
+ if (t['http://www.w3.org/ns/pim/pad#Notepad']) {
23
+ return 'pad';
24
+ }
25
+ return null; // No under other circumstances
26
+ },
27
+ mintClass: _solidUi.ns.pad('Notepad'),
28
+ mintNew: function (context, newPaneOptions) {
29
+ const store = context.session.store;
30
+ const updater = store.updater;
31
+ if (newPaneOptions.me && !newPaneOptions.me.uri) {
32
+ throw new Error('notepad mintNew: Invalid userid');
33
+ }
34
+ const newInstance = newPaneOptions.newInstance = newPaneOptions.newInstance || store.sym(newPaneOptions.newBase + 'index.ttl#this');
35
+ // const newInstance = kb.sym(newBase + 'pad.ttl#thisPad');
36
+ const newPadDoc = newInstance.doc();
37
+ store.add(newInstance, _solidUi.ns.rdf('type'), _solidUi.ns.pad('Notepad'), newPadDoc);
38
+ store.add(newInstance, _solidUi.ns.dc('title'), 'Shared Notes', newPadDoc);
39
+ store.add(newInstance, _solidUi.ns.dc('created'), new Date(), newPadDoc); // @@ TODO Remove casting
40
+ if (newPaneOptions.me) {
41
+ store.add(newInstance, _solidUi.ns.dc('author'), newPaneOptions.me, newPadDoc);
42
+ }
43
+ // kb.add(newInstance, ns.pad('next'), newInstance, newPadDoc);
44
+ // linked list empty @@
45
+ const chunk = store.sym(newInstance.uri + '_line0');
46
+ store.add(newInstance, _solidUi.ns.pad('next'), chunk, newPadDoc); // Linked list has one entry
47
+ store.add(chunk, _solidUi.ns.pad('next'), newInstance, newPadDoc);
48
+ store.add(chunk, _solidUi.ns.dc('author'), newPaneOptions.me, newPadDoc);
49
+ store.add(chunk, _solidUi.ns.sioc('content'), '', newPadDoc);
50
+ return new Promise(function (resolve, reject) {
51
+ if (!updater) {
52
+ reject(new Error('Have no updater'));
53
+ return;
54
+ }
55
+ updater.put(newPadDoc, store.statementsMatching(undefined, undefined, undefined, newPadDoc), 'text/turtle', function (uri2, ok, message) {
56
+ if (ok) {
57
+ resolve(newPaneOptions);
58
+ } else {
59
+ reject(new Error('FAILED to save new tool at: ' + uri2 + ' : ' + message));
26
60
  }
27
- const newInstance = (newPaneOptions.newInstance =
28
- newPaneOptions.newInstance ||
29
- store.sym(newPaneOptions.newBase + 'index.ttl#this'));
30
- // const newInstance = kb.sym(newBase + 'pad.ttl#thisPad');
31
- const newPadDoc = newInstance.doc();
32
- store.add(newInstance, ns.rdf('type'), ns.pad('Notepad'), newPadDoc);
33
- store.add(newInstance, ns.dc('title'), 'Shared Notes', newPadDoc);
34
- store.add(newInstance, ns.dc('created'), new Date(), newPadDoc); // @@ TODO Remove casting
35
- if (newPaneOptions.me) {
36
- store.add(newInstance, ns.dc('author'), newPaneOptions.me, newPadDoc);
61
+ });
62
+ });
63
+ },
64
+ // and follow instructions there
65
+ // @@ TODO Set better type for paneOptions
66
+ render: function (subject, context, paneOptions) {
67
+ const dom = context.dom;
68
+ const store = context.session.store;
69
+ // Utility functions
70
+ const complainIfBad = function (ok, message) {
71
+ if (!ok) {
72
+ div.appendChild(_solidUi.widgets.errorMessageBlock(dom, message, 'pink'));
73
+ }
74
+ };
75
+ const clearElement = function (ele) {
76
+ while (ele.firstChild) {
77
+ ele.removeChild(ele.firstChild);
78
+ }
79
+ return ele;
80
+ };
81
+
82
+ // Access control
83
+
84
+ // Two constiations of ACL for this app, public read and public read/write
85
+ // In all cases owner has read write control
86
+ const genACLtext = function (docURI, aclURI, allWrite) {
87
+ const g = (0, _rdflib.graph)();
88
+ const auth = (0, _rdflib.Namespace)('http://www.w3.org/ns/auth/acl#');
89
+ let a = g.sym(aclURI + '#a1');
90
+ const acl = g.sym(aclURI);
91
+ const doc = g.sym(docURI);
92
+ g.add(a, _solidUi.ns.rdf('type'), auth('Authorization'), acl);
93
+ g.add(a, auth('accessTo'), doc, acl);
94
+ g.add(a, auth('agent'), me, acl);
95
+ g.add(a, auth('mode'), auth('Read'), acl);
96
+ g.add(a, auth('mode'), auth('Write'), acl);
97
+ g.add(a, auth('mode'), auth('Control'), acl);
98
+ a = g.sym(aclURI + '#a2');
99
+ g.add(a, _solidUi.ns.rdf('type'), auth('Authorization'), acl);
100
+ g.add(a, auth('accessTo'), doc, acl);
101
+ g.add(a, auth('agentClass'), _solidUi.ns.foaf('Agent'), acl);
102
+ g.add(a, auth('mode'), auth('Read'), acl);
103
+ if (allWrite) {
104
+ g.add(a, auth('mode'), auth('Write'), acl);
105
+ }
106
+ // TODO: Figure out why `serialize` isn't on the type definition according to TypeScript:
107
+ return (0, _rdflib.serialize)(acl, g, aclURI, 'text/turtle');
108
+ };
109
+
110
+ /**
111
+ * @param docURI
112
+ * @param allWrite
113
+ * @param callbackFunction
114
+ *
115
+ * @returns {Promise<Response>}
116
+ */
117
+ const setACL = function setACL(docURI, allWrite, callbackFunction) {
118
+ const aclDoc = store.any((0, _rdflib.sym)(docURI), (0, _rdflib.sym)('http://www.iana.org/assignments/link-relations/acl')); // @@ check that this get set by web.js
119
+ if (!fetcher) {
120
+ throw new Error('Have no fetcher');
121
+ }
122
+ if (aclDoc) {
123
+ // Great we already know where it is
124
+ const aclText = genACLtext(docURI, aclDoc.uri, allWrite);
125
+ return fetcher.webOperation('PUT', aclDoc.uri, {
126
+ data: aclText,
127
+ contentType: 'text/turtle'
128
+ }).then(() => callbackFunction(true)).catch(err => {
129
+ callbackFunction(false, err.message);
130
+ });
131
+ } else {
132
+ return fetcher.load(docURI).catch(err => {
133
+ callbackFunction(false, 'Getting headers for ACL: ' + err);
134
+ }).then(() => {
135
+ const aclDoc = store.any((0, _rdflib.sym)(docURI), (0, _rdflib.sym)('http://www.iana.org/assignments/link-relations/acl'));
136
+ if (!aclDoc) {
137
+ // complainIfBad(false, "No Link rel=ACL header for " + docURI);
138
+ throw new Error('No Link rel=ACL header for ' + docURI);
139
+ }
140
+ const aclText = genACLtext(docURI, aclDoc.uri, allWrite);
141
+ return fetcher.webOperation('PUT', aclDoc.uri, {
142
+ data: aclText,
143
+ contentType: 'text/turtle'
144
+ });
145
+ }).then(() => callbackFunction(true)).catch(err => {
146
+ callbackFunction(false, err.message);
147
+ });
148
+ }
149
+ };
150
+
151
+ // Reproduction: spawn a new instance
152
+ //
153
+ // Viral growth path: user of app decides to make another instance
154
+ const newInstanceButton = function () {
155
+ const button = div.appendChild(dom.createElement('button'));
156
+ button.textContent = 'Start another pad';
157
+ button.addEventListener('click', function () {
158
+ return showBootstrap(subject, spawnArea, 'pad');
159
+ });
160
+ return button;
161
+ };
162
+
163
+ // Option of either using the workspace system or just typing in a URI
164
+ const showBootstrap = function showBootstrap(thisInstance, container, noun) {
165
+ const div = clearElement(container);
166
+ const appDetails = {
167
+ noun: 'notepad'
168
+ };
169
+ div.appendChild(_solidUi.login.newAppInstance(dom, appDetails, (workspace, newBase) => {
170
+ // FIXME: not sure if this will work at all, just
171
+ // trying to get the types to match - Michiel.
172
+ return initializeNewInstanceInWorkspace(new _rdflib.NamedNode(workspace || newBase));
173
+ }));
174
+ div.appendChild(dom.createElement('hr')); // @@
175
+
176
+ const p = div.appendChild(dom.createElement('p'));
177
+ p.textContent = 'Where would you like to store the data for the ' + noun + '? ' + 'Give the URL of the directory where you would like the data stored.';
178
+ const baseField = div.appendChild(dom.createElement('input'));
179
+ baseField.setAttribute('type', 'text');
180
+ baseField.size = 80 // really a string
181
+ ;
182
+ baseField.label = 'base URL';
183
+ baseField.autocomplete = 'on';
184
+ div.appendChild(dom.createElement('br')); // @@
185
+
186
+ const button = div.appendChild(dom.createElement('button'));
187
+ button.textContent = 'Start new ' + noun + ' at this URI';
188
+ button.addEventListener('click', function (_e) {
189
+ let newBase = baseField.value;
190
+ if (newBase.slice(-1) !== '/') {
191
+ newBase += '/';
37
192
  }
38
- // kb.add(newInstance, ns.pad('next'), newInstance, newPadDoc);
39
- // linked list empty @@
40
- const chunk = store.sym(newInstance.uri + '_line0');
41
- store.add(newInstance, ns.pad('next'), chunk, newPadDoc); // Linked list has one entry
42
- store.add(chunk, ns.pad('next'), newInstance, newPadDoc);
43
- store.add(chunk, ns.dc('author'), newPaneOptions.me, newPadDoc);
44
- store.add(chunk, ns.sioc('content'), '', newPadDoc);
45
- return new Promise(function (resolve, reject) {
46
- if (!updater) {
47
- reject(new Error('Have no updater'));
48
- return;
49
- }
50
- updater.put(newPadDoc, store.statementsMatching(undefined, undefined, undefined, newPadDoc), 'text/turtle', function (uri2, ok, message) {
51
- if (ok) {
52
- resolve(newPaneOptions);
53
- }
54
- else {
55
- reject(new Error('FAILED to save new tool at: ' + uri2 + ' : ' + message));
193
+ initializeNewInstanceAtBase(thisInstance, newBase);
194
+ });
195
+ };
196
+
197
+ // Create new document files for new instance of app
198
+ const initializeNewInstanceInWorkspace = function (ws) {
199
+ // @@ TODO Clean up type for newBase
200
+ let newBase = store.any(ws, _solidUi.ns.space('uriPrefix'));
201
+ if (!newBase) {
202
+ newBase = ws.uri.split('#')[0];
203
+ } else {
204
+ newBase = newBase.value;
205
+ }
206
+ if (newBase.slice(-1) !== '/') {
207
+ _rdflib.log.error(appPathSegment + ': No / at end of uriPrefix ' + newBase); // @@ paramater?
208
+ newBase = newBase + '/';
209
+ }
210
+ const now = new Date();
211
+ newBase += appPathSegment + '/id' + now.getTime() + '/'; // unique id
212
+
213
+ initializeNewInstanceAtBase(thisInstance, newBase);
214
+ };
215
+ const initializeNewInstanceAtBase = function (thisInstance, newBase) {
216
+ const here = (0, _rdflib.sym)(thisInstance.uri.split('#')[0]);
217
+ const base = here; // @@ ???
218
+
219
+ const newPadDoc = store.sym(newBase + 'pad.ttl');
220
+ const newIndexDoc = store.sym(newBase + 'index.html');
221
+ const toBeCopied = [{
222
+ local: 'index.html',
223
+ contentType: 'text/html'
224
+ }];
225
+ const newInstance = store.sym(newPadDoc.uri + '#thisPad');
226
+
227
+ // log.debug("\n Ready to put " + kb.statementsMatching(undefined, undefined, undefined, there)); //@@
228
+
229
+ const agenda = [];
230
+ let f; // @@ This needs some form of visible progress bar
231
+ for (f = 0; f < toBeCopied.length; f++) {
232
+ const item = toBeCopied[f];
233
+ const fun = function copyItem(item) {
234
+ agenda.push(function () {
235
+ const newURI = newBase + item.local;
236
+ console.log('Copying ' + base + item.local + ' to ' + newURI);
237
+ const setThatACL = function () {
238
+ setACL(newURI, false, function (ok, message) {
239
+ if (!ok) {
240
+ complainIfBad(ok, 'FAILED to set ACL ' + newURI + ' : ' + message);
241
+ console.log('FAILED to set ACL ' + newURI + ' : ' + message);
242
+ } else {
243
+ agenda.shift()(); // beware too much nesting
56
244
  }
57
- });
58
- });
59
- },
60
- // and follow instructions there
61
- // @@ TODO Set better type for paneOptions
62
- render: function (subject, context, paneOptions) {
63
- const dom = context.dom;
64
- const store = context.session.store;
65
- // Utility functions
66
- const complainIfBad = function (ok, message) {
67
- if (!ok) {
68
- div.appendChild(widgets.errorMessageBlock(dom, message, 'pink'));
245
+ });
246
+ };
247
+ if (!store.fetcher) {
248
+ throw new Error('Store has no fetcher');
69
249
  }
70
- };
71
- const clearElement = function (ele) {
72
- while (ele.firstChild) {
73
- ele.removeChild(ele.firstChild);
74
- }
75
- return ele;
76
- };
77
- // Access control
78
- // Two constiations of ACL for this app, public read and public read/write
79
- // In all cases owner has read write control
80
- const genACLtext = function (docURI, aclURI, allWrite) {
81
- const g = graph();
82
- const auth = Namespace('http://www.w3.org/ns/auth/acl#');
83
- let a = g.sym(aclURI + '#a1');
84
- const acl = g.sym(aclURI);
85
- const doc = g.sym(docURI);
86
- g.add(a, ns.rdf('type'), auth('Authorization'), acl);
87
- g.add(a, auth('accessTo'), doc, acl);
88
- g.add(a, auth('agent'), me, acl);
89
- g.add(a, auth('mode'), auth('Read'), acl);
90
- g.add(a, auth('mode'), auth('Write'), acl);
91
- g.add(a, auth('mode'), auth('Control'), acl);
92
- a = g.sym(aclURI + '#a2');
93
- g.add(a, ns.rdf('type'), auth('Authorization'), acl);
94
- g.add(a, auth('accessTo'), doc, acl);
95
- g.add(a, auth('agentClass'), ns.foaf('Agent'), acl);
96
- g.add(a, auth('mode'), auth('Read'), acl);
97
- if (allWrite) {
98
- g.add(a, auth('mode'), auth('Write'), acl);
99
- }
100
- // TODO: Figure out why `serialize` isn't on the type definition according to TypeScript:
101
- return serialize(acl, g, aclURI, 'text/turtle');
102
- };
103
- /**
104
- * @param docURI
105
- * @param allWrite
106
- * @param callbackFunction
107
- *
108
- * @returns {Promise<Response>}
109
- */
110
- const setACL = function setACL(docURI, allWrite, callbackFunction) {
111
- const aclDoc = store.any(sym(docURI), sym('http://www.iana.org/assignments/link-relations/acl')); // @@ check that this get set by web.js
112
- if (!fetcher) {
113
- throw new Error('Have no fetcher');
114
- }
115
- if (aclDoc) {
116
- // Great we already know where it is
117
- const aclText = genACLtext(docURI, aclDoc.uri, allWrite);
118
- return fetcher
119
- .webOperation('PUT', aclDoc.uri, {
120
- data: aclText,
121
- contentType: 'text/turtle'
122
- })
123
- .then(() => callbackFunction(true))
124
- .catch(err => {
125
- callbackFunction(false, err.message);
126
- });
127
- }
128
- else {
129
- return fetcher
130
- .load(docURI)
131
- .catch((err) => {
132
- callbackFunction(false, 'Getting headers for ACL: ' + err);
133
- })
134
- .then(() => {
135
- const aclDoc = store.any(sym(docURI), sym('http://www.iana.org/assignments/link-relations/acl'));
136
- if (!aclDoc) {
137
- // complainIfBad(false, "No Link rel=ACL header for " + docURI);
138
- throw new Error('No Link rel=ACL header for ' + docURI);
139
- }
140
- const aclText = genACLtext(docURI, aclDoc.uri, allWrite);
141
- return fetcher.webOperation('PUT', aclDoc.uri, {
142
- data: aclText,
143
- contentType: 'text/turtle'
144
- });
145
- })
146
- .then(() => callbackFunction(true))
147
- .catch(err => {
148
- callbackFunction(false, err.message);
149
- });
150
- }
151
- };
152
- // Reproduction: spawn a new instance
153
- //
154
- // Viral growth path: user of app decides to make another instance
155
- const newInstanceButton = function () {
156
- const button = div.appendChild(dom.createElement('button'));
157
- button.textContent = 'Start another pad';
158
- button.addEventListener('click', function () {
159
- return showBootstrap(subject, spawnArea, 'pad');
160
- });
161
- return button;
162
- };
163
- // Option of either using the workspace system or just typing in a URI
164
- const showBootstrap = function showBootstrap(thisInstance, container, noun) {
165
- const div = clearElement(container);
166
- const appDetails = { noun: 'notepad' };
167
- div.appendChild(login.newAppInstance(dom, appDetails, (workspace, newBase) => {
168
- // FIXME: not sure if this will work at all, just
169
- // trying to get the types to match - Michiel.
170
- return initializeNewInstanceInWorkspace(new NamedNode(workspace || newBase));
171
- }));
172
- div.appendChild(dom.createElement('hr')); // @@
173
- const p = div.appendChild(dom.createElement('p'));
174
- p.textContent =
175
- 'Where would you like to store the data for the ' +
176
- noun +
177
- '? ' +
178
- 'Give the URL of the directory where you would like the data stored.';
179
- const baseField = div.appendChild(dom.createElement('input'));
180
- baseField.setAttribute('type', 'text');
181
- baseField.size = 80 // really a string
182
- ;
183
- baseField.label = 'base URL';
184
- baseField.autocomplete = 'on';
185
- div.appendChild(dom.createElement('br')); // @@
186
- const button = div.appendChild(dom.createElement('button'));
187
- button.textContent = 'Start new ' + noun + ' at this URI';
188
- button.addEventListener('click', function (_e) {
189
- let newBase = baseField.value;
190
- if (newBase.slice(-1) !== '/') {
191
- newBase += '/';
192
- }
193
- initializeNewInstanceAtBase(thisInstance, newBase);
250
+ store.fetcher.webCopy(base + item.local, newBase + item.local, item.contentType).then(() => _solidLogic.authn.checkUser()).then(webId => {
251
+ me = webId;
252
+ setThatACL();
253
+ }).catch(err => {
254
+ console.log('FAILED to copy ' + base + item.local + ' : ' + err.message);
255
+ complainIfBad(false, 'FAILED to copy ' + base + item.local + ' : ' + err.message);
194
256
  });
257
+ });
195
258
  };
196
- // Create new document files for new instance of app
197
- const initializeNewInstanceInWorkspace = function (ws) {
198
- // @@ TODO Clean up type for newBase
199
- let newBase = store.any(ws, ns.space('uriPrefix'));
200
- if (!newBase) {
201
- newBase = ws.uri.split('#')[0];
202
- }
203
- else {
204
- newBase = newBase.value;
205
- }
206
- if (newBase.slice(-1) !== '/') {
207
- log.error(appPathSegment + ': No / at end of uriPrefix ' + newBase); // @@ paramater?
208
- newBase = newBase + '/';
209
- }
210
- const now = new Date();
211
- newBase += appPathSegment + '/id' + now.getTime() + '/'; // unique id
212
- initializeNewInstanceAtBase(thisInstance, newBase);
213
- };
214
- const initializeNewInstanceAtBase = function (thisInstance, newBase) {
215
- const here = sym(thisInstance.uri.split('#')[0]);
216
- const base = here; // @@ ???
217
- const newPadDoc = store.sym(newBase + 'pad.ttl');
218
- const newIndexDoc = store.sym(newBase + 'index.html');
219
- const toBeCopied = [{ local: 'index.html', contentType: 'text/html' }];
220
- const newInstance = store.sym(newPadDoc.uri + '#thisPad');
221
- // log.debug("\n Ready to put " + kb.statementsMatching(undefined, undefined, undefined, there)); //@@
222
- const agenda = [];
223
- let f; // @@ This needs some form of visible progress bar
224
- for (f = 0; f < toBeCopied.length; f++) {
225
- const item = toBeCopied[f];
226
- const fun = function copyItem(item) {
227
- agenda.push(function () {
228
- const newURI = newBase + item.local;
229
- console.log('Copying ' + base + item.local + ' to ' + newURI);
230
- const setThatACL = function () {
231
- setACL(newURI, false, function (ok, message) {
232
- if (!ok) {
233
- complainIfBad(ok, 'FAILED to set ACL ' + newURI + ' : ' + message);
234
- console.log('FAILED to set ACL ' + newURI + ' : ' + message);
235
- }
236
- else {
237
- agenda.shift()(); // beware too much nesting
238
- }
239
- });
240
- };
241
- if (!store.fetcher) {
242
- throw new Error('Store has no fetcher');
243
- }
244
- store.fetcher
245
- .webCopy(base + item.local, newBase + item.local, item.contentType)
246
- .then(() => authn.checkUser())
247
- .then(webId => {
248
- me = webId;
249
- setThatACL();
250
- })
251
- .catch(err => {
252
- console.log('FAILED to copy ' + base + item.local + ' : ' + err.message);
253
- complainIfBad(false, 'FAILED to copy ' + base + item.local + ' : ' + err.message);
254
- });
255
- });
256
- };
257
- fun(item);
258
- }
259
- agenda.push(function createNewPadDataFile() {
260
- store.add(newInstance, ns.rdf('type'), PAD('Notepad'), newPadDoc);
261
- // TODO @@ Remove casting of add
262
- store.add(newInstance, ns.dc('created'), new Date(), // @@ TODO Remove casting
263
- newPadDoc);
264
- if (me) {
265
- store.add(newInstance, ns.dc('author'), me, newPadDoc);
266
- }
267
- store.add(newInstance, PAD('next'), newInstance, newPadDoc); // linked list empty
268
- // Keep a paper trail @@ Revisit when we have non-public ones @@ Privacy
269
- store.add(newInstance, ns.space('inspiration'), thisInstance, padDoc);
270
- store.add(newInstance, ns.space('inspiration'), thisInstance, newPadDoc);
271
- if (!updater) {
272
- throw new Error('Have no updater');
273
- }
274
- updater.put(newPadDoc, store.statementsMatching(undefined, undefined, undefined, newPadDoc), 'text/turtle', function (_uri2, ok, message) {
275
- if (ok) {
276
- agenda.shift()();
277
- }
278
- else {
279
- complainIfBad(ok, 'FAILED to save new notepad at: ' +
280
- newPadDoc.uri +
281
- ' : ' +
282
- message);
283
- console.log('FAILED to save new notepad at: ' +
284
- newPadDoc.uri +
285
- ' : ' +
286
- message);
287
- }
288
- });
289
- });
290
- agenda.push(function () {
291
- setACL(newPadDoc.uri, true, function (ok, body) {
292
- complainIfBad(ok, 'Failed to set Read-Write ACL on pad data file: ' + body);
293
- if (ok)
294
- agenda.shift()();
295
- });
296
- });
297
- agenda.push(function () {
298
- // give the user links to the new app
299
- const p = div.appendChild(dom.createElement('p'));
300
- p.setAttribute('style', 'font-size: 140%;');
301
- p.innerHTML =
302
- 'Your <a href=\'' +
303
- newIndexDoc.uri +
304
- '\'><b>new notepad</b></a> is ready. ' +
305
- '<br/><br/><a href=\'' +
306
- newIndexDoc.uri +
307
- '\'>Go to new pad</a>';
308
- });
259
+ fun(item);
260
+ }
261
+ agenda.push(function createNewPadDataFile() {
262
+ store.add(newInstance, _solidUi.ns.rdf('type'), PAD('Notepad'), newPadDoc);
263
+
264
+ // TODO @@ Remove casting of add
265
+ store.add(newInstance, _solidUi.ns.dc('created'), new Date(),
266
+ // @@ TODO Remove casting
267
+ newPadDoc);
268
+ if (me) {
269
+ store.add(newInstance, _solidUi.ns.dc('author'), me, newPadDoc);
270
+ }
271
+ store.add(newInstance, PAD('next'), newInstance, newPadDoc); // linked list empty
272
+
273
+ // Keep a paper trail @@ Revisit when we have non-public ones @@ Privacy
274
+ store.add(newInstance, _solidUi.ns.space('inspiration'), thisInstance, padDoc);
275
+ store.add(newInstance, _solidUi.ns.space('inspiration'), thisInstance, newPadDoc);
276
+ if (!updater) {
277
+ throw new Error('Have no updater');
278
+ }
279
+ updater.put(newPadDoc, store.statementsMatching(undefined, undefined, undefined, newPadDoc), 'text/turtle', function (_uri2, ok, message) {
280
+ if (ok) {
309
281
  agenda.shift()();
310
- // Created new data files.
311
- };
312
- // Update on incoming changes
313
- const showResults = function (exists) {
314
- console.log('showResults()');
315
- me = authn.currentUser();
316
- authn.checkUser().then((webId) => {
317
- me = webId;
318
- });
319
- const title = store.any(subject, ns.dc('title')) || store.any(subject, ns.vcard('fn'));
320
- if (paneOptions.solo && typeof window !== 'undefined' && title) {
321
- window.document.title = title.value;
322
- }
323
- options.exists = exists;
324
- padEle = pad.notepad(dom, padDoc, subject, me, options);
325
- naviMain.appendChild(padEle);
326
- const partipationTarget = store.any(subject, ns.meeting('parentMeeting')) || subject;
327
- pad.manageParticipation(dom, naviMiddle2, padDoc, partipationTarget, me, options);
328
- if (!store.updater) {
329
- throw new Error('Store has no updater');
330
- }
331
- store.updater.setRefreshHandler(padDoc, padEle.reloadAndSync); // initiated =
332
- };
333
- // Read or create empty data file
334
- const loadPadData = function () {
335
- if (!fetcher) {
336
- throw new Error('Have no fetcher');
282
+ } else {
283
+ complainIfBad(ok, 'FAILED to save new notepad at: ' + newPadDoc.uri + ' : ' + message);
284
+ console.log('FAILED to save new notepad at: ' + newPadDoc.uri + ' : ' + message);
285
+ }
286
+ });
287
+ });
288
+ agenda.push(function () {
289
+ setACL(newPadDoc.uri, true, function (ok, body) {
290
+ complainIfBad(ok, 'Failed to set Read-Write ACL on pad data file: ' + body);
291
+ if (ok) agenda.shift()();
292
+ });
293
+ });
294
+ agenda.push(function () {
295
+ // give the user links to the new app
296
+
297
+ const p = div.appendChild(dom.createElement('p'));
298
+ p.setAttribute('style', 'font-size: 140%;');
299
+ p.innerHTML = 'Your <a href=\'' + newIndexDoc.uri + '\'><b>new notepad</b></a> is ready. ' + '<br/><br/><a href=\'' + newIndexDoc.uri + '\'>Go to new pad</a>';
300
+ });
301
+ agenda.shift()();
302
+ // Created new data files.
303
+ };
304
+
305
+ // Update on incoming changes
306
+ const showResults = function (exists) {
307
+ console.log('showResults()');
308
+ me = _solidLogic.authn.currentUser();
309
+ _solidLogic.authn.checkUser().then(webId => {
310
+ me = webId;
311
+ });
312
+ const title = store.any(subject, _solidUi.ns.dc('title')) || store.any(subject, _solidUi.ns.vcard('fn'));
313
+ if (paneOptions.solo && typeof window !== 'undefined' && title) {
314
+ window.document.title = title.value;
315
+ }
316
+ options.exists = exists;
317
+ padEle = _solidUi.pad.notepad(dom, padDoc, subject, me, options);
318
+ naviMain.appendChild(padEle);
319
+ const partipationTarget = store.any(subject, _solidUi.ns.meeting('parentMeeting')) || subject;
320
+ _solidUi.pad.manageParticipation(dom, naviMiddle2, padDoc, partipationTarget, me, options);
321
+ if (!store.updater) {
322
+ throw new Error('Store has no updater');
323
+ }
324
+ store.updater.setRefreshHandler(padDoc, padEle.reloadAndSync); // initiated =
325
+ };
326
+
327
+ // Read or create empty data file
328
+ const loadPadData = function () {
329
+ if (!fetcher) {
330
+ throw new Error('Have no fetcher');
331
+ }
332
+ fetcher.nowOrWhenFetched(padDoc.uri, undefined, function (ok, body, response) {
333
+ if (!ok) {
334
+ if (response.status === 404) {
335
+ // / Check explicitly for 404 error
336
+ console.log('Initializing results file ' + padDoc);
337
+ if (!updater) {
338
+ throw new Error('Have no updater');
337
339
  }
338
- fetcher.nowOrWhenFetched(padDoc.uri, undefined, function (ok, body, response) {
339
- if (!ok) {
340
- if (response.status === 404) {
341
- // / Check explicitly for 404 error
342
- console.log('Initializing results file ' + padDoc);
343
- if (!updater) {
344
- throw new Error('Have no updater');
345
- }
346
- updater.put(padDoc, [], 'text/turtle', function (_uri2, ok, message) {
347
- if (ok) {
348
- clearElement(naviMain);
349
- showResults(false);
350
- }
351
- else {
352
- complainIfBad(ok, 'FAILED to create results file at: ' +
353
- padDoc.uri +
354
- ' : ' +
355
- message);
356
- console.log('FAILED to craete results file at: ' +
357
- padDoc.uri +
358
- ' : ' +
359
- message);
360
- }
361
- });
362
- }
363
- else {
364
- // Other error, not 404 -- do not try to overwite the file
365
- complainIfBad(ok, 'FAILED to read results file: ' + body);
366
- }
367
- }
368
- else {
369
- // Happy read
370
- clearElement(naviMain);
371
- if (store.holds(subject, ns.rdf('type'), ns.wf('TemplateInstance'))) {
372
- showBootstrap(subject, naviMain, 'pad');
373
- }
374
- showResults(true);
375
- naviMiddle3.appendChild(newInstanceButton());
376
- }
340
+ updater.put(padDoc, [], 'text/turtle', function (_uri2, ok, message) {
341
+ if (ok) {
342
+ clearElement(naviMain);
343
+ showResults(false);
344
+ } else {
345
+ complainIfBad(ok, 'FAILED to create results file at: ' + padDoc.uri + ' : ' + message);
346
+ console.log('FAILED to craete results file at: ' + padDoc.uri + ' : ' + message);
347
+ }
377
348
  });
378
- };
379
- // Body of Pane
380
- const appPathSegment = 'app-pad.timbl.com'; // how to allocate this string and connect to
381
- const fetcher = store.fetcher;
382
- const updater = store.updater;
383
- let me;
384
- const PAD = Namespace('http://www.w3.org/ns/pim/pad#');
385
- const thisInstance = subject;
386
- const padDoc = subject.doc();
387
- let padEle;
388
- const div = dom.createElement('div');
389
- // Build the DOM
390
- const structure = div.appendChild(dom.createElement('table')); // @@ make responsive style
391
- structure.setAttribute('style', 'background-color: white; min-width: 94%; margin-right:3% margin-left: 3%; min-height: 13em;');
392
- const naviLoginoutTR = structure.appendChild(dom.createElement('tr'));
393
- naviLoginoutTR.appendChild(dom.createElement('td')); // naviLoginout1
394
- naviLoginoutTR.appendChild(dom.createElement('td'));
395
- naviLoginoutTR.appendChild(dom.createElement('td'));
396
- const naviTop = structure.appendChild(dom.createElement('tr')); // stuff
397
- const naviMain = naviTop.appendChild(dom.createElement('td'));
398
- naviMain.setAttribute('colspan', '3');
399
- const naviMiddle = structure.appendChild(dom.createElement('tr')); // controls
400
- const naviMiddle1 = naviMiddle.appendChild(dom.createElement('td'));
401
- const naviMiddle2 = naviMiddle.appendChild(dom.createElement('td'));
402
- const naviMiddle3 = naviMiddle.appendChild(dom.createElement('td'));
403
- const naviStatus = structure.appendChild(dom.createElement('tr')); // status etc
404
- const statusArea = naviStatus.appendChild(dom.createElement('div'));
405
- const naviSpawn = structure.appendChild(dom.createElement('tr')); // create new
406
- const spawnArea = naviSpawn.appendChild(dom.createElement('div'));
407
- const naviMenu = structure.appendChild(dom.createElement('tr'));
408
- naviMenu.setAttribute('class', 'naviMenu');
409
- // naviMenu.setAttribute('style', 'margin-top: 3em;');
410
- naviMenu.appendChild(dom.createElement('td')); // naviLeft
411
- naviMenu.appendChild(dom.createElement('td'));
412
- naviMenu.appendChild(dom.createElement('td'));
413
- const options = { statusArea, timingArea: naviMiddle1 };
414
- loadPadData();
415
- return div;
416
- }
349
+ } else {
350
+ // Other error, not 404 -- do not try to overwite the file
351
+ complainIfBad(ok, 'FAILED to read results file: ' + body);
352
+ }
353
+ } else {
354
+ // Happy read
355
+ clearElement(naviMain);
356
+ if (store.holds(subject, _solidUi.ns.rdf('type'), _solidUi.ns.wf('TemplateInstance'))) {
357
+ showBootstrap(subject, naviMain, 'pad');
358
+ }
359
+ showResults(true);
360
+ naviMiddle3.appendChild(newInstanceButton());
361
+ }
362
+ });
363
+ };
364
+
365
+ // Body of Pane
366
+ const appPathSegment = 'app-pad.timbl.com'; // how to allocate this string and connect to
367
+
368
+ const fetcher = store.fetcher;
369
+ const updater = store.updater;
370
+ let me;
371
+ const PAD = (0, _rdflib.Namespace)('http://www.w3.org/ns/pim/pad#');
372
+ const thisInstance = subject;
373
+ const padDoc = subject.doc();
374
+ let padEle;
375
+ const div = dom.createElement('div');
376
+
377
+ // Build the DOM
378
+ const structure = div.appendChild(dom.createElement('table')); // @@ make responsive style
379
+ structure.setAttribute('style', 'background-color: white; min-width: 94%; margin-right:3% margin-left: 3%; min-height: 13em;');
380
+ const naviLoginoutTR = structure.appendChild(dom.createElement('tr'));
381
+ naviLoginoutTR.appendChild(dom.createElement('td')); // naviLoginout1
382
+ naviLoginoutTR.appendChild(dom.createElement('td'));
383
+ naviLoginoutTR.appendChild(dom.createElement('td'));
384
+ const naviTop = structure.appendChild(dom.createElement('tr')); // stuff
385
+ const naviMain = naviTop.appendChild(dom.createElement('td'));
386
+ naviMain.setAttribute('colspan', '3');
387
+ const naviMiddle = structure.appendChild(dom.createElement('tr')); // controls
388
+ const naviMiddle1 = naviMiddle.appendChild(dom.createElement('td'));
389
+ const naviMiddle2 = naviMiddle.appendChild(dom.createElement('td'));
390
+ const naviMiddle3 = naviMiddle.appendChild(dom.createElement('td'));
391
+ const naviStatus = structure.appendChild(dom.createElement('tr')); // status etc
392
+ const statusArea = naviStatus.appendChild(dom.createElement('div'));
393
+ const naviSpawn = structure.appendChild(dom.createElement('tr')); // create new
394
+ const spawnArea = naviSpawn.appendChild(dom.createElement('div'));
395
+ const naviMenu = structure.appendChild(dom.createElement('tr'));
396
+ naviMenu.setAttribute('class', 'naviMenu');
397
+ // naviMenu.setAttribute('style', 'margin-top: 3em;');
398
+ naviMenu.appendChild(dom.createElement('td')); // naviLeft
399
+ naviMenu.appendChild(dom.createElement('td'));
400
+ naviMenu.appendChild(dom.createElement('td'));
401
+ const options = {
402
+ statusArea,
403
+ timingArea: naviMiddle1
404
+ };
405
+ loadPadData();
406
+ return div;
407
+ }
417
408
  };
418
409
  // ends
419
- export default paneDef;
410
+ var _default = exports.default = paneDef;
420
411
  //# sourceMappingURL=padPane.js.map